diff options
author | Daniel Stenberg <daniel@haxx.se> | 2011-04-14 22:45:42 +0200 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2011-04-18 19:46:21 +0200 |
commit | 8e4fb01e64bee1893452f25873758cb856898d84 (patch) | |
tree | 8b94999d472b201d98f1d72144a10d8afc8c6675 /lib | |
parent | ebb37eac8ba8caca5282c41635e491f19fe7df48 (diff) |
transfer-encoding: added new option and cmdline
Added CURLOPT_TRANSFER_ENCODING as the option to set to request Transfer
Encoding in HTTP requests (if built zlib enabled). I also renamed
CURLOPT_ENCODING to CURLOPT_ACCEPT_ENCODING (while keeping the old name
around) to reduce the confusion when we have to encoding options for
HTTP.
--tr-encoding is now the new command line option for curl to request
this, and thus I updated the test cases accordingly.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/http.c | 19 | ||||
-rw-r--r-- | lib/url.c | 6 | ||||
-rw-r--r-- | lib/urldata.h | 1 |
3 files changed, 19 insertions, 7 deletions
diff --git a/lib/http.c b/lib/http.c index 8d3a085d0..4f2b46a59 100644 --- a/lib/http.c +++ b/lib/http.c @@ -1733,21 +1733,28 @@ CURLcode Curl_http(struct connectdata *conn, bool *done) return CURLE_OUT_OF_MEMORY; } - if(Curl_checkheaders(data, "TE:")) { - /* When we insert a TE: header in the request, we must also insert TE in a - Connection: header, so we need to merge the custom provided Connection: - header and prevent the original to get sent */ +#ifdef HAVE_LIBZ + /* we only consider transfer-encoding magic if libz support is built-in */ + + if(!Curl_checkheaders(data, "TE:") && data->set.http_transfer_encoding) { + /* When we are to insert a TE: header in the request, we must also insert + TE in a Connection: header, so we need to merge the custom provided + Connection: header and prevent the original to get sent. Note that if + the user has inserted his/hers own TE: header we don't do this magic + but then assume that the user will handle it all! */ char *cptr = Curl_checkheaders(data, "Connection:"); +#define TE_HEADER "TE: gzip\r\n" Curl_safefree(conn->allocptr.te); /* Create the (updated) Connection: header */ - conn->allocptr.te = cptr? aprintf("%s, TE\r\n", cptr): - strdup("Connection: TE\r\n"); + conn->allocptr.te = cptr? aprintf("%s, TE\r\n" TE_HEADER, cptr): + strdup("Connection: TE\r\n" TE_HEADER); if(!conn->allocptr.te) return CURLE_OUT_OF_MEMORY; } +#endif ptr = Curl_checkheaders(data, "Transfer-Encoding:"); if(ptr) { @@ -1076,7 +1076,7 @@ CURLcode Curl_setopt(struct SessionHandle *data, CURLoption option, data->set.http_auto_referer = (bool)(0 != va_arg(param, long)); break; - case CURLOPT_ENCODING: + case CURLOPT_ACCEPT_ENCODING: /* * String to use at the value of Accept-Encoding header. * @@ -1092,6 +1092,10 @@ CURLcode Curl_setopt(struct SessionHandle *data, CURLoption option, (char *) ALL_CONTENT_ENCODINGS: argptr); break; + case CURLOPT_TRANSFER_ENCODING: + data->set.http_transfer_encoding = (bool)(0 != va_arg(param, long)); + break; + case CURLOPT_FOLLOWLOCATION: /* * Follow Location: header hints on a HTTP-server. diff --git a/lib/urldata.h b/lib/urldata.h index 33933b3e1..96814cfb5 100644 --- a/lib/urldata.h +++ b/lib/urldata.h @@ -1456,6 +1456,7 @@ struct UserDefined { bool hide_progress; /* don't use the progress meter */ bool http_fail_on_error; /* fail on HTTP error codes >= 300 */ bool http_follow_location; /* follow HTTP redirects */ + bool http_transfer_encoding; /* request compressed HTTP transfer-encoding */ bool http_disable_hostname_check_before_authentication; bool include_header; /* include received protocol headers in data output */ bool http_set_referer; /* is a custom referer used */ |