reaktivity / nukleus-http.java

HTTP Nukleus Implementation
Apache License 2.0
0 stars 8 forks source link

Transport stream keep-alive #3

Open jfallows opened 7 years ago

jfallows commented 7 years ago

HTTP/1.1 supports reuse of the underlying connection to avoid setup and teardown overhead. Each underlying connection consists of a pair of correlated input and output transport streams.

Connection reuse includes decoding (server) or encoding (client) multiple HTTP/1.1 requests on the same transport, but the transport is only eligible for reuse if the previous request has already been sent a response (server) or received a response (client).

Note: allowing subsequent requests inbound on the same transport stream while a previous response is still pending requires more complete support for HTTP/1.1 pipelining, which is problematic because responses must be written in the same order as the corresponding requests even though the work done to produce those responses may complete in a different order.

An outbound HTTP request that would most naturally target an existing transport stream, may need to either trigger creation of a new transport stream, or remain cached until an underlying transport stream becomes available.

cmebarrow commented 7 years ago

HTTP Nukleus as a server now supports multiple requests on the same transport, and connection pooling has been implemented for HTTP Nukleus when acting as a client. I am however leaving this issue open because if a few more loose ends need tidying up:

  1. Harden handling of pipelined requests when acting as a server to prevent parallel execution
  2. Add more tests for the handling of connection close header, to make sure we handle it properly, especially when acting as a server (it is handled properly when acting as a client, server may need some work to ensure we do not attempt to process the next request after receiving a request with connection close header: this would be invalid but we should make sure we handle it properly)