Fix issues with fsockopen transport. Props santosj. see #4779

git-svn-id: https://develop.svn.wordpress.org/trunk@8586 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Ryan Boren 2008-08-08 00:02:11 +00:00
parent 7d0bd55969
commit 5fb79ce141

View File

@ -125,10 +125,10 @@ class WP_Http {
if ( is_null($working_transport) ) { if ( is_null($working_transport) ) {
if ( true === WP_Http_ExtHttp::test() && apply_filters('use_http_extension_transport', true) ) if ( true === WP_Http_ExtHttp::test() && apply_filters('use_http_extension_transport', true) )
$working_transport[] = new WP_Http_ExtHttp(); $working_transport[] = new WP_Http_ExtHttp();
else if ( true === WP_Http_Streams::test() && apply_filters('use_streams_transport', true) )
$working_transport[] = new WP_Http_Streams();
else if ( true === WP_Http_Fsockopen::test() && apply_filters('use_fsockopen_transport', true) ) else if ( true === WP_Http_Fsockopen::test() && apply_filters('use_fsockopen_transport', true) )
$working_transport[] = new WP_Http_Fsockopen(); $working_transport[] = new WP_Http_Fsockopen();
else if ( true === WP_Http_Streams::test() && apply_filters('use_streams_transport', true) )
$working_transport[] = new WP_Http_Streams();
} }
return $working_transport; return $working_transport;
@ -195,7 +195,12 @@ class WP_Http {
$headers = $processedHeaders['headers']; $headers = $processedHeaders['headers'];
} }
if ( ! isset($headers['user-agent']) || ! isset($headers['User-Agent']) ) if ( isset($headers['User-Agent']) ) {
$headers['user-agent'] = $headers['User-Agent'];
unset($headers['User-Agent']);
}
if ( ! isset($headers['user-agent']) )
$headers['user-agent'] = $r['user-agent']; $headers['user-agent'] = $r['user-agent'];
if ( is_null($body) ) { if ( is_null($body) ) {
@ -441,11 +446,11 @@ class WP_Http_Fsockopen {
$strHeaders .= strtoupper($r['method']) . ' ' . $requestPath . ' HTTP/' . $r['httpversion'] . "\r\n"; $strHeaders .= strtoupper($r['method']) . ' ' . $requestPath . ' HTTP/' . $r['httpversion'] . "\r\n";
$strHeaders .= 'Host: ' . $arrURL['host'] . "\r\n"; $strHeaders .= 'Host: ' . $arrURL['host'] . "\r\n";
if ( is_array($header) ) { if ( is_array($headers) ) {
foreach ( (array) $this->getHeaders() as $header => $headerValue ) foreach ( (array) $headers as $header => $headerValue )
$strHeaders .= $header . ': ' . $headerValue . "\r\n"; $strHeaders .= $header . ': ' . $headerValue . "\r\n";
} else { } else {
$strHeaders .= $header; $strHeaders .= $headers;
} }
$strHeaders .= "\r\n"; $strHeaders .= "\r\n";