emikulic / darkhttpd

When you need a web server in a hurry.
https://unix4lyfe.org/darkhttpd/
ISC License
1.03k stars 83 forks source link

Directory listings missing size in Kodi #48

Closed hhartzer closed 6 months ago

hhartzer commented 6 months ago

Not a bug, but maybe something simple to address.

When Kodi uses darkhttpd as a HTTP source, it shows 0B for all file sizes.

This may be because the last modified date is missing. It may also be because we don't give a "-" under directory sizes.

I imagine there's some common libraries used for parsing this that could explain more.

Related: https://github.com/xbmc/xbmc/issues/17623

emikulic commented 6 months ago

Looks like Kodi is using these regexes to parse the generated directory listing: https://github.com/xbmc/xbmc/pull/17652/files

Do you want to change the regexes, or the directory listing? :)

hhartzer commented 6 months ago

Nice find!

I feel like maybe changing the directory listing is better in this case. I'm thinking the regex is trickier. 😛

I'll dive in more and see which example is closest (maybe nginx?).

emikulic commented 6 months ago

Looking at e.g. xbmc/filesystem/test/data/httpdirectory/apache-html.html, it's probably the mtime is missing like you said at the start.

I'd be okay with adding mtimes to the generated listing.

emikulic commented 6 months ago

Looking at the regexes they use to parse the HTML (lol etc), I think we should generate something that matches ([0-9]{4})-([0-9]{2})-([0-9]{2}) ([0-9]{2}):([0-9]{2}) i.e. yyyy-mm-dd hh:mm

hhartzer commented 6 months ago

Sounds good! ISO-8601 seems like a great option here. Looks like not down to the seconds?

Should it respond in local time or UTC? I forgot which the Date header was doing.

emikulic commented 6 months ago

Date: is GMT, but I vote for local time for directory listings. Usually I'm using darkhttpd to copy files between machines that are in my own timezone.

If you don't want this behavior, you can always env TZ=UTC ./darkhttpd /path