From RFC 7540:
Flow control and prioritization ensure that it is possible to efficiently use multiplexed streams.
TODO:
- Compare our design with.
- Proxygen's.
- libnghttp2_asio's.
- curl's.
Where does tcp::async_read_some
is called? basic_http2_server
should not
buffer structured messages, because object/memory pools whatsoever, but a new
"transaction" can be requested at any moment. So, the only appropriate place to
tcp::async_read_some
is within basic_http2_server
's async_accept
, which
opens a channel to a new stream.
It happens we might issue concurrent write requests (e.g. multiple
handlers on different streams). How to prevent concurrent writes? Nothing needs
to be done. User can already implement correct synchronization infering the
readness status from whether completion handler from the last write operation
was called or not. It's too complex, but the user can always use an underlying
basic_queue_socket
.
Is the server cleanly stoppable? Yes, just stop accepting new streams/transactions and the asio's executor will exit as soon as the remaining operations are complete.
Stateless push? HTTP/1.1
is stateless, but this is not so true for HTTP/2.0
.
HTTP/2.0
adds a new interaction mode whereby a server can push responses to a
client. Server push allows a server to speculatively send data to a client that
the server anticipates the client will need. This state is tied to an HTTP/2.0
connection, so the connection object will add the interface which can be used to
do a server push.
So, the interaction will be like:
The HTTP/2.0
connection object will:
- Act as the "acceptor" for new streams within the underlying connection.
- Buffer bytes, structure messages and dispatch them to the correct
ServerSocket
's objects. - Handle server push.
To make the code simpler, the concept of multiple streams will not be
used. Instead, after the response is delivered for each ServerSocket
object,
their "connection" will be closed. Therefore, they're closer to the concept of a
transaction. The "done" objects can be reused in new async_accept
calls.