aboutsummaryrefslogtreecommitdiff
path: root/lib/http2.c
AgeCommit message (Collapse)Author
2015-05-25http2: Copy data passed in Curl_http2_switched into HTTP/2 connection bufferTatsuhiro Tsujikawa
Previously, after seeing upgrade to HTTP/2, we feed data followed by upgrade response headers directly to nghttp2_session_mem_recv() in Curl_http2_switched(). But it turns out that passed buffer, mem, is part of stream->mem, and callbacks called by nghttp2_session_mem_recv() will write stream specific data into stream->mem, overwriting input data. This will corrupt input, and most likely frame length error is detected by nghttp2 library. The fix is first copy the passed data to HTTP/2 connection buffer, httpc->inbuf, and call nghttp2_session_mem_recv().
2015-05-22http2: on_frame_recv: return early on stream 0Daniel Stenberg
Coverity CID 1299426 warned about possible NULL dereference otherwise, but that would only ever happen if we get invalid HTTP/2 data with frames for stream 0. Avoid this risk by returning early when stream 0 is used.
2015-05-22http2: Make HTTP Upgrade workTatsuhiro Tsujikawa
This commit just add implicitly opened stream 1 to streams hash.
2015-05-20http2: show stream IDs in decimalDaniel Stenberg
It makes them easier to match output from the nghttpd test server.
2015-05-20http2: Faster http2 uploadTatsuhiro Tsujikawa
Previously, when we send all given buffer in data_source_callback, we return NGHTTP2_ERR_DEFERRED, and nghttp2 library removes this stream temporarily for writing. This itself is good. If this is the sole stream in the session, nghttp2_session_want_write() returns zero, which means that libcurl does not check writeability of the underlying socket. This leads to very slow upload, because it seems curl only upload 16k something per 1 second. To fix this, if we still have data to send, call nghttp2_session_resume_data after nghttp2_session_send. This makes nghttp2_session_want_write() returns nonzero (if connection window still opens), and as a result, socket writeability is checked, and upload speed becomes normal.
2015-05-18http2: store upload state per streamDaniel Stenberg
Use a curl_off_t for upload left
2015-05-18http2: fix build when NOT h2-enabledDaniel Stenberg
2015-05-18http2: switch to use Curl_hash_destroy()Daniel Stenberg
as after 4883f7019d3, the *_clean() function only flushes the hash.
2015-05-18http2: Ignore if we have stream ID not in hash in on_stream_closeTatsuhiro Tsujikawa
We could get stream ID not in the hash in on_stream_close. For example, if we decided to reject stream (e.g., PUSH_PROMISE), then we don't create stream and store it in hash with its stream ID.
2015-05-18Require nghttp2 v1.0.0Tatsuhiro Tsujikawa
This commit requires nghttp2 v1.0.0 to compile, and migrate to v1.0.0, and utilize recent version of nghttp2 to simplify the code, First we use nghttp2_option_set_no_recv_client_magic function to detect nghttp2 v1.0.0. That function only exists since v1.0.0. Since nghttp2 v0.7.5, nghttp2 ensures header field ordering, and validates received header field. If it found error, RST_STREAM with PROTOCOL_ERROR is issued. Since we require v1.0.0, we can utilize this feature to simplify libcurl code. This commit does this. Migration from 0.7 series are done based on nghttp2 migration document. For libcurl, we removed the code sending first 24 bytes client magic. It is now done by nghttp2 library. on_invalid_frame_recv callback signature changed, and is updated accordingly.
2015-05-18http2: infof length in on_frame_send()Daniel Stenberg
2015-05-18http2: bump the h2 buffer size to 32K for speedDaniel Stenberg
2015-05-18http2: remove the stream from the hash in stream_close callbackDaniel Stenberg
... and suddenly things work much better!
2015-05-18http2: if there is paused data, do not clear the drain fieldDaniel Stenberg
2015-05-18http2: rename s/data/pausedataDaniel Stenberg
2015-05-18http2: "stream %x" in all outputs to make it easier to search forDaniel Stenberg
2015-05-18http2: Curl_expire() all handles with incoming trafficDaniel Stenberg
... so that they'll get handled next in the multi loop.
2015-05-18http2: don't signal settings change for same valuesDaniel Stenberg
2015-05-18http2: set default concurrency, fix ConnectionExists for multiplexDaniel Stenberg
2015-05-18bundles: store no/default/pipeline/multiplexDaniel Stenberg
to allow code to act differently on the situation. Also added some more info message for the connection re-use function to make it clearer when connections are not re-used.
2015-05-18http2: lazy init header_recvbufDaniel Stenberg
It makes us use less memory when not doing HTTP/2 and subsequently also makes us not have to cleanup HTTP/2 related data when not using HTTP/2!
2015-05-18http2: separate multiplex/pipelining + cleanup memory leaksDaniel Stenberg
2015-05-18http2: Fix bug that data to be drained are overwritten by pending "paused" dataTatsuhiro Tsujikawa
2015-05-18http2: Don't call nghttp2_session_mem_recv while it is paused by a streamTatsuhiro Tsujikawa
2015-05-18http2: Read data left in connection buffer after pauseTatsuhiro Tsujikawa
Previously when we do pause because of out of buffer, we just throw away unread data in connection buffer. This just broke protocol framing, and I saw occasional FRAME_SIZE_ERROR. This commit fix this issue by remembering how much data read, and in the next iteration, we process remaining data.
2015-05-18http2: Fix streams get stuckTatsuhiro Tsujikawa
This commit fixes the bug that streams get stuck if stream gets some DATA, and stream->closed becomes true at the same time. Previously, in this condition, after we processed DATA, we are going to try to read data from underlying transport, but there is no data, and gets EAGAIN. There was no code path to evaludate stream->closed.
2015-05-18http2: store incoming h2 SETTINGSDaniel Stenberg
2015-05-18http2: remove debug logging from on_frame_recvDaniel Stenberg
2015-05-18http2: remove the closed check in http2_recvDaniel Stenberg
With the "drained" functionality we can get here slightly asynchronously so the stream have have been closed but there is pending data left to read.
2015-05-18http2: bump the h2 buffer to 8KDaniel Stenberg
2015-05-18http2: more debug outputsDaniel Stenberg
2015-05-18http2: leave WAITPERFORM when conn is multiplexedDaniel Stenberg
No need to wait for our "spot" like for pipelining
2015-05-18http2: force "drainage" of streamsDaniel Stenberg
... which is necessary since the socket won't be readable but there is data waiting in the buffer.
2015-05-18http2: move the mem+len pair to the stream structDaniel Stenberg
2015-05-18http2: more stream-oriented data, stream ID 0 is for connectionsDaniel Stenberg
2015-05-18http2: move lots of state data to the 'stream' structDaniel Stenberg
... from the connection struct. The stream one being the 'struct HTTP' which is kept in the SessionHandle struct (easy handle). lookup streams for incoming frames in the stream hash, hashing is based on the stream id and we get the SessionHandle for the incoming stream that way.
2015-05-18HTTP: partial start at fixing up hash-lookups on http2 frame receivalDaniel Stenberg
2015-05-18http: a stream hash for h2 multiplexingDaniel Stenberg
2015-05-18http: a stream hash for h2 multiplexingDaniel Stenberg
2015-05-18http2: debug log when receiving unexpected stream_idDaniel Stenberg
2015-05-18http2: move stream_id to the HTTP struct (per-stream)Daniel Stenberg
2015-05-18Curl_http2_setup: only do it once and enable multiplex on the serverDaniel Stenberg
Once we know we are HTTP/2 enabled we know the server can multiplex.
2015-04-27http2: unify http_conn variable names to 'c'Daniel Stenberg
2015-04-02http2: Fix missing nghttp2_session_send call in Curl_http2_switchedTatsuhiro Tsujikawa
Previously in Curl_http2_switched, we called nghttp2_session_mem_recv to parse incoming data which were already received while curl was handling upgrade. But we didn't call nghttp2_session_send, and it led to make curl not send any response to the received frames. Most likely, we received SETTINGS from server at this point, so we missed opportunity to send SETTINGS + ACK. This commit adds missing nghttp2_session_send call in Curl_http2_switched to fix this issue. Bug: https://github.com/bagder/curl/issues/192 Reported-by: Stefan Eissing
2015-03-24curl_memory: make curl_memory.h the second-last header file loadedDan Fandrich
This header file must be included after all header files except memdebug.h, as it does similar memory function redefinitions and can be similarly affected by conflicting definitions in system or dependent library headers.
2015-03-23http2: move the init too for when its actually neededDaniel Stenberg
... it would otherwise lead to memory leakage if we never actually do the switch.
2015-03-19HTTP: don't switch to HTTP/2 from 1.1 until we get the 101Daniel Stenberg
We prematurely changed protocol handler to HTTP/2 which made things very slow (and wrong). Reported-by: Stefan Eissing Bug: https://github.com/bagder/curl/issues/169
2015-03-16free: instead of Curl_safefree()Daniel Stenberg
Since we just started make use of free(NULL) in order to simplify code, this change takes it a step further and: - converts lots of Curl_safefree() calls to good old free() - makes Curl_safefree() not check the pointer before free() The (new) rule of thumb is: if you really want a function call that frees a pointer and then assigns it to NULL, then use Curl_safefree(). But we will prefer just using free() from now on.
2015-03-14http2: detect prematures close without data transferedDaniel Stenberg
... by using the regular Curl_http_done() method which checks for that. This makes test 1801 fail consistently with error 56 (which seems fine) to that test is also updated here. Reported-by: Ben Darnell Bug: https://github.com/bagder/curl/issues/166
2015-03-07http2: make the info-message about receiving HTTP2 headers debug-onlyDaniel Stenberg