-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
Add HTTP server support #64465
Add HTTP server support #64465
Conversation
include/zephyr/net/http/server.h
Outdated
|
||
#endif | ||
|
||
#define CLIENT_BUFFER_SIZE CONFIG_NET_HTTP_SERVER_CLIENT_BUFFER_SIZE |
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.
These should probably not go in this header.
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.
Yes, agreed. I think we need to create internal http server header file for these.
subsys/net/lib/http/http_server.c
Outdated
if (IS_ENABLED(CONFIG_NET_SOCKETS_SOCKOPT_TLS)) { | ||
proto = IPPROTO_TLS_1_2; | ||
} |
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've created a CoAP server implementation (#64265) inspired by the work that was done in the previous PR.
I did leave out the secure variant for now, since this way of doing it, forces it to either secure or non-secure. But no option to support both.
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.
IMHO we need to allow supporting both at the same time so some tweaking is needed here. Initially I was thinking that application could do the socket initialization for TLS which would move the https burden from the lib to the application needing that support. For example, when registering the service, user could supply a function pointer that the server could then call to initialize the socket to use TLS.
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 have been through the same process, I was working on a PoC for my CoAP server where the service is either secure or not, something like:
#define COAP_SERVICE_DEFINE(_name, _host, _port, _flags) /* Put NULL in the DTLS data */
#define COAP_SERVICE_DEFINE_SECURE(_name, _host, _port, _flags, _dtls_cfg) /* Some struct with DTLS info is provided */
The server implementation could then verify the secure data struct on how to initialize the sockets.
d7ac3f9
to
46cdc8c
Compare
|
While I like the customization level, moving the TLS complexities outside of the library seems like a step back to me. I would prefer, as a user, that the subsystem provides the implementation for a certain configuration. I see some benefits that way:
If the subsystem would expose a Just my 2 cents :) |
Perhaps this is a way to go. So we could provide a default way to setup the TLS but if needed application could override that and do things its own way. |
46cdc8c
to
6a66467
Compare
Worked on supporting multiple clients. Did not get it fully working yet. |
6a66467
to
e796b23
Compare
This is now somewhat usable as a library. More than one client can be supported at the same time. Still missing:
|
e796b23
to
ffd7b7d
Compare
Changes:
|
c39edd5
to
5f76516
Compare
HTTPS works now with attached certs which were copied from echo-server sample. |
I am wondering about the dynamic resources, how they are defined and what kind of API between application and lib would work best. Any suggestion / ideas for that? |
As in REST APIs? It would be a different kind of handler with a different "detail" pointer. |
Yes, I was thinking that too and did some experiments. Will send changes after get something working. |
5f76516
to
643c66a
Compare
Updated according to comments. |
7d39ec2
to
839d8bb
Compare
74f9f1d
to
7c1e6aa
Compare
|
394f1b2
to
7f78ce7
Compare
@cfriedt @pdgendt @nxpadamm @MeisterBob and all the others in the review list. I have the original branch (with 75 commits) as a backup if we need it for anything. |
Just to be clear - not all remaining/known issues, but the implementation is quite functional already and the PR is already pretty large. Further improvements/fixes can/will be submitted in separate PRs. |
@Emna-Rekik 🪁🎉🥳 |
Have separate macros to setup a HTTPS service. Signed-off-by: Jukka Rissanen <[email protected]>
Add HTTP/2 helper libraries to encode and decode HPACK encoded headers, according to RFC7541. HPACK string encoding requires to support certain set of Huffman codes, therefore implement Huffman encoder/decoder as well. Signed-off-by: Robert Lubos <[email protected]>
Original code developed as a GSoC 2023 project by Emna Rekik. Code refactored in order to provide better bisectability as the origical commits were not bisectable. The server supports static and dynamic resources, managed by HTTP_SERVICE/HTTP_RESOURCE macros. Fixes zephyrproject-rtos#59685 Fixes zephyrproject-rtos#59686 Fixes zephyrproject-rtos#59688 Fixes zephyrproject-rtos#59690 Fixes zephyrproject-rtos#59670 Fixes zephyrproject-rtos#59700 Fixes zephyrproject-rtos#59684 Fixes zephyrproject-rtos#59693 Fixes zephyrproject-rtos#59693 Fixes zephyrproject-rtos#59694 Fixes zephyrproject-rtos#59699 Fixes zephyrproject-rtos#59696 Fixes zephyrproject-rtos#59688 Fixes zephyrproject-rtos#59690 Fixes zephyrproject-rtos#59670 Fixes zephyrproject-rtos#59700 Fixes zephyrproject-rtos#59685 Fixes zephyrproject-rtos#59686 Fixes zephyrproject-rtos#59688 Fixes zephyrproject-rtos#59691 Signed-off-by: Emna Rekik <[email protected]> Signed-off-by: Jukka Rissanen <[email protected]> Signed-off-by: Robert Lubos <[email protected]>
Tests for HTTP server support. Signed-off-by: Emna Rekik <[email protected]> Signed-off-by: Jukka Rissanen <[email protected]> Signed-off-by: Robert Lubos <[email protected]>
A simple HTTP server sample application. Signed-off-by: Emna Rekik <[email protected]> Signed-off-by: Jukka Rissanen <[email protected]> Signed-off-by: Robert Lubos <[email protected]>
7f78ce7
to
49ccbff
Compare
|
Related to discussion in #70817, @fabiobaltieri would you mind force merging this, there are binary certificate files that cause CI to fail. |
Thanks @jukkar I don't have permissions to do it myself though, @carlescufi can you take care of this one? |
@rlubos @jukkar As a follow-up to this PR, could you please look at adding minimal docs for this new feature? |
Yes, that is in the todo list, we will address this before 3.7. |
This is based on the work done in #59669. I created a new PR as the original PR was kind of messy and long.
I fixed the tests so that they now use picolibc. Also the sample is tweaked to compile properly in native_sim.
Fixed also Posix support (basically removed it) so that it compiles properly with socket API.