-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Description
Introduction
This issue is a followup of the Zephyr Networking Forum discussion from March 2019.
Problem description
Since the net_app API has been removed, Zephyr does not have any HTTP APIs.
This should be brought back - this time with the usage of the regular sockets.
Some use cases:
HTTP Server:
- Simple On device web server
- Enabling Websocket API
HTTP Client:
- Simple POST requests to send sensor values
- Enabling Webscocket API
HTTP Authentication:
- At least digest auth supported
Proposed change
As it was mentioned in various places by various people (github, mailing lists), it would be a nice thing to port an existing HTTP implementation, rather than implementing it from scratch.
There are two main things to take into account when researching the libraries:
- Licensing
- It's completeness
Notes on the second bullet: it should be complete, but the features needed for Zephyr need to be evaluated. This library needs to fit to a resource constrained system after all. On the other hand it cannot be so small that it would be equally effective to just write it from scratch.
For example, libcurl was suggested in #13212, as it is considered to be the de-facto standard for HTTP.
The issue with it is: GPL licensed (it is not, I was wrong in this case), and its meant to be complete - i.e. such libs may just be too large for Zephyr
Detailed RFC
We did some research on that, and unfortunately it turns out that there are similar issues with most of what's available. It's either copyleft licensed or extensively large (or both).
What we think could be a good start, is civetweb (https://github.com/civetweb/civetweb).
Some highlights:
- MIT licensed, could be imported to Zephyr
- it is meant to be embeddedable (to other applications - can be a single binary easily)
- it seems to have a well defined API
- seems to be quite flexible (many of its features can be just disabled and compiled out)
Major disadvantages (concerns raised during the Networking Forum):
- Not really ported to any embedded platform
- It seems to be a little bit of everything
That is really something that is done by-design by the developers (it was needed to create an easily embeddable code). Yet this needs to be evaluated whether this is something that is acceptable in Zephyr (as this is something that will have to be dealt with).
To sum up: this is not a perfect candidate, but yet it may be the best there is.
Concerns and Unresolved Questions
The suggested library does not support any client functionality (except a WS client). It is only a HTTP server.
The HTTP client API candidate is still needed.
Alternatives
The very opposite thing - so writing this from scratch. This is something that should probably be taken into account too.
Notes
We are hoping this issue will trigger some discussion and gather opinions. Both on the proposed server API (civetweb), but also on other available libraries that could be good candidates. Opinions about the general idea of porting an existing API instead of writing it from scratch are very welcome too.