Ticket #8787: 8787.diff
File 8787.diff, 2.6 KB (added by , 16 years ago) |
---|
-
http.php
257 257 } 258 258 259 259 if ( is_null($r['body']) ) { 260 // Some servers fail when sending content without the content-length 261 // header being set. 260 262 $r['headers']['Content-Length'] = 0; 261 263 $transports = WP_Http::_getTransport($r); 262 264 } else { … … 660 662 if ( false === $arrURL ) 661 663 return new WP_Error('http_request_failed', sprintf(__('Malformed URL: %s'), $url)); 662 664 663 if ( 'http' != $arrURL['scheme'] ||'https' != $arrURL['scheme'] )665 if ( 'http' != $arrURL['scheme'] && 'https' != $arrURL['scheme'] ) 664 666 $url = str_replace($arrURL['scheme'], 'http', $url); 665 667 666 668 if ( !defined('WP_DEBUG') || ( defined('WP_DEBUG') && false === WP_DEBUG ) ) … … 794 796 795 797 $context = stream_context_create($arrContext); 796 798 797 if ( ! defined('WP_DEBUG') || ( defined('WP_DEBUG') && false === WP_DEBUG ) )799 if ( ! defined('WP_DEBUG') || ( defined('WP_DEBUG') && false === WP_DEBUG ) ) 798 800 $handle = @fopen($url, 'r', false, $context); 799 801 else 800 802 $handle = fopen($url, 'r', false, $context); … … 999 1001 unset($r['headers']['user-agent']); 1000 1002 } 1001 1003 1002 // If timeout is a float less than 1, round it up to 1. 1004 // cURL extension will sometimes fail when the timeout is less than 1 as 1005 // it may round down to 0, which gives it unlimited timeout. 1003 1006 if ( $r['timeout'] > 0 && $r['timeout'] < 1 ) 1004 1007 $r['timeout'] = 1; 1005 1008 1006 1009 $handle = curl_init(); 1007 1010 curl_setopt( $handle, CURLOPT_URL, $url); 1008 1011 1012 // The cURL extension requires that the option be set for the HEAD to 1013 // work properly. 1009 1014 if ( 'HEAD' === $r['method'] ) { 1010 1015 curl_setopt( $handle, CURLOPT_NOBODY, true ); 1011 1016 } … … 1024 1029 curl_setopt( $handle, CURLOPT_TIMEOUT, $r['timeout'] ); 1025 1030 curl_setopt( $handle, CURLOPT_MAXREDIRS, $r['redirection'] ); 1026 1031 1032 // The option doesn't work with safe mode or when open_basedir is set. 1027 1033 if ( !ini_get('safe_mode') && !ini_get('open_basedir') ) 1028 1034 curl_setopt( $handle, CURLOPT_FOLLOWLOCATION, true ); 1029 1035 … … 1035 1041 else 1036 1042 curl_setopt( $handle, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1 ); 1037 1043 1044 // Cookies are not handled by the HTTP API currently. Allow for plugin 1045 // authors to handle it themselves... Although, it is somewhat pointless 1046 // without some reference. 1038 1047 do_action_ref_array( 'http_api_curl', array(&$handle) ); 1039 1048 1049 // We don't need to return the body, so don't. Just execution request 1050 // and return. 1040 1051 if ( ! $r['blocking'] ) { 1041 1052 curl_exec( $handle ); 1042 1053 curl_close( $handle );