-
Notifications
You must be signed in to change notification settings - Fork 6
Week 1
This week was all about reading code and deciding what to implement.
We can differentiate three different parts in the libmicrohttpd-HTTP2 project:
-
Because MHD implements only the HTTP/1 protocol, there is no setting (MHD_FLAG or MHD_OPTION) to indicate the supported HTTP versions by the web server.
We can inspire us from Libcurl, which implements this as the option CURLOPT_HTTP_VERSION, with values, e.g., CURL_HTTP_VERSION_1_1, CURL_HTTP_VERSION_2_0, etc.
-
The code to handle the connection and parse the HTTP request in src/microhttpd/connection.c is tightly coupled.
MHD was designed (and coded) with the HTTP state machine and parser mixed with the socket read/write operations. We need to separate these two parts (the connection handler and the HTTP request parser) so it's easy to switch between protocols.
Since HTTP/2 is binary (instead of textual) and provides multiplexing (instead of ordered and blocking requests), the implementation code will be very different from the one for HTTP/1.
-
The nghttp2 library works with byte strings (input and output), leaving outside its scope the handling of I/O operations.
Consequently, we need a connection_http2.c file that will manage the HTTP2 connections, reading the data and passing it to nghttp2.
A client has several ways to connect to an HTTP2 web server:
- Send an upgrade request using HTTP/1.1 over a clear text connection.
- Negotiate HTTP2 over a TLS connection.
- Simply issue HTTP2 requests over a clear text connection, having prior knowledge that the server supports HTTP/2.
The two last options talk directly HTTP/2 when sending data to the server. As a first step, we can start by implementing the connection_http2.c functionality.
The first option needs to switch from an HTTP/1 connection to an HTTP/2. MHD implements the upgrade request by giving the socket to the "MHD application" to use it directly for bi-directional communication with the client. Consequently, the socket is not responsability of MHD any more. Allowing this option (upgrade from HTTP/1 to HTTP/2) will introduce several changes in MHD, so I will postpone this feature until the code for HTTP/2-only connections is stable.
For end-to-end functionality, we can reuse the tests developed by MHD (see in src/examples/ and src/testcurl/). For benchmarking, we will use the tool h2load.