[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] [gnurl] 239/256: Set and use more necessary options when so
From: |
gnunet |
Subject: |
[GNUnet-SVN] [gnurl] 239/256: Set and use more necessary options when some protocols are disabled |
Date: |
Fri, 06 Oct 2017 19:45:30 +0200 |
This is an automated email from the git hooks/post-receive script.
ng0 pushed a commit to branch master
in repository gnurl.
commit df7839b68c7a3e78c469efc28157ad0df228f32f
Author: Dan Fandrich <address@hidden>
AuthorDate: Sat Sep 30 01:20:56 2017 +0200
Set and use more necessary options when some protocols are disabled
When curl and libcurl are built with some protocols disabled, they stop
setting and receiving some options that don't make sense with those
protocols. In particular, when HTTP is disabled many options aren't set
that are used only by HTTP. However, some options that appear to be
HTTP-only are actually used by other protocols as well (some despite
having HTTP in the name) and should be set, but weren't. This change now
causes some of these options to be set and used for more (or for all)
protocols. In particular, this fixes tests 646 through 649 in an
HTTP-disabled build, which use the MIME API in the mail protocols.
---
lib/url.c | 24 +++++++++++++-----------
src/tool_operate.c | 46 +++++++++++++++++++++++++---------------------
tests/data/test1401 | 4 ++--
3 files changed, 40 insertions(+), 34 deletions(-)
diff --git a/lib/url.c b/lib/url.c
index 9ad503dbd..df12cbf6d 100644
--- a/lib/url.c
+++ b/lib/url.c
@@ -1152,6 +1152,7 @@ CURLcode Curl_setopt(struct Curl_easy *data, CURLoption
option,
data->set.httpreq = HTTPREQ_POST_FORM;
data->set.opt_no_body = FALSE; /* this is implied */
break;
+#endif /* CURL_DISABLE_HTTP */
case CURLOPT_MIMEPOST:
/*
@@ -1194,6 +1195,7 @@ CURLcode Curl_setopt(struct Curl_easy *data, CURLoption
option,
data->set.headers = va_arg(param, struct curl_slist *);
break;
+#ifndef CURL_DISABLE_HTTP
case CURLOPT_PROXYHEADER:
/*
* Set a list with proxy headers to use (or replace internals with)
@@ -1345,7 +1347,7 @@ CURLcode Curl_setopt(struct Curl_easy *data, CURLoption
option,
}
break;
-#endif /* CURL_DISABLE_COOKIES */
+#endif /* !CURL_DISABLE_COOKIES */
case CURLOPT_HTTPGET:
/*
@@ -1371,6 +1373,16 @@ CURLcode Curl_setopt(struct Curl_easy *data, CURLoption
option,
data->set.httpversion = arg;
break;
+ case CURLOPT_EXPECT_100_TIMEOUT_MS:
+ /*
+ * Time to wait for a response to a HTTP request containing an
+ * Expect: 100-continue header before sending the data anyway.
+ */
+ data->set.expect_100_timeout = va_arg(param, long);
+ break;
+
+#endif /* CURL_DISABLE_HTTP */
+
case CURLOPT_HTTPAUTH:
/*
* Set HTTP Authentication type BITMASK.
@@ -1422,16 +1434,6 @@ CURLcode Curl_setopt(struct Curl_easy *data, CURLoption
option,
}
break;
- case CURLOPT_EXPECT_100_TIMEOUT_MS:
- /*
- * Time to wait for a response to a HTTP request containing an
- * Expect: 100-continue header before sending the data anyway.
- */
- data->set.expect_100_timeout = va_arg(param, long);
- break;
-
-#endif /* CURL_DISABLE_HTTP */
-
case CURLOPT_CUSTOMREQUEST:
/*
* Set a custom string to use as request
diff --git a/src/tool_operate.c b/src/tool_operate.c
index 6dd05dbf4..5401955af 100644
--- a/src/tool_operate.c
+++ b/src/tool_operate.c
@@ -986,6 +986,31 @@ static CURLcode operate_do(struct GlobalConfig *global,
my_setopt(curl, CURLOPT_ERRORBUFFER, errorbuffer);
my_setopt(curl, CURLOPT_TIMEOUT_MS, (long)(config->timeout * 1000));
+ switch(config->httpreq) {
+ case HTTPREQ_SIMPLEPOST:
+ my_setopt_str(curl, CURLOPT_POSTFIELDS,
+ config->postfields);
+ my_setopt(curl, CURLOPT_POSTFIELDSIZE_LARGE,
+ config->postfieldsize);
+ break;
+ case HTTPREQ_MIMEPOST:
+ my_setopt_mimepost(curl, CURLOPT_MIMEPOST, config->mimepost);
+ break;
+ default:
+ break;
+ }
+
+ /* new in libcurl 7.10.6 (default is Basic) */
+ if(config->authtype)
+ my_setopt_bitmask(curl, CURLOPT_HTTPAUTH, (long)config->authtype);
+
+ my_setopt_slist(curl, CURLOPT_HTTPHEADER, config->headers);
+
+ if(built_in_protos & (CURLPROTO_HTTP | CURLPROTO_RTSP)) {
+ my_setopt_str(curl, CURLOPT_REFERER, config->referer);
+ my_setopt_str(curl, CURLOPT_USERAGENT, config->useragent);
+ }
+
if(built_in_protos & CURLPROTO_HTTP) {
long postRedir = 0;
@@ -995,24 +1020,7 @@ static CURLcode operate_do(struct GlobalConfig *global,
my_setopt(curl, CURLOPT_UNRESTRICTED_AUTH,
config->unrestricted_auth?1L:0L);
- switch(config->httpreq) {
- case HTTPREQ_SIMPLEPOST:
- my_setopt_str(curl, CURLOPT_POSTFIELDS,
- config->postfields);
- my_setopt(curl, CURLOPT_POSTFIELDSIZE_LARGE,
- config->postfieldsize);
- break;
- case HTTPREQ_MIMEPOST:
- my_setopt_mimepost(curl, CURLOPT_MIMEPOST, config->mimepost);
- break;
- default:
- break;
- }
-
- my_setopt_str(curl, CURLOPT_REFERER, config->referer);
my_setopt(curl, CURLOPT_AUTOREFERER, config->autoreferer?1L:0L);
- my_setopt_str(curl, CURLOPT_USERAGENT, config->useragent);
- my_setopt_slist(curl, CURLOPT_HTTPHEADER, config->headers);
/* new in libcurl 7.36.0 */
if(config->proxyheaders) {
@@ -1029,10 +1037,6 @@ static CURLcode operate_do(struct GlobalConfig *global,
my_setopt_enum(curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_2TLS);
}
- /* new in libcurl 7.10.6 (default is Basic) */
- if(config->authtype)
- my_setopt_bitmask(curl, CURLOPT_HTTPAUTH, (long)config->authtype);
-
/* curl 7.19.1 (the 301 version existed in 7.18.2),
303 was added in 7.26.0 */
if(config->post301)
diff --git a/tests/data/test1401 b/tests/data/test1401
index 2217ed8c1..de4d0aa4f 100644
--- a/tests/data/test1401
+++ b/tests/data/test1401
@@ -84,10 +84,10 @@ int main(int argc, char *argv[])
curl_easy_setopt(hnd, CURLOPT_URL, "http://%HOSTIP:%HTTPPORT/we/want/1401");
curl_easy_setopt(hnd, CURLOPT_HEADER, 1L);
curl_easy_setopt(hnd, CURLOPT_USERPWD, "fake:user");
- curl_easy_setopt(hnd, CURLOPT_USERAGENT, "MyUA");
+ curl_easy_setopt(hnd, CURLOPT_HTTPAUTH, (long)CURLAUTH_BASIC);
curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, slist1);
+ curl_easy_setopt(hnd, CURLOPT_USERAGENT, "MyUA");
curl_easy_setopt(hnd, CURLOPT_MAXREDIRS, 50L);
- curl_easy_setopt(hnd, CURLOPT_HTTPAUTH, (long)CURLAUTH_BASIC);
curl_easy_setopt(hnd, CURLOPT_COOKIE, "chocolate=chip");
curl_easy_setopt(hnd, CURLOPT_VERBOSE, 1L);
curl_easy_setopt(hnd, CURLOPT_TCP_KEEPALIVE, 1L);
--
To stop receiving notification emails like this one, please contact
address@hidden
- [GNUnet-SVN] [gnurl] 180/256: travis: add build without HTTP/SMTP/IMAP, (continued)
- [GNUnet-SVN] [gnurl] 180/256: travis: add build without HTTP/SMTP/IMAP, gnunet, 2017/10/06
- [GNUnet-SVN] [gnurl] 113/256: unit1301: fix error message on first test, gnunet, 2017/10/06
- [GNUnet-SVN] [gnurl] 214/256: mime: fix an explicit null dereference (#1899), gnunet, 2017/10/06
- [GNUnet-SVN] [gnurl] 194/256: tests: enable gssapi in travis-ci linux build, gnunet, 2017/10/06
- [GNUnet-SVN] [gnurl] 168/256: vtls: fix memory corruption, gnunet, 2017/10/06
- [GNUnet-SVN] [gnurl] 170/256: OpenSSL: fix yet another mistake while encapsulating SSL backend data, gnunet, 2017/10/06
- [GNUnet-SVN] [gnurl] 206/256: cookies: reject oversized cookies, gnunet, 2017/10/06
- [GNUnet-SVN] [gnurl] 176/256: ossfuzz: add some more handled CURL options, gnunet, 2017/10/06
- [GNUnet-SVN] [gnurl] 155/256: fixup data/test1135, gnunet, 2017/10/06
- [GNUnet-SVN] [gnurl] 200/256: conversions: fix several compiler warnings, gnunet, 2017/10/06
- [GNUnet-SVN] [gnurl] 239/256: Set and use more necessary options when some protocols are disabled,
gnunet <=
- [GNUnet-SVN] [gnurl] 173/256: configure: fix curl_off_t check's include order, gnunet, 2017/10/06
- [GNUnet-SVN] [gnurl] 181/256: Curl_checkheaders: make it available for IMAP and SMTP too, gnunet, 2017/10/06
- [GNUnet-SVN] [gnurl] 250/256: proxy: read the "no_proxy" variable only if necessary, gnunet, 2017/10/06
- [GNUnet-SVN] [gnurl] 191/256: URL: on connection re-use, still pick the new remote port, gnunet, 2017/10/06
- [GNUnet-SVN] [gnurl] 192/256: test1150: verify same host fetch using different ports over proxy, gnunet, 2017/10/06
- [GNUnet-SVN] [gnurl] 199/256: server/getpart: provide dummy function to build conversion enabled, gnunet, 2017/10/06
- [GNUnet-SVN] [gnurl] 230/256: RELEASE-NOTES: synced with d8ab5dc50, gnunet, 2017/10/06
- [GNUnet-SVN] [gnurl] 134/256: headers: move the global_sslset() proto from multi.h to curl.h, gnunet, 2017/10/06
- [GNUnet-SVN] [gnurl] 190/256: RELEASE-NOTES: synced with 87501e57f, gnunet, 2017/10/06
- [GNUnet-SVN] [gnurl] 252/256: idn: fix source code comment, gnunet, 2017/10/06