Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Accept header to choose between HTML and JSON directory listings #366

Open
1 task done
palant opened this issue Apr 25, 2024 · 1 comment
Open
1 task done
Labels
enhancement New feature or request help wanted Extra attention is needed v2 v2 release

Comments

@palant
Copy link
Contributor

palant commented Apr 25, 2024

Search for duplicate feature request

  • I already searched, and this feature request or improvement is not a duplicate.

Feature scope

Improve existing functionality

Feature request related to a problem

As things are now, the decision between HTML and JSON directory listings is made in the configuration. I am unsure about the reasoning behind that, but that’s actually exactly what the Accept header is for.

Describe the solution you'd like

Use content negotiation via the Accept header to decide on the directory listing format. There is already QualityValue in the tree, it can be reused to parse the Accept header. If application/json comes up first, the format should be JSON. If text/html is found first, it should be HTML. Default if none of the two are present should be HTML.

If necessary, there can also be an explicit format query parameter to override the header.

The config setting can be removed then – or ignored with a warning to keep existing configs working.

Describe alternatives you've considered

Build target

All targets

Additional context

No response

@palant palant added enhancement New feature or request help wanted Extra attention is needed v2 v2 release labels Apr 25, 2024
@joseluisq
Copy link
Collaborator

The idea is not bad. We could use similar logic when working with the Accept-Encoding but of course under the --directory-listing being enabled.

I think that this feature should complement what we already have, I mean the --directory-listing-format.
For example, an idea that comes to mind could be to introduce a new entry in the DirListFmt enum like Auto or something to tell SWS to determine the directory listing format automatically via the Accept header rather than using --directory-listing-format.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed v2 v2 release
Projects
None yet
Development

No branches or pull requests

2 participants