Vijay Panghal's patch implements a feature that I need for my project, so I am very glad that work is being done on it. I tested the patch and have a few comments. Just in case this email won't be assigned to a proper thread, I am replying to message http://curl.haxx.se/mail/lib-2014-01/0079.html . I have created a bug report regarding this issue, available at https://sourceforge.net/p/curl/bugs/1326/ . The link to the patch file is http://curl.haxx.se/mail/lib-2014-01/att-0079/0001-Http-Proxy-Option-to-set-header-for-http-proxy.patch
Comments: 1. The patch includes modifications to curl library, but not to the command line curl tool. I attach the patch that adds --proxy-header command line option. 2. I tested curl 7.34.0 with both patches applied, and I am happy to report that the feature worked as I expected. My tests involved curl tool, I did not use libcurl directly from within my program. 3. When --proxy-header option is absent, but --header is present, curl sends headers specified in --header to both proxy and the origin server (i.e. final destination of the request). In my opinion this is an incorrect and potentially dangerous behavior (please see my bug report for details). However, Vijay Panghal comments in his code that this is done for backward compatibility, and my testing confirms that without --proxy-header the behavior of curl matches the previous version. 4. Option --proxy-header is only used for CONNECT requests, i.e. when https URL is requested, or when --proxytunnel option is explicitly used. When proxying with GET/POST (typical for unencrypted requests), --proxy-header is ignored. While this is technically correct (only one set of headers is sent in such a case), this behavior may be confusing to the user. I suggest issuing a warning when --proxy-header is used for a request that is not tunneled. 5. A very minor issue that I noticed in the code: in file lib/http.c the second (newly added) argument to function Curl_add_custom_headers is named 'is_proxy', while in file lib/http.h it is named 'is_connect'. Thanks Maciej > Bump! > > I missed the 7.34 feature train for this patch. I would like to push it for > 7.35. Let me know if you guys have any comments. > > Regards > Vijay
diff -rup a/src/tool_cfgable.c b/src/tool_cfgable.c --- a/src/tool_cfgable.c 2013-10-23 15:55:34.000000000 -0500 +++ b/src/tool_cfgable.c 2014-01-23 10:48:49.000000000 -0600 @@ -114,6 +114,7 @@ void free_config_fields(struct Configura curl_slist_free_all(config->prequote); curl_slist_free_all(config->headers); + curl_slist_free_all(config->proxyheaders); if(config->httppost) { curl_formfree(config->httppost); diff -rup a/src/tool_cfgable.h b/src/tool_cfgable.h --- a/src/tool_cfgable.h 2013-12-16 16:02:35.000000000 -0600 +++ b/src/tool_cfgable.h 2014-01-23 10:48:33.000000000 -0600 @@ -156,6 +156,7 @@ struct Configurable { curl_TimeCond timecond; time_t condtime; struct curl_slist *headers; + struct curl_slist *proxyheaders; struct curl_httppost *httppost; struct curl_httppost *last_post; struct curl_slist *telnet_options; diff -rup a/src/tool_getparam.c b/src/tool_getparam.c --- a/src/tool_getparam.c 2013-12-16 16:02:35.000000000 -0600 +++ b/src/tool_getparam.c 2014-01-23 10:44:17.000000000 -0600 @@ -226,6 +226,7 @@ static const struct LongShort aliases[]= {"G", "get", FALSE}, {"h", "help", FALSE}, {"H", "header", TRUE}, + {"Hp", "proxy-header", TRUE}, {"i", "include", FALSE}, {"I", "head", FALSE}, {"j", "junk-session-cookies", FALSE}, @@ -1424,7 +1425,10 @@ ParameterError getparameter(char *flag, break; case 'H': /* A custom header to append to a list */ - err = add2list(&config->headers, nextarg); + if(subletter == 'p') /* --proxy-header */ + err = add2list(&config->proxyheaders, nextarg); + else + err = add2list(&config->headers, nextarg); if(err) return err; break; diff -rup a/src/tool_operate.c b/src/tool_operate.c --- a/src/tool_operate.c 2013-12-16 16:02:35.000000000 -0600 +++ b/src/tool_operate.c 2014-01-23 10:43:21.000000000 -0600 @@ -1086,6 +1086,9 @@ int operate(struct Configurable *config, my_setopt_str(curl, CURLOPT_USERAGENT, config->useragent); my_setopt_slist(curl, CURLOPT_HTTPHEADER, config->headers); + /* new in libcurl 7.35.0 */ + my_setopt_slist(curl, CURLOPT_PROXYHEADER, config->proxyheaders); + /* new in libcurl 7.5 */ my_setopt(curl, CURLOPT_MAXREDIRS, config->maxredirs);
------------------------------------------------------------------- List admin: http://cool.haxx.se/list/listinfo/curl-library Etiquette: http://curl.haxx.se/mail/etiquette.html