From b7d7804240753b3b182f091431b447df71629d9f Mon Sep 17 00:00:00 2001 From: Ryan Boren Date: Fri, 1 Aug 2008 21:24:03 +0000 Subject: [PATCH] Various http fixes from santosj. see #4779 git-svn-id: https://develop.svn.wordpress.org/trunk@8522 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-includes/http.php | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/wp-includes/http.php b/wp-includes/http.php index 63b06ea2b9..a98cb18caa 100644 --- a/wp-includes/http.php +++ b/wp-includes/http.php @@ -536,7 +536,7 @@ class WP_Http_Fopen { if ( 'http' != $arrURL['scheme'] || 'https' != $arrURL['scheme'] ) $url = str_replace($arrURL['scheme'], 'http', $url); - $handle = fopen($url, 'rb'); + $handle = fopen($url, 'r'); if (! $handle) return new WP_Error('http_request_failed', sprintf(__('Could not open handle for fopen() to %s'), $url)); @@ -553,8 +553,6 @@ class WP_Http_Fopen { while ( ! feof($handle) ) $strResponse .= fread($handle, 4096); - fclose($handle); - $theHeaders = ''; if ( function_exists('stream_get_meta_data') ) { $meta = stream_get_meta_data($handle); @@ -564,6 +562,7 @@ class WP_Http_Fopen { } $processedHeaders = WP_Http::processHeaders($theHeaders); + fclose($handle); return array('headers' => $processedHeaders['headers'], 'body' => $strResponse, 'response' => $processedHeaders['response']); } @@ -635,9 +634,9 @@ class WP_Http_Streams { $context = stream_context_create($arrContext); - $handle = fopen($url, 'rb', false, $context); + $handle = fopen($url, 'r', false, $context); - stream_set_timeout($handle, apply_filters('http_request_stream_timeout', $this->timeout) ); + stream_set_timeout($handle, apply_filters('http_request_stream_timeout', $r['timeout']) ); if ( ! $handle) return new WP_Error('http_request_failed', sprintf(__('Could not open handle for fopen() to %s'), $url)); @@ -747,7 +746,7 @@ class WP_Http_ExtHTTP { 'timeout' => $r['timeout'], 'connecttimeout' => $r['timeout'], 'redirect' => $r['redirection'], - 'useragent' => $r['user_agent'], + 'useragent' => $r['user-agent'], 'headers' => $headers, ); @@ -849,9 +848,9 @@ class WP_Http_Curl { curl_setopt( $handle, CURLOPT_HTTPHEADER, $headers ); if ( $r['httpversion'] == '1.0' ) - curl_setopt( $headle, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0 ); + curl_setopt( $handle, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0 ); else - curl_setopt( $headle, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1 ); + curl_setopt( $handle, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1 ); if ( ! $r['blocking'] ) { curl_close( $handle ); @@ -1084,4 +1083,4 @@ function wp_remote_retrieve_body(&$response) { return $response['body']; } -?> +?> \ No newline at end of file