[wp-trac] [WordPress Trac] #34053: HTTP API (Curl backend) inappropriately sends Content-Length header on POST requests made through a proxy server CONNECT

WordPress Trac noreply at wordpress.org
Tue Nov 17 20:05:37 UTC 2015


#34053: HTTP API (Curl backend) inappropriately sends Content-Length header on POST
requests made through a proxy server CONNECT
--------------------------+------------------------------
 Reporter:  petertvs      |       Owner:
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  Awaiting Review
Component:  HTTP API      |     Version:  4.3.1
 Severity:  normal        |  Resolution:
 Keywords:                |     Focuses:  administration
--------------------------+------------------------------

Comment (by awbauer):

 Actually, just discovered that tapping into the `http_api_curl` action
 provides a functioning workaround.

 {{{#!php
 <?php
 function bu_http_api_curl( $handle, $r, $url ) {
         if ( ! empty( $r['body'] ) || 'POST' == $r['method'] || 'PUT' ==
 $r['method'] ) {
                 unset($r['headers']['Content-Length']);
                 curl_setopt( $handle, CURLOPT_HTTPHEADER, $r['headers'] );
         }
 }
 add_action( 'http_api_curl', 'bu_http_api_curl', 10, 3 );
 }}}

--
Ticket URL: <https://core.trac.wordpress.org/ticket/34053#comment:3>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list