summaryrefslogtreecommitdiff
path: root/lib/easy.c
Commit message (Collapse)AuthorAgeFilesLines
* multi: rename the multi transfer statesDaniel Stenberg2021-02-161-2/+2
| | | | | | | | | | While working on documenting the states it dawned on me that step one is to use more descriptive names on the states. This also changes prefix on the states to make them shorter in the source. State names NOT ending with *ing are transitional ones. Closes #6612
* lib: remove 'conn->data' completelyDaniel Stenberg2021-02-161-12/+0
| | | | | | | | The Curl_easy pointer struct entry in connectdata is now gone. Just before commit 215db086e0 landed on January 8, 2021 there were 919 references to conn->data. Closes #6608
* hostip: remove conn->data from resolver functionsDaniel Stenberg2021-01-221-2/+2
| | | | | | | This also moves the 'async' struct from the connectdata struct into the Curl_easy struct, which seems like a better home for it. Closes #6497
* lib: pass in 'struct Curl_easy *' to most functionsDaniel Stenberg2021-01-171-7/+17
| | | | | | | | | | | | | | | | | | | | | ... 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
* global_init: debug builds allocates a byte in initDaniel Stenberg2021-01-061-1/+14
| | | | | | | | | | ... to make build tools/valgrind warn if no curl_global_cleanup is called. This is conditionally only done for debug builds with the env variable CURL_GLOBAL_INIT set. Closes #6410
* speedcheck: exclude paused transfersDaniel Stenberg2020-12-221-0/+3
| | | | | | | | | | | Paused transfers should not be stopped due to slow speed even when CURLOPT_LOW_SPEED_LIMIT is set. Additionally, the slow speed timer is now reset when the transfer is unpaused - as otherwise it would easily just trigger immediately after unpausing. Reported-by: Harry Sintonen Fixes #6358 Closes #6359
* curl.se: new homeDaniel Stenberg2020-11-041-1/+1
| | | | Closes #6172
* hsts: add read/write callbacksDaniel Stenberg2020-11-031-1/+3
| | | | | | | | - read/write callback options - man pages for the 4 new setopts - test 1915 verifies the callbacks Closes #5896
* hsts: add support for Strict-Transport-SecurityDaniel Stenberg2020-11-031-0/+11
| | | | | | | | | | | | | | | | | | | | | | | | | - enable in the build (configure) - header parsing - host name lookup - unit tests for the above - CI build - CURL_VERSION_HSTS bit - curl_version_info support - curl -V output - curl-config --features - CURLOPT_HSTS_CTRL - man page for CURLOPT_HSTS_CTRL - curl --hsts (sets CURLOPT_HSTS_CTRL and works with --libcurl) - man page for --hsts - save cache to disk - load cache from disk - CURLOPT_HSTS - man page for CURLOPT_HSTS - added docs/HSTS.md - fixed --version docs - adjusted curl_easy_duphandle Closes #5896
* pause: only trigger a reread if the unpause sticksDaniel Stenberg2020-09-251-3/+4
| | | | | | | | | | | | As an unpause might itself get paused again and then triggering another reread doesn't help. Follow-up from e040146f22608fd9 (shipped since 7.69.1) Bug: https://curl.haxx.se/mail/lib-2020-09/0081.html Patch-by: Kunal Chandarana Fixes #5988 Closes #6013
* symbian: drop supportDaniel Stenberg2020-09-221-12/+0
| | | | | | | | | The OS is deprecated. I see no traces of anyone having actually built curl for Symbian after 2012. The public headers are unmodified. Closes #5989
* easy_reset: clear retry counterQuentin Balland2020-09-181-0/+1
| | | | | Closes #5975 Fixes #5974
* altsvc: clone setting in curl_easy_duphandlebagder/altsvc-duphandleDaniel Stenberg2020-09-061-0/+11
| | | | | | | | | | | | The cache content is not duplicated, like other caches, but the setting and specified file name are. Test 1908 is extended to verify this somewhat. Since the duplicated handle gets the same file name, the test unfortunately overwrites the same file twice (with different contents) which makes it hard to check automatically. Closes #5923
* Curl_easy: remember last connection by id, not by pointerDaniel Stenberg2020-08-171-2/+1
| | | | | | | | | CVE-2020-8231 Bug: https://curl.haxx.se/docs/CVE-2020-8231.html Reported-by: Marc Aldorasi Closes #5824
* timeouts: move ms timeouts to timediff_t from int and longMarc Hoersken2020-06-061-1/+1
| | | | | | | | | | | | | Now that all functions in select.[ch] take timediff_t instead of the limited int or long, we can remove type conversions and related preprocessor checks to silence compiler warnings. Avoiding conversions from time_t was already done in 842f73de. Based upon #5262 Supersedes #5214, #5220 and #5221 Follow up to #5343 and #5479 Closes #5490
* url: alloc the download buffer at transfer startDaniel Stenberg2020-05-301-17/+0
| | | | | | | | | | | ... 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
* setopt: support certificate options in memory with struct curl_blobGilles Vollant2020-05-151-0/+11
| | | | | | | | | | | | | This change introduces a generic way to provide binary data in setopt options, called BLOBs. This change introduces these new setopts: CURLOPT_ISSUERCERT_BLOB, CURLOPT_PROXY_SSLCERT_BLOB, CURLOPT_PROXY_SSLKEY_BLOB, CURLOPT_SSLCERT_BLOB and CURLOPT_SSLKEY_BLOB. Reviewed-by: Daniel Stenberg Closes #5357
* easy: fix dangling pointer on easy_perform faildenzor2020-05-121-0/+1
| | | | Closes https://github.com/curl/curl/pull/5363
* dynbuf: introduce internal generic dynamic buffer functionsDaniel Stenberg2020-05-041-10/+9
| | | | | | | | | | | | | 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
* easy: Fix curl_easy_duphandle for builds missing IPv6 that use c-aresJay Satiro2020-03-141-8/+19
| | | | | | | | | | | | | | | | | - Ignore CURLE_NOT_BUILT_IN errors returned by c-ares functions in curl_easy_duphandle. Prior to this change if c-ares was used as the resolver backend and either it was too old or libcurl was built without IPv6 support then some of our resolver functions could return CURLE_NOT_BUILT_IN to curl_easy_duphandle causing it to fail. Caused by c8f086b which shipped in 7.69.1. Reported-by: Karl Chen Fixes https://github.com/curl/curl/issues/5097 Closes https://github.com/curl/curl/pull/5100
* mime: latch last read callback status.Patrick Monnerat2020-03-071-0/+8
| | | | | | | | | | | | | In case a read callback returns a status (pause, abort, eof, error) instead of a byte count, drain the bytes read so far but remember this status for further processing. Takes care of not losing data when pausing, and properly resume a paused mime structure when requested. New tests 670-673 check unpausing cases, with easy or multi interface and mime or form api. Fixes #4813 Reported-by: MrdUkk on github
* ares: store dns parameters for duphandleErnst Sjöstrand2020-03-071-0/+11
| | | | | | | | | | | With c-ares the dns parameters lives in ares_channel. Store them in the curl handle and set them again in easy_duphandle. Regression introduced in #3228 (6765e6d), shipped in curl 7.63.0. Fixes #4893 Closes #5020 Signed-off-by: Ernst Sjöstrand <ernst.sjostrand@verisure.com>
* version: make curl_version* thread-safe without using global contextDaniel Stenberg2020-03-071-4/+0
| | | | Closes #5010
* pause: force a connection (re-)check after unpausingDaniel Stenberg2020-03-071-0/+4
| | | | | | | | | There might be data available that was already read off the socket, for example in the TLS layer. Reported-by: Anders Berg Fixes #4966 Closes #5049
* pause: bail out on bad inputDaniel Stenberg2020-03-061-6/+12
| | | | | | | A NULL easy handle or an easy handle without an associated connection cannot be paused or unpaused. Closes #5050
* pause: return early for calls that don't change pause stateDaniel Stenberg2020-03-061-0/+7
| | | | | | Reviewed-by: Patrick Monnerat Ref: #4833 Closes #5026
* Revert "pause: force-drain the transfer on unpause"bagder/revert-unpause-h2Daniel Stenberg2020-03-051-1/+0
| | | | | | | | | | This reverts commit fa0216b294af4c7113a9040ca65eefc7fc18ac1c (from #5000) Clearly that didn't solve the problem correctly. Reported-by: Christopher Reid Reopens #4966 Fixes #5044
* Revert "mime: latch last read callback status."Daniel Stenberg2020-03-021-8/+0
| | | | | | | | This reverts commit 87869e38d7afdec3ef1bb4965711458b088e254f. Fixes #5014 Closes #5015 Reopens #4833
* mime: latch last read callback status.Patrick Monnerat2020-03-021-0/+8
| | | | | | | | | | | | | | In case a read callback returns a status (pause, abort, eof, error) instead of a byte count, drain the bytes read so far but remember this status for further processing. Takes care of not losing data when pausing, and properly resume a paused mime structure when requested. New tests 670-673 check unpausing cases, with easy or multi interface and mime or form api. Fixes #4813 Reported-by: MrdUkk on github Closes #4833
* pause: force-drain the transfer on unpauseDaniel Stenberg2020-02-291-0/+1
| | | | | | | | | ... 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
* http2: make pausing/unpausing set/clear local stream windowDaniel Stenberg2020-02-271-33/+38
| | | | | | | | | | | | | 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
* easy: remove dead codeJay Satiro2020-02-121-4/+0
| | | | | | multi is already assigned to data->multi by curl_multi_add_handle. Closes https://github.com/curl/curl/pull/4900
* global_init: move the IPv6 works status bool to multi handleDaniel Stenberg2020-01-281-2/+0
| | | | | | | | | Previously it was stored in a global state which contributed to curl_global_init's thread unsafety. This boolean is now instead figured out in curl_multi_init() and stored in the multi handle. Less effective, but thread safe. Closes #4851
* global_init: assume the EINTR bit by defaultDaniel Stenberg2020-01-261-2/+6
| | | | | | | | | | | | - Removed from global_init since it isn't thread-safe. The symbol will still remain to not break compiles, it just won't have any effect going forward. - make the internals NOT loop on EINTR (the opposite from previously). It only risks returning from the select/poll/wait functions early, and that should be risk-free. Closes #4840
* wolfssh: make it init properly via Curl_ssh_init()Daniel Stenberg2020-01-241-7/+0
| | | | Closes #4846
* wolfSSH: new SSH backendDaniel Stenberg2020-01-121-1/+12
| | | | | | Adds support for SFTP (not SCP) using WolfSSH. Closes #4231
* global_init: undo the "intialized" bump in case of failureDaniel Stenberg2019-12-021-5/+9
| | | | | | | | | ... so that failures in the global init function don't count as a working init and it can then be called again. Reported-by: Paul Groke Fixes #4636 Closes #4653
* lib: Move lib/ssh.h -> lib/vssh/ssh.hJay Satiro2019-11-171-1/+1
| | | | | | Follow-up to 5b2d703 which moved ssh source files to vssh. Closes https://github.com/curl/curl/pull/4609
* pause: avoid updating socket if done was already calledDaniel Stenberg2019-11-101-3/+4
| | | | | | | | ... avoids unnecesary recursive risk when the transfer is already done. Reported-by: Richard Bowker Fixes #4563 Closes #4574
* url: make Curl_close() NULLify the pointer tooDaniel Stenberg2019-10-301-1/+1
| | | | | | | This is the common pattern used in the code and by a unified approach we avoid mistakes. Closes #4534
* easy: part of conditional expression is always true: !resultDaniel Stenberg2019-09-201-3/+2
| | | | | Fixes warning detected by PVS-Studio Fixes #4374
* cleanup: move functions out of url.c and make them staticDaniel Stenberg2019-09-031-1/+30
| | | | Closes #4289
* vssh: move ssh init/cleanup functions into backend codeDaniel Stenberg2019-08-171-17/+3
|
* curl_multi_poll: a sister to curl_multi_wait() that waits moreDaniel Stenberg2019-08-061-19/+3
| | | | | | | | | | | | | | | | | | | | | | | | Repeatedly we see problems where using curl_multi_wait() is difficult or just awkward because if it has no file descriptor to wait for internally, it returns immediately and leaves it to the caller to wait for a small amount of time in order to avoid occasional busy-looping. This is often missed or misunderstood, leading to underperforming applications. This change introduces curl_multi_poll() as a replacement drop-in function that accepts the exact same set of arguments. This function works identically to curl_multi_wait() - EXCEPT - for the case when there's nothing to wait for internally, as then this function will by itself wait for a "suitable" short time before it returns. This effectiely avoids all risks of busy-looping and should also make it less likely that apps "over-wait". This also changes the curl tool to use this funtion internally when doing parallel transfers and changes curl_easy_perform() to use it internally. Closes #4163
* easy: resize receive buffer on easy handle resetJay Satiro2019-07-251-0/+14
| | | | | | | | | | | | | | | | | | | - In curl_easy_reset attempt to resize the receive buffer to its default size. If realloc fails then continue using the previous size. Prior to this change curl_easy_reset did not properly handle resetting the receive buffer (data->state.buffer). It reset the variable holding its size (data->set.buffer_size) to the default size (READBUFFER_SIZE) but then did not actually resize the buffer. If a user resized the buffer by using CURLOPT_BUFFERSIZE to set the size smaller than the default, later called curl_easy_reset and attempted to reuse the handle then a heap overflow would very likely occur during that handle's next transfer. Reported-by: Felix Hädicke Fixes https://github.com/curl/curl/issues/4143 Closes https://github.com/curl/curl/pull/4145
* unpause: trigger a timeout for event-based transfersDaniel Stenberg2019-06-091-1/+4
| | | | | | | | | | ... so that timeouts or other state machine actions get going again after a changing pause state. For example, if the last delivery was paused there's no pending socket activity. Reported-by: sstruchtrup on github Fixes #3994 Closes #4001
* cleanup: remove FIXME and TODO commentsDaniel Stenberg2019-05-161-1/+1
| | | | | | | | | They serve very little purpose and mostly just add noise. Most of them have been around for a very long time. I read them all before removing or rephrasing them. Ref: #3876 Closes #3883
* auth: Rename the various authentication clean up functionsSteve Holme2019-05-121-1/+1
| | | | | | For consistency and to a avoid confusion. Closes #3869
* easy: fix another "clarify calculation precedence" warningMarcel Raad2019-05-121-2/+2
| | | | I missed this one in commit 6b3dde7fe62ea5a557fd1fd323fac2bcd0c2e9be.
* build: fix "clarify calculation precedence" warningsMarcel Raad2019-05-121-2/+2
| | | | | | | Codacy/CppCheck warns about this. Consistently use parentheses as we already do in some places to silence the warning. Closes https://github.com/curl/curl/pull/3866