summaryrefslogtreecommitdiff
path: root/lib/http2.c
Commit message (Collapse)AuthorAgeFilesLines
* Curl_http2_setup: don't change connection data on repeat invokesDaniel Stenberg2021-09-161-6/+6
| | | | | | | | | | Regression from 3cb8a748670ab88c (releasde in 7.79.0). That change moved transfer oriented inits to before the check but also erroneously moved a few connection oriented ones, which causes problems. Reported-by: Evangelos Foutras Fixes #7730 Closes #7731
* http2: Curl_http2_setup needs to init stream data in all invokesDaniel Stenberg2021-09-111-12/+17
| | | | | | | | | | | | Thus function was written to avoid doing multiple connection data initializations, which is fine, but since it also initiates stream related data it is crucial that it doesn't skip those even if called again for the same connection. Solved by moving the stream initializations before the "doing-it-again" check. Reported-by: Inho Oh Fixes #7630 Closes #7692
* Revert "http2: skip immediate parsing of payload following protocol switch"Daniel Stenberg2021-08-301-9/+2
| | | | | | | | This reverts commit 455a63c66f188598275e87d32de2c4e8e26b80cb. Reported-by: Tk Xiong Fixes #7633 Closes #7648
* http2: revert call the handle-closed function correctly on closed streamArtur Sinila2021-08-161-4/+0
| | | | | | | | Reverts 252790c5335a221 Assisted-by: Gergely Nagy Fixes #7400 Closes #7525
* infof: remove newline from format strings, always append itDaniel Stenberg2021-07-071-69/+69
| | | | | | | | | | | | | | | | - the data needs to be "line-based" anyway since it's also passed to the debug callback/application - it makes infof() work like failf() and consistency is good - there's an assert that triggers on newlines in the format string - Also removes a few instances of "..." - Removes the code that would append "..." to the end of the data *iff* it was truncated in infof() Closes #7357
* version: turn version number functions into returning voidDaniel Stenberg2021-06-301-4/+3
| | | | | | | ... as we never use the return codes from them. Reviewed-by: Daniel Gustafsson Closes #7319
* http2: Clarify 'Using HTTP2' verbose messageJay Satiro2021-06-151-1/+1
| | | | | | | | | | | | | | - Change phrasing from multi-use to multiplexing since the former may not be as well understood. Before: * Using HTTP2, server supports multi-use After: * Using HTTP2, server supports multiplexing Bug: https://github.com/curl/curl/discussions/7255 Reported-by: David Hu Closes https://github.com/curl/curl/pull/7258
* http2_connisdead: handle trailing GOAWAY betterShikha Sharma2021-06-051-1/+3
| | | | | | | | When checking the connection the input processing returns error immediately, we now consider that a dead connnection. Bug: https://curl.se/mail/lib-2021-06/0001.html Closes #7192
* http2: init recvbuf struct for pushed streamsDaniel Stenberg2021-05-311-0/+2
| | | | | | | | Debug builds would warn that these structs were not initialized properly for pushed streams. Ref: #7148 Closes #7153
* conn: add 'attach' to protocol handler, make libssh2 use itDaniel Stenberg2021-05-171-0/+2
| | | | | | | | | | | The libssh2 backend has SSH session associated with the connection but the callback context is the easy handle, so when a connection gets attached to a transfer, the protocol handler now allows for a custom function to get used to set things up correctly. Reported-by: Michael O'Farrell Fixes #6898 Closes #7078
* http2: make sure pause is done on HTTPDaniel Stenberg2021-05-171-1/+2
| | | | | | | | | Since the function is called for any protocol, we can't assume that the HTTP struct is there without first making sure it is HTTP. Reported-by: Denis Goleshchikhin Fixes #7079 Closes #7080
* http2: skip immediate parsing of payload following protocol switchPeng-Yu Chen2021-05-111-2/+9
| | | | | | | | | | | | | This is considered not harmful as a following http2_recv shall be called very soon. This is considered helpful in the specific situation where some servers (e.g. nghttpx v1.43.0) may fulfill stream 1 immediately following the return of HTTP status 101, other than waiting for the client-side connection preface to arrive. Fixes #7036 Closes #7040
* http2: use nghttp2_session_upgrade2 instead of nghttp2_session_upgradePeng-Yu Chen2021-05-111-3/+3
| | | | | | | | Following the upstream deprecation of nghttp2_session_upgrade. Also provides further checks for requests with the HEAD method. Closes #7041
* http2: fix potentially uninitialized variableJay Satiro2021-05-051-1/+1
| | | | introduced several days ago in 3193170. caught by visual studio linker.
* http2: fix a resource leak in push_promise()Kamil Dudka2021-05-011-0/+1
| | | | | | | | | | | | ... detected by Coverity: Error: RESOURCE_LEAK (CWE-772): lib/http2.c:532: alloc_fn: Storage is returned from allocation function "duphandle". lib/http2.c:532: var_assign: Assigning: "newhandle" = storage returned from "duphandle(data)". lib/http2.c:552: noescape: Resource "newhandle" is not freed or pointed-to in "set_transfer_url". lib/http2.c:555: leaked_storage: Variable "newhandle" going out of scope leaks the storage it points to. Closes #6986
* http2: fix resource leaks in set_transfer_url()Kamil Dudka2021-05-011-7/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ... detected by Coverity: Error: RESOURCE_LEAK (CWE-772): lib/http2.c:480: alloc_fn: Storage is returned from allocation function "curl_url". [Note: The source code implementation of the function has been overridden by a builtin model.] lib/http2.c:480: var_assign: Assigning: "u" = storage returned from "curl_url()". lib/http2.c:486: noescape: Resource "u" is not freed or pointed-to in "curl_url_set". [Note: The source code implementation of the function has been overridden by a builtin model.] lib/http2.c:488: leaked_storage: Variable "u" going out of scope leaks the storage it points to. Error: RESOURCE_LEAK (CWE-772): lib/http2.c:480: alloc_fn: Storage is returned from allocation function "curl_url". [Note: The source code implementation of the function has been overridden by a builtin model.] lib/http2.c:480: var_assign: Assigning: "u" = storage returned from "curl_url()". lib/http2.c:493: noescape: Resource "u" is not freed or pointed-to in "curl_url_set". [Note: The source code implementation of the function has been overridden by a builtin model.] lib/http2.c:495: leaked_storage: Variable "u" going out of scope leaks the storage it points to. Error: RESOURCE_LEAK (CWE-772): lib/http2.c:480: alloc_fn: Storage is returned from allocation function "curl_url". [Note: The source code implementation of the function has been overridden by a builtin model.] lib/http2.c:480: var_assign: Assigning: "u" = storage returned from "curl_url()". lib/http2.c:500: noescape: Resource "u" is not freed or pointed-to in "curl_url_set". [Note: The source code implementation of the function has been overridden by a builtin model.] lib/http2.c:502: leaked_storage: Variable "u" going out of scope leaks the storage it points to. Error: RESOURCE_LEAK (CWE-772): lib/http2.c:480: alloc_fn: Storage is returned from allocation function "curl_url". [Note: The source code implementation of the function has been overridden by a builtin model.] lib/http2.c:480: var_assign: Assigning: "u" = storage returned from "curl_url()". lib/http2.c:505: noescape: Resource "u" is not freed or pointed-to in "curl_url_get". [Note: The source code implementation of the function has been overridden by a builtin model.] lib/http2.c:507: leaked_storage: Variable "u" going out of scope leaks the storage it points to. Closes #6986
* tidy-up: make conditional checks more consistentDaniel Stenberg2021-04-221-9/+9
| | | | | | ... remove '== NULL' and '!= 0' Closes #6912
* http2: remove DEBUG_HTTP2Daniel Stenberg2021-04-211-1/+0
| | | | Accidentally committed in 605e84235
* http2: move the stream error field to the per-transfer storageDaniel Stenberg2021-04-211-14/+14
| | | | | | | | Storing a stream error in the per-connection struct was an error that lead to race conditions as subsequent stream handling could overwrite the error code before it was used for the stream with the actual problem. Closes #6910
* http2: call the handle-closed function correctly on closed streamDaniel Stenberg2021-04-211-0/+4
| | | | | | | | | This was this one condition where the stream could be closed due to an error and the function would still wrongly just return 0 for it. Reported-by: Gergely Nagy Fixes #6862 Closes #6910
* urldata: merge "struct DynamicStatic" into "struct UrlState"Daniel Stenberg2021-03-261-4/+4
| | | | | | | | Both were used for the same purposes and there was no logical separation between them. Combined, this also saves 16 bytes in less holes in my test build. Closes #6798
* http2: don't set KEEP_SEND when there's no more data to be sentRobert Ronto2021-03-151-3/+5
| | | | | | | this should fix an issue where curl sometimes doesn't send out a request with authorization info after a 401 is received over http2 Closes #6747
* http2: fail if connection terminated without END_STREAMoxalica2021-03-121-0/+11
| | | | Closes #6736
* http2: remove conn->data useDaniel Stenberg2021-02-151-37/+57
| | | | | | | | | | | | ... but instead use a private alternative that points to the "driving transfer" from the connection. We set the "user data" associated with the connection to be the connectdata struct, but when we drive transfers the code still needs to know the pointer to the transfer. We can change the user data to become the Curl_easy handle, but with older nghttp2 version we cannot dynamically update that pointer properly when different transfers are used over the same connection. Closes #6520
* urldata: remove duplicate 'upkeep_interval_ms' from connectdataDaniel Stenberg2021-01-271-1/+1
| | | | | | ... and rely only on the value already set in Curl_easy. Closes #6534
* lib: pass in 'struct Curl_easy *' to most functionsDaniel Stenberg2021-01-171-101/+103
| | | | | | | | | | | | | | | | | | | | | ... in most cases instead of 'struct connectdata *' but in some cases in addition to. - We mostly operate on transfers and not connections. - We need the transfer handle to log, store data and more. Everything in libcurl is driven by a transfer (the CURL * in the public API). - This work clarifies and separates the transfers from the connections better. - We should avoid "conn->data". Since individual connections can be used by many transfers when multiplexing, making sure that conn->data points to the current and correct transfer at all times is difficult and has been notoriously error-prone over the years. The goal is to ultimately remove the conn->data pointer for this reason. Closes #6425
* failf: remove newline from formatting stringsDaniel Stenberg2020-12-251-3/+3
| | | | | | | | | ... as failf adds one itself. Also: add an assert() to failf() that triggers on a newline in the format string! Closes #6365
* h2: do not wait for RECV on paused transfersDaniel Stenberg2020-12-221-3/+4
| | | | | | | | | | ... as the socket might be readable all the time when paused and thus causing a busy-loop. Reported-by: Harry Sintonen Reviewed-by: Jay Satiro Fixes #6356 Closes #6357
* infof/failf calls: fix format specifiersRikard Falkeborn2020-11-241-2/+2
| | | | | | Update a few format specifiers to match what is being printed. Closes #6241
* urldata: remove 'void *protop' and create the union 'p'Daniel Stenberg2020-11-231-25/+25
| | | | | | | ... to avoid the use of 'void *' for the protocol specific structs done per transfer. Closes #6238
* curl.se: new homeDaniel Stenberg2020-11-041-1/+1
| | | | Closes #6172
* sendf: move the verbose-check into Curl_debugDaniel Stenberg2020-11-021-2/+1
| | | | | | Saves us from having the same check done everywhere. Closes #6159
* Curl_handler: add 'family' to each protocolDaniel Stenberg2020-09-211-0/+2
| | | | | | | Makes get_protocol_family() faster and it moves the knowledge about the "families" to each protocol handler, where it belongs. Closes #5986
* http: consolidate nghttp2_session_mem_recv() call pathsLaramie Leavitt2020-09-101-88/+29
| | | | | | | | | | | | | | | | | | | | | Previously there were several locations that called nghttp2_session_mem_recv and handled responses slightly differently. Those have been converted to call the existing h2_process_pending_input() function. Moved the end-of-session check to h2_process_pending_input() since the only place the end-of-session state can change is after nghttp2 processes additional input frames. This will likely fix the fuzzing error. While I don't have a root cause the out-of-bounds read seems like a use after free, so moving the nghttp2_session_check_request_allowed() call to a location with a guaranteed nghttp2 session seems reasonable. Also updated a few nghttp2 callsites to include error messages and added a few additional error checks. Closes #5648
* h2: repair trailer handlingDaniel Stenberg2020-08-031-8/+28
| | | | | | | | | | | | | The previous h2 trailer fix in 54a2b63 was wrong and caused a regression: it cannot deal with trailers immediately when read since they may be read off the connection by the wrong 'data' owner. This change reverts the logic back to gathering all trailers into a single buffer, like before 54a2b63. Reported-by: Tadej Vengust Fixes #5663 Closes #5769
* CURL_PUSH_ERROROUT: allow the push callback to fail the parent streamDaniel Stenberg2020-07-161-9/+18
| | | | | | | | | ... by adding support for a new dedicated return code. Suggested-by: Jonathan Cardoso Assisted-by: Erik Johansson URL: https://curl.haxx.se/mail/lib-2020-06/0099.html Closes #5636
* http2: only do the *done() cleanups for HTTPDaniel Stenberg2020-07-041-1/+2
| | | | | | | Follow-up to ef86daf4d3 Closes #5650 Fixes #5646
* http2: close the http2 connection when no more requests may be sentLaramie Leavitt2020-07-031-0/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Well-behaving HTTP2 servers send two GOAWAY messages. The first message is a warning that indicates that the server is going to stop accepting streams. The second one actually closes the stream. nghttp2 reports this state (and the other state of no more stream identifiers) via the call nghttp2_session_check_request_allowed(). In this state the client should not create more streams on the session (tcp connection), and in curl this means that the server has requested that the connection is closed. It would be also be possible to put the connclose() call into the on_http2_frame_recv() function that triggers on the GOAWAY message. This fixes a bug seen when the client sees the following sequence of frames: // advisory GOAWAY HTTP2 GOAWAY [stream-id = 0, promised-stream-id = -1] ... some additional frames // final GOAWAY HTTP2 GOAWAY [stream-id = 0, promised-stream-id = N ] Before this change, curl will attempt to reuse the connection even after the last stream, will encounter this error: * Found bundle for host localhost: 0x5595f0a694e0 [can multiplex] * Re-using existing connection! (#0) with host localhost * Connected to localhost (::1) port 10443 (#0) * Using Stream ID: 9 (easy handle 0x5595f0a72e30) > GET /index.html?5 HTTP/2 > Host: localhost:10443 > user-agent: curl/7.68.0 > accept: */* > * stopped the pause stream! * Connection #0 to host localhost left intact curl: (16) Error in the HTTP2 framing layer This error may posion the connection cache, causing future requests which resolve to the same curl connection to go through the same error path. Closes #5643
* http2: fix nghttp2_strerror -> nghttp2_http2_strerror in debug messagesJeremy Maitin-Shepard2020-07-021-2/+2
| | | | | | | | | Confusingly, nghttp2 has two different error code enums: - nghttp2_error, to be used with nghttp2_strerror - nghttp2_error_code, to be used with nghttp2_http2_strerror Closes #5641
* http2: set the correct URL in pushed transfersDaniel Stenberg2020-06-251-0/+44
| | | | | | | | | ...previously CURLINFO_EFFECTIVE_URL would report the URL of the original "mother transfer", not the actually pushed resource. Reported-by: Jonathan Cardoso Machado Fixes #5589 Closes #5591
* urldata: let the HTTP method be in the set.* structDaniel Stenberg2020-06-021-1/+1
| | | | | | | | | | | | When the method is updated inside libcurl we must still not change the method as set by the user as then repeated transfers with that same handle might not execute the same operation anymore! This fixes the libcurl part of #5462 Test 1633 added to verify. Closes #5499
* url: alloc the download buffer at transfer startDaniel Stenberg2020-05-301-3/+6
| | | | | | | | | | | ... and free it as soon as the transfer is done. It removes the extra alloc when a new size is set with setopt() and reduces memory for unused easy handles. In addition: the closure_handle now doesn't use an allocated buffer at all but the smallest supported size as a stack based one. Closes #5472
* http2: keep trying to send pending frames after req.upload_doneVyron Tsingaras2020-05-151-2/+20
| | | | | Fixes #1410 Closes #5401
* http2: simplify and clean up trailer handlingDaniel Stenberg2020-05-071-42/+11
| | | | | | | | | | | | Triggered by a crash detected by OSS-Fuzz after the dynbuf introduction in ed35d6590e72. This should make the trailer handling more straight forward and hopefully less error-prone. Deliver the trailer header to the callback already at receive-time. No longer caches the trailers to get delivered at end of stream. Bug: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=22030 Closes #5348
* dynbuf: introduce internal generic dynamic buffer functionsDaniel Stenberg2020-05-041-65/+50
| | | | | | | | | | | | | A common set of functions instead of many separate implementations for creating buffers that can grow when appending data to them. Existing functionality has been ported over. In my early basic testing, the total number of allocations seem at roughly the same amount as before, possibly a few less. See docs/DYNBUF.md for a description of the API. Closes #5300
* http2: Fix erroneous debug message that h2 connection closedJay Satiro2020-03-181-2/+0
| | | | | | | | | | | | | Prior to this change in libcurl debug builds http2 stream closure was erroneously referred to as connection closure. Before: * nread <= 0, server closed connection, bailing After: * nread == 0, stream closed, bailing Closes https://github.com/curl/curl/pull/5118
* version: make curl_version* thread-safe without using global contextDaniel Stenberg2020-03-071-1/+1
| | | | Closes #5010
* http2: make pausing/unpausing set/clear local stream windowDaniel Stenberg2020-02-271-4/+53
| | | | | | | | | | | | | This reduces the HTTP/2 window size to 32 MB since libcurl might have to buffer up to this amount of data in memory and yet we don't want it set lower to potentially impact tranfer performance on high speed networks. Requires nghttp2 commit b3f85e2daa629 (https://github.com/nghttp2/nghttp2/pull/1444) to work properly, to end up in the next release after 1.40.0. Fixes #4939 Closes #4940
* http2: now require nghttp2 >= 1.12.0Daniel Stenberg2020-02-211-47/+5
| | | | | | | | | To simplify our code and since earlier versions lack important function calls libcurl needs to function correctly. nghttp2 1.12.0 was relased on June 26, 2016. Closes #4961
* ConnectionExists: respect the max_concurrent_streams limitsDaniel Stenberg2020-01-131-2/+2
| | | | | | | | | | | | | | | A regression made the code use 'multiplexed' as a boolean instead of the counter it is intended to be. This made curl try to "over-populate" connections with new streams. This regression came with 41fcdf71a1, shipped in curl 7.65.0. Also, respect the CURLMOPT_MAX_CONCURRENT_STREAMS value in the same check. Reported-by: Kunal Ekawde Fixes #4779 Closes #4784