Make WordPress Core

Opened 5 years ago

Last modified 5 years ago

#24182 closed defect (bug)

WP_Http_Fsockopen fails when requesting an IP based URL with an explicit Host header — at Initial Version

Reported by: friedcell Owned by:
Milestone: 3.7 Priority: normal
Severity: normal Version: 2.7
Component: HTTP API Keywords: needs-patch
Focuses: Cc:


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

wp_remote_post(): $url = $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 fwrite: POST /1.1/verify-key HTTP/1.0 Host: 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


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.

Change History (0)

Note: See TracTickets for help on using tickets.