Commit Graph

385 Commits

Author SHA1 Message Date
Tatsuhiro Tsujikawa b685747643 Add nghttp2_submit_shutdown_notice() to start graceful shutdown
nghttp2_submit_shutdown_notice() is used to notify the client that
graceful shutdown is started.  We expect that after this call, the
server application should send another GOAWAY using
nghttp2_submit_goaway() with appropriate last_stream_id.  In this
commit, we also added nghttp2_session_get_last_proc_stream_id(), which
can be used as last_stream_id parameter.

This commit implements graceful shutdown in nghttpx.  The integration
test for graceful shutdown is also added.
2015-01-22 23:21:58 +09:00
Tatsuhiro Tsujikawa 5770c6bd04 nghttpx: Return 503 on hard disconnect in HTTP/2 backend 2015-01-21 23:30:48 +09:00
Tatsuhiro Tsujikawa e219d6a94f nghttpx: Clarify error_reply upstream method
There is no application level failure in h1 upstream.  For h2, SPDY
upstreams, don't call DIE(), instead return -1 to delete handler.
2015-01-21 22:55:00 +09:00
Tatsuhiro Tsujikawa 41e72064e0 nghttpx: Log error in INFO level when frame cannot be sent 2015-01-21 22:49:00 +09:00
Tatsuhiro Tsujikawa 041d9863c2 nghttpx: Set request_start_time_ at Downstream ctor
.. so that we can avoid the problem that request_start_time_ is 0
2015-01-21 22:28:15 +09:00
Tatsuhiro Tsujikawa 8997e4369d nghttpx: Adjust backend buffers 2015-01-21 01:47:43 +09:00
Tatsuhiro Tsujikawa 5a6d6ccbd4 nghttpx: Read from backend eagerly in all upstreams 2015-01-21 01:41:17 +09:00
Tatsuhiro Tsujikawa 8059380fb0 nghttpx: Don't need to set response state to MSG_COMPLETE after error_reply 2015-01-20 23:33:45 +09:00
Tatsuhiro Tsujikawa a440bdf15e nghttpx: Response 502 if HTTP/2 backend receives invalid Content-Length 2015-01-19 23:44:23 +09:00
Tatsuhiro Tsujikawa 8004ea9726 nghttpx: Return 400 if request CL is invalid or multiple CLs 2015-01-19 22:40:37 +09:00
Tatsuhiro Tsujikawa 62b9e4bb56 nghttpx: Validate received request body length against content-length 2015-01-17 21:33:23 +09:00
Tatsuhiro Tsujikawa 441f1cc282 nghttpx: Validate received response body length against content-length 2015-01-17 21:33:23 +09:00
Tatsuhiro Tsujikawa f92110c54c nghttpx: Http2Upstream: Try to read data from backend if buffer is empty 2015-01-17 17:37:32 +09:00
Tatsuhiro Tsujikawa 90914b38f1 nghttpx: Do not limit DATA frame length 2015-01-07 01:25:43 +09:00
Tatsuhiro Tsujikawa 2fb3d5fd1f nghttpx: Remove Http2Upstream::deferred_ for now 2015-01-06 23:32:58 +09:00
Tatsuhiro Tsujikawa d80952a2bc nghttpx: Implement stream level timeout using ev_timer 2015-01-06 00:30:57 +09:00
Tatsuhiro Tsujikawa 3ae44ef2f3 nghttpd, nghttpx: Rework incoming header handling 2015-01-05 01:46:41 +09:00
Tatsuhiro Tsujikawa d157744fb2 nghttpx: Fix handling of pending data 2015-01-03 00:19:41 +09:00
Tatsuhiro Tsujikawa 7db1864766 nghttpx: Add --backend-http1-connections-per-frontend option 2015-01-03 00:19:41 +09:00
Tatsuhiro Tsujikawa bfac015d61 src: Use libev for rest of the applications 2015-01-03 00:19:41 +09:00
Tatsuhiro Tsujikawa 89291e4010 nghttpx: Improve priority handling in http2 upstream 2014-12-23 17:45:57 +09:00
Tatsuhiro Tsujikawa dce20c3e6a nghttpx: Check HTTP/2 downstream connection after certain idle time
Previously when requests are issued to HTTP/2 downstream connection,
but it turns out that connection is down, handlers of those requests
are deleted.  In some situations, we only know connection is down when
we write something to network, so we'd like to handle this kind of
situation in more robust manner.  In this change, certain seconds
passed after last network activity, we first issue PING frame to
downstream connection before issuing new HTTP request.  If writing
PING frame is failed, it means connection was lost.  In this case,
instead of deleting handler, pending requests are migrated to new
HTTP2/ downstream connection, so that it can continue without
affecting upstream connection.
2014-12-09 21:41:29 +09:00
Tatsuhiro Tsujikawa 3b03ff626a nghttpx: Don't log access log for blocked streams 2014-12-05 21:29:31 +09:00
Tatsuhiro Tsujikawa 9614611969 nghttpx: Limit # of downstream connections per host when h2 proxy is used
This commit limits the number of concurrent HTTP/1 downstream
connections to same host.  By defualt, it is limited to 8 connections.
--backend-connections-per-frontend option was replaced with
--backend-http1-connections-per-host, which changes the maximum number
of connections per host.  This limitation only kicks in when h2 proxy
is used (-s option).
2014-12-05 01:47:03 +09:00
Tatsuhiro Tsujikawa 204ff787fa nghttpx: Submit RST_STREAM if HEADERS appears in the middle of a stream 2014-11-28 00:23:46 +09:00
Tatsuhiro Tsujikawa b1f807abd1 Reformat lines with clang-format-3.5 2014-11-27 23:56:30 +09:00
Lucas Pardue 6e178653a5 fixed conflict 2014-11-23 21:10:51 +00:00
Lucas Pardue 9cf1a0c77c Add features to logging, client and server port,
time_iso8601 and request_time.
2014-11-23 20:37:51 +00:00
Tatsuhiro Tsujikawa 74ec1d3377 nghttpx: Write accesslog when upstream connection is lost for HTTP/2 and SPDY 2014-11-23 17:24:23 +09:00
Tatsuhiro Tsujikawa 1a09cef0ef nghttpx: Avoid 0-length DATA in HTTP/2 upstream 2014-11-22 21:12:28 +09:00
Tatsuhiro Tsujikawa 27609327ee nghttpx: Fix heap-after-free crash in https upstream
Add Upstream::on_handler_delete() hook to safely write log for
HttpsUpstream.
2014-11-19 01:59:09 +09:00
Tatsuhiro Tsujikawa 958cd0de64 nghttpx: Add configurable access logging format
This commit adds functionality to customize access logging format in
nghttpx.  The format variables are inspired by nginx.  The default
format is combined format.
2014-11-19 01:29:55 +09:00
Tatsuhiro Tsujikawa 1d7601edfb nghttpx: Better handling EOF from downstream connection to tunnel stream 2014-11-18 00:03:52 +09:00
Tatsuhiro Tsujikawa ce71e65aee nghttpx: Replace WARNING with WARN for consistency 2014-11-08 10:51:56 +09:00
Tatsuhiro Tsujikawa 154876a17b nghttpx: Apply TLS record length limit to DATA frame payload
This is not obvious but it makes intermediaries flush and forward DATA
frame boundary without excessive buffering.  Since we have different
TCP connections frontend and backend, this may not work.  This is
still experimental.
2014-11-06 21:14:14 +09:00
Tatsuhiro Tsujikawa f8c70993c0 nghttpx: Adjust TLS record size dynamically
Use the same behaviour the current Google server does: start with 1300
TLS record size and after transmitting 1MiB, change record size to
16384.  After 1 second idle time, reset to 1300.  Only applies to
HTTP/2 and SPDY upstream connections.
2014-11-06 02:36:53 +09:00
Tatsuhiro Tsujikawa a225bb29df nghttpx: Fix request is sent to backend prematurely with http2 upstream 2014-10-07 00:31:35 +09:00
Tatsuhiro Tsujikawa 446f8f13aa src: Move libevent related helper functions to libevent_util 2014-09-24 00:45:40 +09:00
Tatsuhiro Tsujikawa b305495a75 nghttpx: Reset both timeouts when either read or write succeeds
Previously read and write timeouts work independently.  When we are
writing response to the client, read timeout still ticks (e.g., HTTP/2
or tunneled HTTPS connection).  So read timeout may occur during long
download.  This commit fixes this issue.  This commit only fixes the
upstream part.  We need similar fix for the downstream.
2014-09-18 23:03:36 +09:00
Tatsuhiro Tsujikawa e4751a798a Replace auto_delete* with defer 2014-09-16 23:39:38 +09:00
Tatsuhiro Tsujikawa 8890e593e6 src: Add util::array_size 2014-08-28 00:45:12 +09:00
Tatsuhiro Tsujikawa 0209b7c083 nghttpx: Fix location rewrite is failed because request headers are empty
Previously we empties request headers after they are sent to
downstream in order to free memory.  But it turns out that we use
request headers when rewriting location header response field.  Also
user reported that request headers are useful to add new features.
This commits defers the deletion of request headers to the point when
response headers are deleted (which is after response headers are sent
to upstream client).
2014-08-27 21:25:25 +09:00
Tatsuhiro Tsujikawa 53ee21caa9 Remove nghttp2_on_unknown_frame_recv_callback
It is not used by library for a while.  It could be used to pass
unsupported extension frames to application, but its interface
requires library to buffer entire frame, which we'd like to avoid.
For unsupported extension frames, we will add new callbacks which does
not require buffering if they are required.
2014-08-25 21:24:04 +09:00
Tatsuhiro Tsujikawa 31528b6267 Use uint32_t for HTTP/2 error_code
h2-14 now allows extensions to define new error codes.  To allow
application callback to access such error codes, we uses uint32_t as
error_code type for structs and function parameters.  Previously we
treated unknown error code as INTERNAL_ERROR, but this change removes
this and unknown error code is passed to application callback as is.
2014-08-25 21:24:04 +09:00
Tatsuhiro Tsujikawa ab5b81bee1 Hide nghttp2_session_callbacks details and provide setter like functions
To make it possible to add new callbacks without bumping so name, we
decided to hide details of nghttp2_session_callbacks.  We provide
setter like functions to set individual callback function.
2014-08-25 21:24:04 +09:00
Tatsuhiro Tsujikawa d5dcbf6f3b nghttpx: Fix possible flow control issue
Previously we only update consumed flow control window when number of
bytes read in nghttp2 and spdylay callback is 0.  Now we notify
nghttp2 library the consumed bytes even if number of bytes read > 0.
This change also uses newly added spdylay_session_consume() API, so we
require spdylay >= 1.3.0.
2014-08-21 21:22:16 +09:00
Tatsuhiro Tsujikawa 69b9ce6b68 nghttpx: Fix possible deadlock due to exhaustion of send window 2014-08-20 01:39:07 +09:00
Tatsuhiro Tsujikawa a5dfe24e49 nghttpx: Use std::unique_ptr for DownstreamConnection 2014-08-19 00:20:57 +09:00
Tatsuhiro Tsujikawa 273d9f4f7d nghttpx: Use std::unique_ptr for Downstream object 2014-08-19 00:20:56 +09:00
Tatsuhiro Tsujikawa 500c5eea56 nghttpx: Rename Http2Upstream::add_downstream as add_pending_downstream 2014-08-18 21:38:03 +09:00
Tatsuhiro Tsujikawa 83a39f5b49 nghttpx: Fix stream handling of upgraded request 2014-08-18 21:36:55 +09:00
Tatsuhiro Tsujikawa 49a9ec2cb3 nghttpx: Use int for resonse_rst_stream_error_code_ 2014-08-17 16:36:02 +09:00
Tatsuhiro Tsujikawa 0e8419ac37 nghttpx: Add backend-connections-per-frontend option
This option limits the number of backend connections per frontend.
This is meaningful for the combination of HTTP/2 and SPDY frontend and
HTTP/1 backend.
2014-08-16 22:24:17 +09:00
Tatsuhiro Tsujikawa da08ba5d50 nghttpx: Reset upstream timer on upgrade 2014-08-15 10:29:46 +09:00
Tatsuhiro Tsujikawa 30fa6d24d0 nghttpx: Rewirte server header field if configured as reverse proxy 2014-08-14 22:45:21 +09:00
Tatsuhiro Tsujikawa 24cfb52b5a nghttpx: Add --no-location-rewrite option
--no-location-rewrite option disallows location header rewrite on
--http2-bridge, --client and default mode.  This option is useful when
connecting nghttpx proxy with --http2-bridge to backend nghttpx with
http2-proxy mode.
2014-08-10 12:39:27 +09:00
Tatsuhiro Tsujikawa 76703f79fa nghttpx: Add stream level timeout for HTTP/2 and SPDY upstream/downstream 2014-08-09 22:56:27 +09:00
Tatsuhiro Tsujikawa 88add854ff nghttpx: Treat malformed request as PROTOCOL_ERROR 2014-08-08 23:11:58 +09:00
Tatsuhiro Tsujikawa d4d56e1846 nghttpd, nghttpx: Check that pseudo headers come before normal headers 2014-08-08 20:52:32 +09:00
Tatsuhiro Tsujikawa d496c42dc9 Revert "nghttpx, nghttpd: Check pseudo header fields come before normal header fields"
This reverts commit cc24b9aaf0.
2014-08-08 20:17:03 +09:00
Tatsuhiro Tsujikawa cc24b9aaf0 nghttpx, nghttpd: Check pseudo header fields come before normal header fields 2014-08-07 22:49:34 +09:00
Tatsuhiro Tsujikawa 6e027ad830 nghttpd, nghttpx: Check allowed pseudo headers 2014-07-31 23:05:53 +09:00
Tatsuhiro Tsujikawa 9d78167297 nghttpx: Treat unexpected HEADERS as stream error 2014-07-31 23:05:53 +09:00
Tatsuhiro Tsujikawa 04b5d1679f nghttpx: Log non-final response headers 2014-07-31 23:05:53 +09:00
Tatsuhiro Tsujikawa c859fb8f7c nghttpx: Don't respond DATA frame for HEAD request or 204, 304, 1xx 2014-07-31 23:05:53 +09:00
Tatsuhiro Tsujikawa 079db14d45 Add nghttp2_session_consume() API
Reworked no automatic WINDOW_UPDATE feature.  We added new API
nghttp2_session_consume() which tells the library how many bytes are
consumed by the application.  Instead of submitting WINDOW_UPDATE by
the application, the library is now responsible to submit
WINDOW_UPDATE based on consumed bytes.  This is more reliable method,
since it enables us to properly send WINDOW_UPDATE for stream and
connection individually.  The previous implementation of nghttpx had
broken connection window management.
2014-07-31 23:05:53 +09:00
Tatsuhiro Tsujikawa 4f815521ae nghttpx, nghttpd: Support non-final response 2014-07-31 23:05:52 +09:00
Tatsuhiro Tsujikawa af5fd2019d src: Remove 0x00 concatenation for headers
Now concatenating header values with 0x00 as delimiter is not
necessary because HPACK reference set is removed and the order of
header field fed into HPACK encoder is preserved when they are
decoded.
2014-07-31 23:05:52 +09:00
Tatsuhiro Tsujikawa bb47484667 nghttpx: Log transmission and reception of GOAWAY 2014-07-12 23:30:13 +09:00
Tatsuhiro Tsujikawa a072d719b3 nghttpx: Use 431 instead of 413 2014-07-08 22:37:48 +09:00
Tatsuhiro Tsujikawa 0ce848a611 nghttpx: Rewrite logging system
This change rewrites logging system of nghttpx.  Previously access log
and error log are written to stderr or syslog and there was no option
to change stderr to something else.  With this change, file path of
access log and error log can be configured separately and logging to
regular file is now added.  To support rotating log, if SIGUSR1 signal
is received by nghttpx, it closes the current log files and reopen it
with the same name.  The format of access log is changed and has same
look of apache's.  But not all columns are not supported yet.
2014-07-05 18:43:24 +09:00
Tatsuhiro Tsujikawa 0f4d01c25c nghttpx: Pass through NGHTTP2_NO_ERROR from downstream to upstream 2014-07-03 23:00:19 +09:00
Tatsuhiro Tsujikawa f8b872096e nghttpx: Use NGHTTP2_NO_ERROR to close upgraded (tunneled) stream 2014-07-03 22:59:49 +09:00
Tatsuhiro Tsujikawa 4b6f124b7e Add API to check half-closed state for both direction of stream 2014-07-03 21:44:29 +09:00
Tatsuhiro Tsujikawa 1ce00f455c nghttpx: Remove requirement of content-length for HTTP2 upstream POST 2014-07-03 19:59:10 +09:00
Tatsuhiro Tsujikawa 9cddb05f54 nghttpx: Use error_reply instead of RST_STREAM for http2 upstream request 2014-07-03 00:12:16 +09:00
Tatsuhiro Tsujikawa 93b3a44fb5 nghttpx: Add ability to Http2Upstream to send RST_STREAM after END_STREAM 2014-07-02 23:56:26 +09:00
Tatsuhiro Tsujikawa 797edae4d4 nghttpx: Handle connection flow control for DATA not sent to backend 2014-07-02 23:24:58 +09:00
Tatsuhiro Tsujikawa 303f0f3fcd nghttpx: Return 413 if request header is too large
For now, if request has request body, we'll issue RST_STREAM to inform
the peer to stop sending body.  RST_STREAM may be sent before error
page header or data, so peer may receive RST_STREAM only.
2014-06-27 22:54:33 +09:00
Tatsuhiro Tsujikawa ca87b45fe4 nghttpx: Don't fail backend connection if one of backend request fails 2014-06-27 22:34:54 +09:00
Tatsuhiro Tsujikawa 94b9c3771d nghttpx: Throw away request and response headers when they are done 2014-06-15 17:25:24 +09:00
Tatsuhiro Tsujikawa 7e217511bf nghttpx: Code cleanup
Mainly make nested code block to rather flat style.
2014-06-01 23:44:32 +09:00
Tatsuhiro Tsujikawa 8c67bbe3a8 src: Avoid copy in evbuffer_pullup()
Previously, we use evbuffer_pullup(buf, -1) to linearize the memory
region and it may cause buffer copy.  To avoid this, we use the return
value of evbuffer_get_contiguous_space() as 2nd parameter.  According
to the libevent manual, by doing so evbuffer_pullup() will not copy or
modify any data in evbuffer.
2014-06-01 21:01:01 +09:00
Tatsuhiro Tsujikawa 7a797b2c11 nghttpx: Reduce socket I/O buffer size 2014-05-29 22:24:15 +09:00
Tatsuhiro Tsujikawa 86ab9f33de nghttpx: Fix regression bug that frame with stream_id = 0 not handled 2014-05-28 00:26:27 +09:00
Tatsuhiro Tsujikawa ebf0e4d787 nghttpd, nghttpx: Check END_STREAM flag in HEADERS other than request 2014-05-24 15:02:46 +09:00
Tatsuhiro Tsujikawa 3f80472e0a nghttpx: Minor tweak to buffer size
Simplified when to send WINDOW_UPDATE to the backend, that is we send
WINDOW_UPDATE when input buffer is empty.
2014-05-16 21:42:30 +09:00
Tatsuhiro Tsujikawa a8a2236da9 nghttpx: Add --add-response-header option 2014-04-26 14:56:08 +09:00
Tatsuhiro Tsujikawa f9f6cdc93d nghttpx: Specify altsvc info in one option and allow multiple occurrences 2014-04-08 22:28:50 +09:00
Tatsuhiro Tsujikawa 0a527f16f5 nghttpx: Log when connection was upgraded to HTTP/2 2014-04-05 18:59:22 +09:00
Tatsuhiro Tsujikawa e7ad3633c7 nghttp2_data_source_read_callback: Replace eof with uint32_t *data_flags
Replace int *eof with uint32_t *data_flags so that we can easily
extend functionality if we have to (but we don't do if possible).
2014-04-05 17:59:24 +09:00
Tatsuhiro Tsujikawa d668d2448b Hide session option from public API
To make adding new option easier, we decided to make the details of
option struct private and hide it from public API.  We provide
functions to set individual option value.
2014-04-04 21:57:47 +09:00
Tatsuhiro Tsujikawa 22c88af1ab nghttpx: Resume deferred DATA after complete DATA frame arrived on backend
If SPDY or HTTP/2 ustream is used and HTTP/2 downstream is used, only
call {spdylay,nghttp2}_resume_data when complete DATA frame was read
in backend to avoid to transmit too small DATA frame to the upstream.
2014-04-03 18:54:15 +09:00
Tatsuhiro Tsujikawa db6c41a219 nghttpx: Add altsvc related options
To advertise alternative serive, at least --altsvc-port and
--altsvc-protocol-id must be specified.
2014-04-03 13:20:50 +09:00
Tatsuhiro Tsujikawa b1edb1f3ae Don't index name/value pair bearing NO_INDEX flag when forwarding it 2014-04-03 11:22:11 +09:00
Tatsuhiro Tsujikawa c9f90924a9 Add flags parameter to nghttp2_on_header_callback 2014-04-02 02:10:35 +09:00
Tatsuhiro Tsujikawa ab2dc5967d Replace HTTP/2.0 with HTTP/2 2014-03-30 19:26:37 +09:00
Tatsuhiro Tsujikawa f7162ab702 Implement dependency based priority 2014-03-30 01:24:16 +09:00
Tatsuhiro Tsujikawa 334656b704 nghttpx: Announce 2.0 in via header field 2014-03-21 19:25:46 +09:00
Tatsuhiro Tsujikawa a7eb6502a9 src: Use large transmission buffer to reduce SSL/TLS overhead 2014-03-15 16:10:42 +09:00
Tatsuhiro Tsujikawa 27e161dc31 src: Add EvbufferBuffer class to simplify the code base 2014-03-05 00:23:33 +09:00
Tatsuhiro Tsujikawa e34b8ac7fb src: Avoid to call costly evbuffer_add() repeatedly
The profiler and benchmarking showed that calling evbuffer_add()
repeatedly is very costly. To avoid this, we buffer up small writes
into one large chunk and call evbuffer_add() less times.
2014-03-03 23:45:57 +09:00
Tatsuhiro Tsujikawa 649586fff6 Add nghttp2_session_mem_send() API function
This function behaves like nghttp2_session_send(), but it does not
use nghttp2_send_callback to send data. Instead, it returns the
serialized data to trasmit and its length to the caller.
2014-02-18 23:23:11 +09:00
Tatsuhiro Tsujikawa 1fd5fdd54a src: Remove redundant SETTINGS_ENABLE_PUSH from server side 2014-02-16 16:05:26 +09:00
Tatsuhiro Tsujikawa c280cc7c4d nghttpx: Add --padding option for debugging purpose 2014-02-11 17:23:22 +09:00
Tatsuhiro Tsujikawa c7c283f3a9 nghttpx: Add --frontend-frame-debug option to debug HTTP/2 frame in upstream
The output format is the same one with nghttp/nghttpd. The output
is made into stderr to make it sync with logging.
2014-02-09 18:47:26 +09:00
Tatsuhiro Tsujikawa e186e01933 Replace on_end_headers_callback with on_begin_headers_callback
Previously, there is inconsistency when on_frame_recv_callback
is called between HEADERS/PUSH_PROMISE and the other frames.
For former case, it is called before header block, in latter
case, it is called after whole frame is received. To make it
consistent, we call on_frame_recv_callback for HEADERS/PUSH_PROMISE
after its frame is fully received. Since on_frame_recv_callback
can signal the end of header block, we replaced on_end_headers_callback
with on_begin_headers_callback, which is called when the reception
of the header block is started.
2014-01-29 21:23:13 +09:00
Tatsuhiro Tsujikawa 864789ca65 nghttpx: Limit the maximum header block size (again) 2014-01-28 01:17:54 +09:00
Tatsuhiro Tsujikawa a3082b7c1e Remove nghttp2_on_data_recv_callback and nghttp2_on_data_send_callback
nghttp2_data is added to nghttp2_frame union. When DATA is
received, nghttp2_on_frame_recv_callback is called. When DATA is
sent, nghttp2_on_frame_send_callback is called.
2014-01-27 22:16:05 +09:00
Tatsuhiro Tsujikawa fbffd2c923 nghttpx: Limit the number of receiving headers 2014-01-27 00:45:36 +09:00
Tatsuhiro Tsujikawa 545f24bc1b Remove nghttp2_on_frame_recv_parse_error_callback 2014-01-26 23:23:07 +09:00
Tatsuhiro Tsujikawa dfbea797bd src: Use static_cast instead of reinterpret_cast if possible 2014-01-19 21:18:37 +09:00
Tatsuhiro Tsujikawa a37bc88f40 nghttpx: Rename ClientHandler::get_pending_write_length to get_outbuf_length
And other renames.
2014-01-19 17:49:04 +09:00
Tatsuhiro Tsujikawa bacea078da nghttpx: Take into account both frontend buffer and body buffer length 2014-01-19 17:42:31 +09:00
Tatsuhiro Tsujikawa f59a9c5c58 nghttpx: Disable TLS renegotiation properly
4ed4efc does not disable TLS renegotiation at all, if client keeps
rengotiations without sending application data. In this change,
we intercept the raw incoming data from the client and if it is a
renegotiation, drop the connection immediately.
2014-01-19 17:25:18 +09:00
Tatsuhiro Tsujikawa 6f5e1662c6 nghttpx: Handle error from Downstream::resume_read() 2014-01-19 14:42:42 +09:00
Tatsuhiro Tsujikawa becc206ba9 nghttpx: Don't show warning WINDOW_UPDATE failure for HTTP/1 downstream 2014-01-19 00:38:11 +09:00
Tatsuhiro Tsujikawa 8f3d4fdeec nghttpx: Remove deprecated evbuffer_setcb, send WU before buffer gets empty 2014-01-18 18:39:25 +09:00
Tatsuhiro Tsujikawa 0872ce27f4 nghttpx: Use nghttp2_session_mem_recv instead of nghttp2_session_recv 2014-01-18 16:50:52 +09:00
Tatsuhiro Tsujikawa 59ff0b2f77 nghttpx: Propagate upstream priority change to downstream 2014-01-18 16:12:03 +09:00
Tatsuhiro Tsujikawa 707a0b4103 Move name/value validation functions to src
nghttp2 library itself now accept octet header/value pairs,
completely not restricted by HTTP/1 header name/value rule.
The applications may impose restriction about them using
validators.
2014-01-17 02:16:53 +09:00
Tatsuhiro Tsujikawa 0e4b3d435e Emit header name/value pair using callback functions
Now, in nghttp2_on_frame_recv_callback, nva and nvlen in
HEADERS and PUSH_PROMISE frames are always NULL and 0 respectively.
The header name/value pairs are emitted successive
nghttp2_on_header_callback functions. The end of header fields are
signaled with nghttp2_on_end_headers_callback function.

Since NGHTTP2_ERR_PAUSE for nghttp2_on_frame_recv_callback is
introduced to handle header block, it is now deprecated.
Instead, nghttp2_on_header_callback can be paused using
NGHTTP2_ERR_PAUSE.
2014-01-17 01:49:43 +09:00
Tatsuhiro Tsujikawa 88d31ada75 src: Handle PUSH_PROMISE from client and request HEADERS from server
They are just RST_STREAMed for now
2014-01-09 23:47:21 +09:00
Tatsuhiro Tsujikawa 1c43cdbbc8 nghttpx: Don't rewrite location if proxy mode is used 2013-12-28 17:02:43 +09:00
Tatsuhiro Tsujikawa 9cb8754d09 Rename nghttp2_session_fail_session as nghttp2_session_terminate_session 2013-12-26 00:23:07 +09:00
Tatsuhiro Tsujikawa e955598923 nghttpx: Remove downstream_port from location rewrite code 2013-12-21 18:35:53 +09:00
Tatsuhiro Tsujikawa ccfa13cd5b nghttpx: Rewrite location header field
We thought that this kind of rewrite can be achieved by the configuration
of the backend severs, but in some configuration, however, it may get
complicated. So we decided to implement at least location rewrite in
nghttpx.

This commit also contains a fix to the bug which prevents the http2
backend request from concatenating header fields with the same value.
2013-12-21 17:49:31 +09:00
Tatsuhiro Tsujikawa b38b233aa6 nghttpx: Check failure of evbuffer_* and bufferevent_* functions 2013-12-20 23:28:54 +09:00
Tatsuhiro Tsujikawa 658b7d0727 src: Replace MAKE_NV macros with function templates 2013-12-08 22:31:43 +09:00
Tatsuhiro Tsujikawa 6c77cec270 Remove nghttp2_submit_* API functions which has char **nv parameter
The nghttp2_submit_{request,response}2 functions are renamed as
nghttp2_submit_{request, response}.
2013-12-08 21:39:43 +09:00
Tatsuhiro Tsujikawa baa2272b0a src: Concatenate header fields with same name by NULL as delimiter
cookie and set-cookie are treated specially and won't be concatenated.
2013-12-07 00:32:14 +09:00
Tatsuhiro Tsujikawa e596385fc0 src: Split NULL-separated values 2013-12-05 21:54:36 +09:00
Tatsuhiro Tsujikawa d1049f389f nghttpx: Use nghttp2_submit_{request, response}2 API 2013-11-28 21:36:04 +09:00
Tatsuhiro Tsujikawa 01f7162be3 nghttpx: Add connection-level flow control window size options
This commit also changes SPDY's flow control size. Previously,
the size for SPDY is the same amount of bytes with HTTP/2.
For example, --frontend-http2-upstream-window-bits=N,
the window size is 2**N - 1. Now SPDY code uses 2**N.
2013-11-21 00:15:17 +09:00
Tatsuhiro Tsujikawa faedc4381d nghttpx: Add options to dump HTTP headers in HTTP/2.0 upstream 2013-11-17 23:52:19 +09:00
Tatsuhiro Tsujikawa 40347487c9 Don't sort headers in library code
Remove sorting headers from library code. The application must sort
them if necessary. nghttpx and nghttpd do the sorting of the headers
in stable way if names are equal.
2013-11-13 23:56:02 +09:00
Tatsuhiro Tsujikawa 0ba2883940 nghttpx: Use initial window size in config directly 2013-11-12 11:08:43 +09:00
Tatsuhiro Tsujikawa 2ae788eddd Replace nghttp2_set_option with nghttp2_session_{client,server}_new2
nghttp2_session_client_new2 and nghttp2_session_server_new2 take
additional parameters which specifies session options.
nghttp2_set_option is somewhat crumsy because of type checking.
Now we use nghttp2_opt_set, which specifies individual options with
types. We changed the value of nghttp2_opt, so this change will
require re-compile.
2013-11-08 00:12:39 +09:00
Tatsuhiro Tsujikawa b1905c5815 nghttpx: More replacement of spdy with http2 2013-11-04 18:22:29 +09:00
Tatsuhiro Tsujikawa ba3db66cec nghttpx: Replace "spdy" in option name with "http2" 2013-11-04 18:14:05 +09:00
Tatsuhiro Tsujikawa f3d71aa5bb nghttpx: Rename Spdy{Session,DownstreamConnection} to Http2{*} 2013-11-04 17:53:57 +09:00
Tatsuhiro Tsujikawa e0fe939951 nghttpx: Add SETTINGS timeout timer to Http2Upstream 2013-10-31 00:44:23 +09:00
Tatsuhiro Tsujikawa dfa1194804 Add new API to return effective recv data/win size for connection
Using this feature, connection level flow control is now enabled
in nghttpx.
2013-10-30 00:51:01 +09:00
Tatsuhiro Tsujikawa b75455dd96 nghttpx: Remove recv data length calculation in HTTP/2 code 2013-10-30 00:10:28 +09:00
Tatsuhiro Tsujikawa 6c23c34d77 Add new API to return effective received data length and local window size 2013-10-30 00:07:35 +09:00
Tatsuhiro Tsujikawa 9b6a0e5875 nghttpx: Fix stream hang with request body
The end of request stream is not detected correct place.
Also Downstream::end_upload_data() is not called.
2013-10-30 00:00:58 +09:00
Tatsuhiro Tsujikawa 0ced4741d2 nghttpx: Remove flow control error detection code
Now flow control error detection is handled by the library
2013-10-29 22:46:38 +09:00
Tatsuhiro Tsujikawa 5ca8f147f2 nghttpx: Code cleanup 2013-10-27 16:25:50 +09:00
Tatsuhiro Tsujikawa 67553d47e0 nghttpx: Use :authority and host instead of :host 2013-10-27 16:25:50 +09:00
Tatsuhiro Tsujikawa 896db5b24f API change: Add flags parameter to all submit_* functions
The nghttp2_submit_{request,response} family do not get this change.
2013-10-25 22:50:24 +09:00
Tatsuhiro Tsujikawa 8c855c5567 src: Use std::vector to store name/value pairs 2013-10-23 23:18:24 +09:00
Tatsuhiro Tsujikawa a9ba00914e nghttpx: Log error_code when submitting RST_STREAM 2013-09-30 00:13:04 +09:00
Tatsuhiro Tsujikawa 55b8a0b777 shrpx_http2_upstream: Use std::unique_ptr for pre_upstream_ 2013-09-26 21:46:35 +09:00
Tatsuhiro Tsujikawa 825c1bac6b shrpx_downstream.cc: Utilize std::move 2013-09-24 23:53:55 +09:00
Tatsuhiro Tsujikawa cbef6fd0c6 nghttpx: Replace \r\n with space when constructing HTTP/1 headers 2013-09-11 23:24:32 +09:00
Tatsuhiro Tsujikawa 1a05caf847 src: Use util::utos instead of std::to_string
Some platform (e.g., freebsd) does not define _GLIBCXX_USE_C99
and it hides std::to_string functions.
2013-09-08 14:29:18 +09:00
Tatsuhiro Tsujikawa 776cff3dc7 src: Use std::unique_ptr for nv 2013-09-07 01:52:46 +09:00
Tatsuhiro Tsujikawa d960cf8953 Add const to read-only nghttp2_frame* parameter in callbacks 2013-09-03 21:24:14 +09:00
Tatsuhiro Tsujikawa 2f26b04730 nghttpx: Code cleanup 2013-09-01 00:23:07 +09:00
Tatsuhiro Tsujikawa 59286adc5e Add int return value to nghttp2_on_unknown_frame_recv_callback 2013-08-29 23:10:18 +09:00
Tatsuhiro Tsujikawa db4f519500 Add int return value to nghttp2_on_frame_recv_parse_error_callback 2013-08-29 23:07:07 +09:00
Tatsuhiro Tsujikawa 81653c1d1b Add int return value to nghttp2_on_stream_close_callback 2013-08-29 22:58:05 +09:00
Tatsuhiro Tsujikawa b9d2f9b6b0 Add int return value to on_frame_not_send_callback 2013-08-29 21:51:58 +09:00
Tatsuhiro Tsujikawa 972b47d6af Add int return value to nghttp2_on_data_chunk_recv_callback 2013-08-29 21:39:32 +09:00
Tatsuhiro Tsujikawa a59cd3be82 Add int return value to nghttp2_on_frame_recv_callback 2013-08-29 21:33:52 +09:00
Tatsuhiro Tsujikawa 3544bfdbef src: Move pure HTTP code from shrpx_http.cc to http2.cc 2013-08-28 02:47:22 +09:00
Tatsuhiro Tsujikawa 1f3b96e233 nghttpx: Rewrite header handling 2013-08-28 00:09:46 +09:00
Tatsuhiro Tsujikawa 89cd2ff479 nghttpx: Stream error if disallowed header field in HTTP2 is received 2013-08-26 01:25:31 +09:00
Tatsuhiro Tsujikawa 33743ab832 nghttpx: Remove banned header fields in HTTP2 request and response 2013-08-26 01:09:15 +09:00
Tatsuhiro Tsujikawa 4fb1811d18 nghttpx: Include status code only in :status header field in HTTP2 response 2013-08-25 23:28:34 +09:00
Tatsuhiro Tsujikawa 5d7b7a1691 nghttpx: Stream error if mandatory HTTP/2 request header field is missing 2013-08-25 23:21:07 +09:00
Tatsuhiro Tsujikawa b2a34c2e5b nghttpx: Fix bug content-length is removed 2013-08-23 02:49:21 +09:00
Tatsuhiro Tsujikawa 358d12a842 nghttpx: Fix bug CONNECT does not work 2013-08-22 21:28:27 +09:00
Tatsuhiro Tsujikawa b8a01f5212 nghttpx: Require content-length in HTTP2 upstream if END_STREAM flag is not set 2013-08-21 01:19:16 +09:00
Tatsuhiro Tsujikawa aa9688b459 nghttpx: Fix possible multiple replies on HTTP2 and SPDY upstreams 2013-08-21 00:56:08 +09:00
Tatsuhiro Tsujikawa 4fac4eb92d nghttpx: HttpUpstream: Check required request headers strictly
If multiple required headers (e.g., :path) found, return HTTP 400
error.
Fix util::strieq(a,b,n) where boundary of b is not checked in the
loop.
2013-08-11 00:08:44 +09:00
Tatsuhiro Tsujikawa 19377fb3cd Allow disabling auto WINDOW_UPDATE for connection and stream individually
Now NGHTTP2_OPT_NO_AUTO_WINDOW_UPDATE is split into 2 options:
NGHTTP2_OPT_NO_AUTO_STREAM_WINDOW_UPDATE and
NGHTTP2_OPT_NO_AUTO_CONNECTION_WINDOW_UPDATE.
This is preparation for the upcoming removal of END_FLOW_CONTROL
flag. For nghttpx, instead of using END_FLOW_CONTROL to disable
connection-level flow control, increase window size by large
enough value, which is friendly way to current chromium
implementation.
2013-08-09 01:23:39 +09:00
Tatsuhiro Tsujikawa fafec1fdb8 nghttpx: Accept incoming bytes at least initial window size 2013-08-07 21:27:08 +09:00
Tatsuhiro Tsujikawa f613f68a13 src: Make window size - 1
To match the -w16 to 65535, which is HTTP/2.0 default initial window
size, decrement 1 from (1 << window_bits).
2013-08-03 19:53:07 +09:00
Tatsuhiro Tsujikawa f620655d08 nghttp, nghttpx: Add HTTP Upgrade from HTTP/1.1 to HTTP/2.0
nghttpx does not perform upgrade if the request has request body.
2013-08-03 18:51:01 +09:00
Tatsuhiro Tsujikawa 1bbcbd365c shrpx: Cast uint8_t to uint32_t to print its decimal number 2013-08-01 20:33:04 +09:00
Tatsuhiro Tsujikawa fec566aa23 src: Send out data in output buffer before HTTP2/SPDY session tear down 2013-08-01 20:31:29 +09:00
Tatsuhiro Tsujikawa 924b1bd61a Use unmodified http-parser
Handle HTTP Upgrade and CONNECT explicitly
2013-07-31 21:48:37 +09:00
Tatsuhiro Tsujikawa 1fca42ed2b nghttpx: Remove :version from http2 connection 2013-07-26 21:47:53 +09:00
Tatsuhiro Tsujikawa 41b21f7938 fixup 2013-07-26 19:38:54 +09:00