-
Notifications
You must be signed in to change notification settings - Fork 12
main/file: add support for custom headers to file serving #13
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
base: master
Are you sure you want to change the base?
Conversation
main.c
Outdated
| fprintf(stderr, "Error: invalid extra header (-z) - missing colon\n"); | ||
| exit(1); | ||
| } | ||
| extra_header->header = strdup(optarg); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you may use the optarg without duplication, see the alias parsing above
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated, thanks, though it scare me a little :)
| } | ||
| if (strchr(optarg, ':') == NULL) { | ||
| fprintf(stderr, "Error: invalid extra header (-z) - missing colon\n"); | ||
| exit(1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would rather not exit the whole webserver and lost access to Luci if the header is ivalid. But it looks like everywhere else the same behavior.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point, but I think if you're changing the webserver settings you should have the expectation you may mess it up and have an alternative access mechanism (i.e. ssh).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally yes, but here we in the embedded world. A user may lost an access to its router. In the same time if some header is not present and something was broken then it may be not so critical for a security.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As you pointed out, though, the general behaviour of bad options in uhttpd is that the server will not load, even if they're non-critical (e.g. missing 404 handler)... I guess I'm reluctant to change this unless someone else chimes in and says that it's the thing that's blocking a merge.
stokito
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
This allows us to set 'Cache-Control: no-cache', which makes it possible to develop LuCI JS without resorting to disabling the cache in the browser dev tools. Signed-off-by: James Haggerty <james.haggerty@morsemicro.com>
938187b to
1bdaac0
Compare
This allows us to set something like: list extra_header 'Cache-Control: no-cache' And no longer run into issues with caching JS files during development. The intent would be to make the sync.py script automatically check/set this. See: openwrt/luci#7059 and openwrt/uhttpd#13 Approved-by: Evan Benn Approved-by: Lyall Beveridge
|
@wryun: What is the situation of your PR? |
|
@Neustradamus can you explain what you mean by 'the situation of your PR'? I'm just hoping someone merges it; I have no permissions on this (or any) OpenWrt repository. |
| " -d string URL decode given string\n" | ||
| " -r string Specify basic auth realm\n" | ||
| " -m string MD5 crypt given string\n" | ||
| " -z string Add additional response header (can use multiple times)\n" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would like to change the z to H with long opt --header. Similar to curl but also similarly to npm http-server, to thecoshman/http and miniserve
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
H is, unfortunately, already used (see getopt). longopts are not supported.
|
I don't have merge right and all my path(es?) to the uhttpd waiting years to be reviewed. The uhttpd started as a replacement for the BusyBox httpd (here it contains the
|
|
@stokito as identified in the original issue, the behaviour of browser caching without a Cache-Control header is based on heuristics. What this means is that they don't always check the ETag, but sometimes present a cached file if they think the resource has not changed for some time. When making JS changes this is frustrating, as it means you need to have all caching disabled and the debug tools open for reliable behaviour. |
This allows us to set 'Cache-Control: no-cache', which makes it possible to develop LuCI JS without resorting to disabling the cache in the browser dev tools.
See: openwrt/luci#7059
If this was merged, the follow up to OpenWrt would look something like: