-
Notifications
You must be signed in to change notification settings - Fork 7k
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
net: http: Add compression support in HTTP server #86490
base: main
Are you sure you want to change the base?
net: http: Add compression support in HTTP server #86490
Conversation
c247ea7
to
f0533cf
Compare
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.
No objection to the feature, just wondering if it would make sense to have this more configurable. I mean that if user only needs gzip support, then the other methods are useless to compile in. Perhaps have a Kconfig entries for each supported compression method, and then compile out code that is not needed.
f0533cf
to
70779c4
Compare
@jukkar I agree in the sense that a kconfig to enable compression in general would be good. I am however not sure if kconfigs for each compression method would't be to much as the only thing they would remove is one I will also have a look at the tests that are failing (need to add tests covering compression anyhow). |
Add compression support using the accept-encoding header to the http server static filesystem resource. Signed-off-by: Carlo Kirchmeier <carlo.kirchmeier@zuehlke.com>
70779c4
to
7271508
Compare
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.
Any chance for some test for this? Or at least we should enable it in the sample to make sure it builds.
@@ -201,6 +201,21 @@ config WEBSOCKET_CONSOLE | |||
help | |||
Hidden option that is enabled only when all the necessary options | |||
needed by websocket console are set. | |||
|
|||
config HTTP_SERVER_COMPRESSION | |||
bool "Compression support in http fileserver" |
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.
bool "Compression support in http fileserver" | |
bool "Compression support in HTTP fileserver" |
HTTP_ZSTD = 4 /**< ZSTD */ | ||
}; | ||
|
||
void http_compression_parse_accept_encoding(const char *accept_encoding, size_t len, |
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 just wonder, does it need to be a public header, those efunctions seem rather internal?
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.
And also the functions should be documented using doxygen comments.
return ""; | ||
} | ||
|
||
int http_compression_from_text(enum http_compression compression[static 1], const char *text) |
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.
Why not just enum http_compression *compression
? TBH it's a bit confusing to see an 1-element array being passed here, plus, is static 1
even a valid C syntax, or just some GCC extension? First time I see a construct like this being used.
Same goes to other functions.
if (ret < 0) { | ||
len = strlen(fname); | ||
len = strlen(fname); | ||
#ifdef CONFIG_HTTP_SERVER_COMPRESSION |
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.
Can we use if (IS_ENABLED(CONFIG_HTTP_SERVER_COMPRESSION)) { ... }
whenever possible. Not only this makes code compile unconditionally, but should also allow to avoid extra ifdef slicing, like around return_filename
label.
What you have now (one Kconfig option) looks fine. |
Add compression support using the accept-encoding header to the http server static filesystem resource.
In our use case we have different files with different compressions it is therefore important that the webserver is able to handle those compressions correctly. This is a first draft of the feature. I am open to discussion on how to implement this or if this is even wanted in upstream.