Repository navigation
Conversation
|
This implements the listing parsing discussed in #10139 for nginx HTML and JSON, with tests and docs. A review whenever there is time would be great. |
|
The |
|
The |
|
A quick update: all 9 checks are passing on the current head. I am happy to rework the listing detection or the flag name if you would like it different, and can move the discussion to the issue first if that suits you better. |
|
Friendly ping for a review when someone has time. The lint failure on the generated docs region is fixed (fd56f78); happy to adjust the approach if you would like it discussed on the issue first. |
|
The issue reporter said on #10139 that they will test this when they can and hope for a quick review. Could someone take a look when there is time? Happy to change anything. |
|
The reporter of #10139 said on the issue that they will test this change. The checks pass and the branch is current; a review is the one thing outstanding. Thanks, and happy to adjust. |
|
I don't really like the whole idea of parsing things out of listings! We currently parse links which are a well defined HTML concept with a tag we can search for. Parsing sizes out of text meant for humans to read sounds very much like a game we are going to lose (I'm getting flashbacks from the FTP LIST parser that we use in rclone here, and FTP LIST is supposed to be standardized :-) I note that Caddy can provide JSON listings (see https://caddyserver.com/docs/caddyfile/directives/file_server ) as can nginx (see https://nginx.org/en/docs/http/ngx_http_autoindex_module.html ) - perhaps we should parse those only which gives 100% reliable info rather than relying on something for humans which can be configured differently (eg in nginx the size can be configured rounded to the nearest MB). I don't know if this would satisfy the original submitter or not. What do you think? |
|
I do definitely agree. So i feel like limiting this feature to only 100% JSON reliable output is the better choice. No problem for my use case to configure my nginx servers with JSON indexing only. |
|
That makes sense, thanks both. Pushed b314c52: |
|
Friendly ping for a first look at this one. If the approach needs changes, I'm glad to rework it. |
|
Checking in on this one: the JSON-listing-only change from the discussion is in b314c52. A first review would be great whenever you have time. |
|
Thanks for reworking this to JSON only. A couple of design thoughts before merging:
|
…ne#10139 When the server returns its directory listing as JSON, read the size and modification time of each file from it instead of doing a HEAD request for every file. Both the nginx (autoindex_format json) and the Caddy (file_server browse with Accept: application/json) formats are understood, told apart by the fields each item has. JSON in any other format is an error rather than a guess. Files that the listing doesn't describe still get a HEAD request. HTML listings are not parsed for sizes and times as they are meant for people and vary between servers.
b314c52 to
bd4370f
Compare
|
Thanks, all three done in bd4370f (squashed). |
What does this change do?
When the server returns its directory listing as JSON, the http backend now takes the size and modification time of each file from it instead of doing a HEAD request for every file, which is slow on directories with many files.
Two formats are understood, told apart by the fields each item has: nginx (
autoindex_format json) and Caddy (file_server browsesentAccept: application/json). JSON in any other format is an error rather than a guess. HTML listings are not read for sizes and times, so they still get the HEAD request as before. There is no option: JSON listings failed before with an unknown content type.Objects found this way have no Content-Type or header metadata from the server, the same as with
--http-no-head.Linked issue
Fixes #10139
For new or changed backends
This is a listing option on the existing read-only http backend. Besides the new unit tests I have not run
test_allagainst a remote.Checklist
test_allpasses for this backend and if submitting a new backend can provide a test account for the integration tester - see CONTRIBUTING.md.Open points
go test ./backend/http/passes, with cases for nginx, Caddy, unknown JSON formats and a listing that skips HEAD requests for listed files.