{"id":5666,"date":"2014-04-04T17:44:46","date_gmt":"2014-04-04T15:44:46","guid":{"rendered":"http:\/\/daniel.haxx.se\/blog\/?p=5666"},"modified":"2014-04-12T20:32:42","modified_gmt":"2014-04-12T18:32:42","slug":"curl-and-proxy-headers","status":"publish","type":"post","link":"https:\/\/daniel.haxx.se\/blog\/2014\/04\/04\/curl-and-proxy-headers\/","title":{"rendered":"curl and proxy headers"},"content":{"rendered":"<p>Starting in the next curl release, <strong>7.37.0<\/strong>, the curl tool supports the new command line option <a href=\"http:\/\/curl.haxx.se\/docs\/manpage.html#--proxy-header\">&#8211;proxy-header<\/a>. (Completely merged at <a href=\"https:\/\/github.com\/bagder\/curl\/commit\/c877c50e13ad4\">this commit<\/a>.)<\/p>\n<p>It works exactly like <a href=\"http:\/\/curl.haxx.se\/docs\/manpage.html#-H\"><strong>&#8211;header<\/strong><\/a> does, but will only include the headers in requests sent to a proxy, while the opposite is true for &#8211;header: that will only be sent in requests that will go to the end server. But of course, if you use a HTTP proxy and do a normal GET for example, curl will include headers for both the proxy and the server in the request. The bigger difference is when using CONNECT to a proxy, which then only will use proxy headers.<\/p>\n<h2>libcurl<\/h2>\n<p>For libcurl, the story is slightly different and more complicated since we&#8217;re having things backwards compatible there. The new libcurl still works exactly like the former one by default.<\/p>\n<p class=\"level0\"><a href=\"http:\/\/curl.haxx.se\/libcurl\/c\/curl_easy_setopt.html#CURLOPTPROXYHEADER\">CURLOPT_PROXYHEADER<\/a> is the new option that is the new proxy header option that should be set up exactly like <a name=\"CURLOPTHTTPHEADER\" href=\"http:\/\/curl.haxx.se\/libcurl\/c\/curl_easy_setopt.html#CURLOPTHTTPHEADER\"><\/a><span class=\"nroffip\"><a href=\"http:\/\/curl.haxx.se\/libcurl\/c\/curl_easy_setopt.html#CURLOPTHTTPHEADER\">CURLOPT_HTTPHEADER<\/a> is<\/span><\/p>\n<p class=\"level0\"><a name=\"CURLOPTHEADEROPT\" href=\"http:\/\/curl.haxx.se\/libcurl\/c\/curl_easy_setopt.html#CURLOPTHEADEROPT\"><\/a><a href=\"http:\/\/curl.haxx.se\/libcurl\/c\/curl_easy_setopt.html#CURLOPTHEADEROPT\"><span class=\"nroffip\">CURLOPT_HEADEROPT<\/span><\/a> is then what an application uses to set how libcurl should use the two header options. Again, by default libcurl will keep working like before and use the CURLOPT_HTTPHEADER list in all HTTP requests. To change that behavior and use the new functionality instead, set CURLOPT_HEADEROPT to CURLHEADER_SEPARATE.<\/p>\n<p class=\"level0\">Then, the header lists will be handled as separate. An application can then switch back to the old behavior with a unified header list by using CURLOPT_HEADEROPT set to CURLHEADER_UNIFIED.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Starting in the next curl release, 7.37.0, the curl tool supports the new command line option &#8211;proxy-header. (Completely merged at this commit.) It works exactly like &#8211;header does, but will only include the headers in requests sent to a proxy, while the opposite is true for &#8211;header: that will only be sent in requests that &hellip; <a href=\"https:\/\/daniel.haxx.se\/blog\/2014\/04\/04\/curl-and-proxy-headers\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">curl and proxy headers<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7,13,45],"tags":[33,230,316],"class_list":["post-5666","post","type-post","status-publish","format-standard","hentry","category-curl","category-net","category-web","tag-curl-and-libcurl","tag-http","tag-proxy"],"_links":{"self":[{"href":"https:\/\/daniel.haxx.se\/blog\/wp-json\/wp\/v2\/posts\/5666","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/daniel.haxx.se\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/daniel.haxx.se\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/daniel.haxx.se\/blog\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/daniel.haxx.se\/blog\/wp-json\/wp\/v2\/comments?post=5666"}],"version-history":[{"count":11,"href":"https:\/\/daniel.haxx.se\/blog\/wp-json\/wp\/v2\/posts\/5666\/revisions"}],"predecessor-version":[{"id":5676,"href":"https:\/\/daniel.haxx.se\/blog\/wp-json\/wp\/v2\/posts\/5666\/revisions\/5676"}],"wp:attachment":[{"href":"https:\/\/daniel.haxx.se\/blog\/wp-json\/wp\/v2\/media?parent=5666"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/daniel.haxx.se\/blog\/wp-json\/wp\/v2\/categories?post=5666"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/daniel.haxx.se\/blog\/wp-json\/wp\/v2\/tags?post=5666"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}