This commit adds ability to check status of cached file descriptor to
make sure that it can be reused. We inspect last modification time
and number of hard links. If last modification is changed from the
last validation time, or number of hard links gets 0, we don't reuse
file descriptor. We also capped upper limit of the cached file
descriptors. If the limit is reached, we will close file descriptor
which is least recently used, and its usecount is 0.
When connection is dropped, we get "nonzero" error code ec in
read_socket callback. We can just call on_error callback if ec is
nonzero. But there is a problem when we did ordered shutdown. In
this case, we also get EOF in ec, but we don't want to call on_error
because it is not an error. To workaround this, we check return value
of should_stop(). If it is true, then we assume that HTTP/2 session
cleanly ended, and we don't call on_error.
To make use cache fd more robust manner (e.g. among several
connections), eviction of cached file descriptor now takes place using
timer. The timer is started when there is no handler (no
connections). The timeout value is hard-coded and 2 seconds.
This commit allows user to override user-agent with -H option. We
also enabled custom header support for http/1.1 requests. We also did
minor optimizations (std::vector::reserve).
This commits enables HTTP/2 server push from HTTP/2 backend to be
relayed to HTTP/2 frontend. To use this feature, --http2-bridge or
--client is required. Server push via Link header field contiues to
work.
This is a regression when we introduced SSL/TLS session resumption in
HTTP/2 backend. Before the introduction of session resumption,
conn_.tls.ssl is always nullptr when connection is made to proxy. But
we have to keep conn_.tls.ssl to enable session resumption, so our
code breaks when it is reused. This commit fixes this issue.
See GH-421
This function is useful for the client application to know that there
is a chance that request can be sent. If this function returns 0,
there is zero chance to make a request.
This commit also set error_code passed to
nghttp2_on_stream_close_callback to NGHTTP2_REFUSED_STREAM if request
is not sent.
It seems that using ev_feed_event to signal write operation is much
faster than starting watcher. This is probably due to the fact that
we don't need to wait in event loop. The same thing cannot be done in
HTTP/2 frontend, since this will raise write operation for each stream
HEADER/DATA write, which leads to very small packets, hurting
performance. Interestingly, HTTP/1 frontend also suffers the same
performance hit.