[wp-trac] [WordPress Trac] #24182: WP_Http_Fsockopen fails when requesting an IP based URL with an explicit Host header

WordPress Trac noreply at wordpress.org
Wed Apr 24 22:50:41 UTC 2013


#24182: WP_Http_Fsockopen fails when requesting an IP based URL with an explicit
Host header
--------------------------+------------------------------
 Reporter:  friedcell     |       Owner:
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  Awaiting Review
Component:  HTTP          |     Version:  trunk
 Severity:  normal        |  Resolution:
 Keywords:                |
--------------------------+------------------------------
Description changed by SergeyBiryukov:

Old description:

> When requesting a resource with a IP based URL and an explicitly set Host
> header fsockopen fails.
>
> wp_remote_post():
> $url = http://72.233.69.89/1.1/verify-key
> $args = Array
> (
>     [body] => key=xxxxxxxxxxxx&blog=http%3A%2F%2Ffriedcell.si%2Foutbreak
>     [headers] => Array
>         (
>             [Content-Type] => application/x-www-form-urlencoded;
> charset=UTF-8
>             [Host] => rest.akismet.com
>             [User-Agent] => WordPress/3.5.1 | Akismet/2.5.7
>         )
>
>     [httpversion] => 1.0
>     [timeout] => 15
> )
>
> WP_Http_Fsockopen $strHeaders just before
> [http://core.trac.wordpress.org/browser/trunk/wp-includes/class-
> http.php#L729 fwrite]:
> POST /1.1/verify-key HTTP/1.0
> Host: 72.233.69.89
> User-agent: WordPress/3.5.1 | Akismet/2.5.7
> Content-Type: application/x-www-form-urlencoded; charset=UTF-8
> Host: rest.akismet.com
> Accept-Encoding: deflate;q=1.0, compress;q=0.5
> Content-Length: 58
>
> key=xxxxxxxxxxxx&blog=http%3A%2F%2Ffriedcell.si%2Foutbreak
>
> The request fails as the first Host header is used.
>
> When $arrURL!['host'] is an IP and there is a Host header in
> $r!['headers'], the Host header should not be added from the URL
> (http://core.trac.wordpress.org/browser/trunk/wp-includes/class-
> http.php#L706) so that the explicitly specified Host header is used.

New description:

 When requesting a resource with a IP based URL and an explicitly set Host
 header fsockopen fails.

 wp_remote_post():
 {{{
 $url = http://72.233.69.89/1.1/verify-key
 $args = Array
 (
     [body] => key=xxxxxxxxxxxx&blog=http%3A%2F%2Ffriedcell.si%2Foutbreak
     [headers] => Array
         (
             [Content-Type] => application/x-www-form-urlencoded;
 charset=UTF-8
             [Host] => rest.akismet.com
             [User-Agent] => WordPress/3.5.1 | Akismet/2.5.7
         )

     [httpversion] => 1.0
     [timeout] => 15
 )
 }}}
 WP_Http_Fsockopen $strHeaders just before
 [http://core.trac.wordpress.org/browser/trunk/wp-includes/class-
 http.php#L729 fwrite]:
 {{{
 POST /1.1/verify-key HTTP/1.0
 Host: 72.233.69.89
 User-agent: WordPress/3.5.1 | Akismet/2.5.7
 Content-Type: application/x-www-form-urlencoded; charset=UTF-8
 Host: rest.akismet.com
 Accept-Encoding: deflate;q=1.0, compress;q=0.5
 Content-Length: 58

 key=xxxxxxxxxxxx&blog=http%3A%2F%2Ffriedcell.si%2Foutbreak
 }}}
 The request fails as the first Host header is used.

 When $arrURL!['host'] is an IP and there is a Host header in
 $r!['headers'], the Host header should not be added from the URL
 (http://core.trac.wordpress.org/browser/trunk/wp-includes/class-
 http.php#L706) so that the explicitly specified Host header is used.

--

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/24182#comment:1>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list