summaryrefslogtreecommitdiff
path: root/lib/transfer.c
Commit message (Collapse)AuthorAgeFilesLines
...
* urldata: merge "struct DynamicStatic" into "struct UrlState"Daniel Stenberg2021-03-261-20/+20
| | | | | | | | 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
* http: use credentials from transfer, not connectionDaniel Stenberg2021-02-131-0/+14
| | | | | | | | | | | | | | | | | | | HTTP auth "accidentally" worked before this cleanup since the code would always overwrite the connection credentials with the credentials from the most recent transfer and since HTTP auth is typically done first thing, this has not been an issue. It was still wrong and subject to possible race conditions or future breakage if the sequence of functions would change. The data.set.str[] strings MUST remain unmodified exactly as set by the user, and the credentials to use internally are instead set/updated in state.aptr.* Added test 675 to verify different credentials used in two requests done over a reused HTTP connection, which previously behaved wrongly. Fixes #6542 Closes #6545
* urldata: don't touch data->set.httpversion at run-timeDaniel Stenberg2021-02-121-2/+2
| | | | | | | | | Rename it to 'httpwant' and make a cloned field in the state struct as well for run-time updates. Also: refuse non-supported HTTP versions. Verified with test 129. Closes #6585
* ftp: add 'list_only' to the transfer state structDaniel Stenberg2021-02-091-0/+1
| | | | | | | | | and rename it from 'ftp_list_only' since it is also used for SSH and POP3. The state is updated internally for 'type=D' FTP URLs. Added test case 1570 to verify. Closes #6578
* ftp: add 'prefer_ascii' to the transfer state structDaniel Stenberg2021-02-091-5/+6
| | | | | | | | | | | ... and make sure the code never updates 'set.prefer_ascii' as it breaks handle reuse which should use the setting as the user specified it. Added test 1569 to verify: it first makes an FTP transfer with ';type=A' and then another without type on the same handle and the second should then use binary. Previously, curl failed this. Closes #6578
* urldata: move 'followlocation' to UrlStateDaniel Stenberg2021-02-091-3/+3
| | | | | | | As this is a state variable it does not belong in UserDefined which is used to store values set by the user. Closes #6582
* transfer: fix GCC 10 warning with flag '-Wint-in-bool-context'Michał Antoniak2021-01-291-2/+3
| | | | | | ... and return the error code from the Curl_mime_rewind call. Closes #6537
* avoid warning: enum constant in boolean contextMichał Antoniak2021-01-291-1/+1
|
* Curl_chunker: shrink the structDaniel Stenberg2021-01-271-8/+6
| | | | | | | ... by removing a field, converting the hex index into a byte and rearranging the order. Cuts it down from 48 bytes to 32 on x86_64. Closes #6527
* chunk/encoding: remove conn->data referencesDaniel Stenberg2021-01-211-2/+2
| | | | | | ... by anchoring more functions on Curl_easy instead of connectdata Closes #6498
* transfer: fix ‘conn’ undeclared mistake for iconv buildDaniel Stenberg2021-01-201-0/+1
| | | | Follow-up to 219d9f8620d
* transfer: remove conn->data useDaniel Stenberg2021-01-191-18/+15
| | | | Closes #6486
* quic: remove conn->data useDaniel Stenberg2021-01-191-1/+1
| | | | Closes #6485
* lib: more conn->data cleanupsDaniel Stenberg2021-01-191-2/+2
| | | | Closes #6479
* lib: pass in 'struct Curl_easy *' to most functionsDaniel Stenberg2021-01-171-16/+16
| | | | | | | | | | | | | | | | | | | | | ... 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
* transfer: remove Curl_ prefix from static functionsDaniel Stenberg2021-01-141-5/+5
|
* pretransfer: setup the User-Agent header hereDaniel Stenberg2021-01-051-0/+14
| | | | | | | | | | | | | ... and not in the connection setup, as for multiplexed transfers the connection setup might be skipped and then the transfer would end up without the set user-agent! Reported-by: Flameborn on github Assisted-by: Andrey Gursky Assisted-by: Jay Satiro Assisted-by: Mike Gelfand Fixes #6312 Closes #6417
* httpauth: make multi-request auth work with custom portDaniel Stenberg2021-01-021-2/+7
| | | | | | | | | | | | When doing HTTP authentication and a port number set with CURLOPT_PORT, the code would previously have the URL's port number override as if it had been a redirect to an absolute URL. Added test 1568 to verify. Reported-by: UrsusArctos on github Fixes #6397 Closes #6400
* language: s/behaviour/behavior/gEmil Engler2021-01-021-3/+3
| | | | | | | | We currently use both spellings the british "behaviour" and the american "behavior". However "behavior" is more used in the project so I think it's worth dropping the british name. Closes #6395
* misc: fix "warning: empty expression statement has no effect"Daniel Stenberg2020-12-261-4/+1
| | | | | | | | | | Turned several macros into do-while(0) style to allow their use to work find with semicolon. Bug: https://github.com/curl/curl/commit/08e8455dddc5e48e58a12ade3815c01ae3da3b64#commitcomment-45433279 Follow-up to 08e8455dddc5e4 Reported-by: Gisle Vanem Closes #6376
* lib: introduce c-hyper for using HyperDaniel Stenberg2020-12-181-58/+8
| | | | ... as an alternative HTTP backend within libcurl.
* http: show the request as headers even when split-sendingDaniel Stenberg2020-12-171-5/+21
| | | | | | | | | | When the initial request isn't possible to send in its entirety, the remainder of request would be delivered to the debug callback as data and would wrongly be counted internally as body-bytes sent. Extended test 1295 to verify. Closes #6328
* urldata: remove 'void *protop' and create the union 'p'Daniel Stenberg2020-11-231-4/+4
| | | | | | | ... 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
* hsts: add read/write callbacksDaniel Stenberg2020-11-031-0/+2
| | | | | | | | - read/write callback options - man pages for the 4 new setopts - test 1915 verifies the callbacks Closes #5896
* sendf: move the verbose-check into Curl_debugDaniel Stenberg2020-11-021-4/+3
| | | | | | Saves us from having the same check done everywhere. Closes #6159
* transfer: move retrycount from connect struct to easy handleStefan Yohansson2020-08-101-2/+4
| | | | | | | | | | This flag was applied to the connection struct that is released on retry. These changes move the retry counter into Curl_easy struct that lives across retries and retains the new connection. Reported-by: Cherish98 on github Fixes #5794 Closes #5800
* transfer: fix data_pending for builds with both h2 and h3 enabledDaniel Stenberg2020-07-281-2/+6
| | | | Closes #5734
* transfer: fix memory-leak with CURLOPT_CURLU in a duped handleDaniel Stenberg2020-07-121-1/+2
| | | | | | | | Added test case 674 to reproduce and verify the bug report. Fixes #5665 Reported-by: NobodyXu on github Closes #5673
* urldata: let the HTTP method be in the set.* structDaniel Stenberg2020-06-021-19/+20
| | | | | | | | | | | | 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
* transfer: remove k->str NULL checkDaniel Stenberg2020-06-011-1/+1
| | | | | | | | | | "Null-checking k->str suggests that it may be null, but it has already been dereferenced on all paths leading to the check" - and it can't legally be NULL at this point. Remove check. Detected by Coverity CID 1463884 Closes #5495
* url: alloc the download buffer at transfer startDaniel Stenberg2020-05-301-7/+7
| | | | | | | | | | | ... 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
* transfer: close connection after excess data has been readMichael Kaufmann2020-05-271-0/+1
| | | | | | | | For HTTP 1.x, it's a protocol error when the server sends more bytes than announced. If this happens, don't reuse the connection, because the start position of the next response is undefined. Closes #5440
* dynbuf: introduce internal generic dynamic buffer functionsDaniel Stenberg2020-05-041-21/+21
| | | | | | | | | | | | | 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
* transfer: Switch PUT to GET/HEAD on 303 redirectJay Satiro2020-04-221-6/+13
| | | | | | | | | | | | | | Prior to this change if there was a 303 reply to a PUT request then the subsequent request to respond to that redirect would also be a PUT. It was determined that was most likely incorrect based on the language of the RFCs. Basically 303 means "see other" resource, which implies it is most likely not the same resource, therefore we should not try to PUT to that different resource. Refer to the discussions in #5237 and #5248 for more information. Fixes https://github.com/curl/curl/issues/5237 Closes https://github.com/curl/curl/pull/5248
* http: don't consider upload done if the request isn't completely sent offDaniel Stenberg2020-04-081-2/+7
| | | | | Fixes #4919 Closes #5197
* build: fixed build for systems with select() in unistd.hHarry Sintonen2020-03-311-0/+2
| | | | Closes #5169
* http2: Fix erroneous debug message that h2 connection closedJay Satiro2020-03-181-6/+14
| | | | | | | | | | | | | 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
* transfer: cap retries of "dead connections" to 5Daniel Stenberg2020-03-151-0/+6
| | | | | | | | | | When libcurl retries a connection due to it being "seemingly dead" or by REFUSED_STREAM, it will now only do it up five times before giving up, to avoid never-ending loops. Reported-by: Dima Tisnek Bug: https://curl.haxx.se/mail/lib-2020-03/0044.html Closes #5074
* transfer: set correct copyright year rangeDaniel Stenberg2020-03-061-1/+1
|
* urldata: remove the 'stream_was_rewound' connectdata struct memberDaniel Stenberg2020-03-061-4/+2
| | | | | | | ... as it is never set anywhere. Follow-up to 2f44e94ef Closes #5046
* Revert "pause: force-drain the transfer on unpause"bagder/revert-unpause-h2Daniel Stenberg2020-03-051-3/+2
| | | | | | | | | | This reverts commit fa0216b294af4c7113a9040ca65eefc7fc18ac1c (from #5000) Clearly that didn't solve the problem correctly. Reported-by: Christopher Reid Reopens #4966 Fixes #5044
* pause: force-drain the transfer on unpauseDaniel Stenberg2020-02-291-2/+3
| | | | | | | | | ... since the socket might not actually be readable anymore when for example the data is already buffered in the TLS layer. Fixes #4966 Reported-by: Anders Berg Closes #5000
* build: Disable Visual Studio warning "conditional expression is constant"Jay Satiro2019-12-011-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - Disable warning C4127 "conditional expression is constant" globally in curl_setup.h for when building with Microsoft's compiler. This mainly affects building with the Visual Studio project files found in the projects dir. Prior to this change the cmake and winbuild build systems already disabled 4127 globally for when building with Microsoft's compiler. Also, 4127 was already disabled for all build systems in the limited circumstance of the WHILE_FALSE macro which disabled the warning specifically for while(0). This commit removes the WHILE_FALSE macro and all other cruft in favor of disabling globally in curl_setup. Background: We have various macros that cause 0 or 1 to be evaluated, which would cause warning C4127 in Visual Studio. For example this causes it: #define Curl_resolver_asynch() 1 Full behavior is not clearly defined and inconsistent across versions. However it is documented that since VS 2015 Update 3 Microsoft has addressed this somewhat but not entirely, not warning on while(true) for example. Prior to this change some C4127 warnings occurred when I built with Visual Studio using the generated projects in the projects dir. Closes https://github.com/curl/curl/pull/4658
* ngtcp2: use overflow buffer for extra HTTP/3 dataJavier Blazquez2019-11-181-2/+5
| | | | | Fixes #4525 Closes #4603
* http2: move state-init from creation to pre-transferDaniel Stenberg2019-10-031-0/+1
| | | | | | | | | | | To make sure that the HTTP/2 state is initialized correctly for duplicated handles. It would otherwise easily generate "spurious" PRIORITY frames to get sent over HTTP/2 connections when duplicated easy handles were used. Reported-by: Daniel Silverstone Fixes #4303 Closes #4442
* redirect: when following redirects to an absolute URL, URL encode itDaniel Stenberg2019-10-021-1/+2
| | | | | | | | ... to make it handle for example (RFC violating) embeded spaces. Reported-by: momala454 on github Fixes #4445 Closes #4447
* chunked-encoding: stop hiding the CURLE_BAD_CONTENT_ENCODING errorDaniel Stenberg2019-10-021-5/+5
| | | | | | | | | Unknown content-encoding would get returned as CURLE_WRITE_ERROR if the response is chunked-encoded. Reported-by: Ilya Kosarev Fixes #4310 Closes #4449
* Curl_fillreadbuffer: avoid double-free trailer buf on errorbagder/trailer-buf-freeDaniel Stenberg2019-09-091-5/+6
| | | | | | | Reviewed-by: Jay Satiro Reported-by: Thomas Vegas Closes #4307
* ngtcp2: accept upload via callbackDaniel Stenberg2019-08-231-0/+2
| | | | Closes #4256