mirror of
https://github.com/lwthiker/curl-impersonate.git
synced 2026-08-25 19:18:13 +00:00
Handle curl_easy_reset() calls when impersonating (#44)
curl_easy_reset() may be used by an application to reset the options on a curl handle. If an app has the CURL_IMPERSONATE env var defined, then the impersonation options are automatically set in curl_easy_init() but will be cleared in a call to curl_easy_reset(). The desired behavior is for the impersonation options to be retained (as they are "transparent" to the user), which this commit takes care of. Note that this only has an effect when libcurl-impersonate is loaded and the CURL_IMPERSONATE env var is set. Otherwise the regular behavior of resetting all the handle options is retained. Test that the unique TLS signature of curl-impersonate is preserved after a call to curl_easy_reset() when libcurl-impersonate is loaded. For this purpose change the 'minicurl' testing util to support multiple URLs and launch it with 2 different URLs when testing the TLS signature.
This commit is contained in:
@@ -244,7 +244,7 @@ index 769363941..cd59ad4b2 100644
|
||||
|
||||
CHECKSRC = $(CS_$(V))
|
||||
diff --git a/lib/easy.c b/lib/easy.c
|
||||
index 20293a710..37cda0992 100644
|
||||
index 20293a710..8b6a0f4e1 100644
|
||||
--- a/lib/easy.c
|
||||
+++ b/lib/easy.c
|
||||
@@ -80,6 +80,7 @@
|
||||
@@ -755,6 +755,28 @@ index 20293a710..37cda0992 100644
|
||||
/* Reinitialize an SSL engine for the new handle
|
||||
* note: the engine name has already been copied by dupset */
|
||||
if(outcurl->set.str[STRING_SSL_ENGINE]) {
|
||||
@@ -967,6 +1440,8 @@ struct Curl_easy *curl_easy_duphandle(struct Curl_easy *data)
|
||||
*/
|
||||
void curl_easy_reset(struct Curl_easy *data)
|
||||
{
|
||||
+ char *target;
|
||||
+
|
||||
Curl_free_request_state(data);
|
||||
|
||||
/* zero out UserDefined data: */
|
||||
@@ -991,6 +1466,12 @@ void curl_easy_reset(struct Curl_easy *data)
|
||||
#if !defined(CURL_DISABLE_HTTP) && !defined(CURL_DISABLE_CRYPTO_AUTH)
|
||||
Curl_http_auth_cleanup_digest(data);
|
||||
#endif
|
||||
+
|
||||
+ target = curl_getenv("CURL_IMPERSONATE");
|
||||
+ if(target) {
|
||||
+ curl_easy_impersonate(data, target);
|
||||
+ free(target);
|
||||
+ }
|
||||
}
|
||||
|
||||
/*
|
||||
diff --git a/lib/easyoptions.c b/lib/easyoptions.c
|
||||
index 04871ad1e..ce280eaa3 100644
|
||||
--- a/lib/easyoptions.c
|
||||
|
||||
Reference in New Issue
Block a user