Ticket #16236: 16236.diff
| File 16236.diff, 5.5 KB (added by , 15 years ago) |
|---|
-
wp-includes/class-http.php
227 227 'body' => null, 228 228 'compress' => false, 229 229 'decompress' => true, 230 'sslverify' => true 230 'sslverify' => true, 231 'stream' => false, 232 'filename' => false 231 233 ); 232 234 233 235 $r = wp_parse_args( $args, $defaults ); … … 255 257 $r['local'] = $homeURL['host'] == $arrURL['host'] || 'localhost' == $arrURL['host']; 256 258 unset( $homeURL ); 257 259 260 if ( $r['stream'] && ! $r['filename'] ) 261 $r['filename'] = basename( $url ); 262 263 if ( $r['stream'] ) { 264 $r['blocking'] = true; 265 $r['method'] = 'GET'; 266 } 267 258 268 if ( is_null( $r['headers'] ) ) 259 269 $r['headers'] = array(); 260 270 … … 1291 1301 */ 1292 1302 class WP_Http_Curl { 1293 1303 1304 private $headers; 1305 1294 1306 /** 1295 1307 * Send a HTTP request to a URI using cURL extension. 1296 1308 * … … 1387 1399 else 1388 1400 curl_setopt( $handle, CURLOPT_HEADER, false ); 1389 1401 1402 if ( $r['stream'] ) { 1403 $stream_handle = fopen( get_temp_dir() . $r['filename'], 'w+' ); 1404 curl_setopt( $handle, CURLOPT_FILE, $stream_handle ); 1405 curl_setopt( $handle, CURLOPT_HEADERFUNCTION, array( &$this, 'stream_headers' ) ); 1406 } 1407 1390 1408 // The option doesn't work with safe mode or when open_basedir is set. 1391 1409 // Disable HEAD when making HEAD requests. 1392 1410 if ( !ini_get('safe_mode') && !ini_get('open_basedir') && 'HEAD' != $r['method'] ) … … 1421 1439 1422 1440 if ( !empty($theResponse) ) { 1423 1441 $headerLength = curl_getinfo($handle, CURLINFO_HEADER_SIZE); 1424 $theHeaders = trim( substr($theResponse, 0, $headerLength) ); 1425 if ( strlen($theResponse) > $headerLength ) 1426 $theBody = substr( $theResponse, $headerLength ); 1427 else 1442 if ( ! empty( $this->headers ) ) { 1443 $theHeaders = $this->headers; 1428 1444 $theBody = ''; 1429 if ( false !== strpos($theHeaders, "\r\n\r\n") ) { 1430 $headerParts = explode("\r\n\r\n", $theHeaders); 1431 $theHeaders = $headerParts[ count($headerParts) -1 ]; 1445 } else { 1446 $theHeaders = trim( substr($theResponse, 0, $headerLength) ); 1447 if ( strlen($theResponse) > $headerLength ) 1448 $theBody = substr( $theResponse, $headerLength ); 1449 else 1450 $theBody = ''; 1451 if ( false !== strpos($theHeaders, "\r\n\r\n") ) { 1452 $headerParts = explode("\r\n\r\n", $theHeaders); 1453 $theHeaders = $headerParts[ count($headerParts) -1 ]; 1454 } 1432 1455 } 1433 1456 $theHeaders = WP_Http::processHeaders($theHeaders); 1434 1457 } else { … … 1462 1485 return array('headers' => $theHeaders['headers'], 'body' => $theBody, 'response' => $response, 'cookies' => $theHeaders['cookies']); 1463 1486 } 1464 1487 1488 function stream_headers( $handle, $headers ) { 1489 $this->headers .= $headers; 1490 return strlen($headers); 1491 } 1492 1465 1493 /** 1466 1494 * Whether this class can be used for retrieving an URL. 1467 1495 * -
wp-includes/functions.php
2111 2111 } 2112 2112 2113 2113 /** 2114 * Determines a writable directory for temporary files. 2115 * Function's preference is to WP_CONTENT_DIR followed by the return value of <code>sys_get_temp_dir()</code>, before finally defaulting to /tmp/ 2116 * 2117 * In the event that this function does not find a writable location, It may be overridden by the <code>WP_TEMP_DIR</code> constant in your <code>wp-config.php</code> file. 2118 * 2119 * @since 2.5.0 2120 * 2121 * @return string Writable temporary directory 2122 */ 2123 function get_temp_dir() { 2124 static $temp; 2125 if ( defined('WP_TEMP_DIR') ) 2126 return trailingslashit(WP_TEMP_DIR); 2127 2128 if ( $temp ) 2129 return trailingslashit($temp); 2130 2131 $temp = WP_CONTENT_DIR . '/'; 2132 if ( is_dir($temp) && @is_writable($temp) ) 2133 return $temp; 2134 2135 if ( function_exists('sys_get_temp_dir') ) { 2136 $temp = sys_get_temp_dir(); 2137 if ( @is_writable($temp) ) 2138 return trailingslashit($temp); 2139 } 2140 2141 $temp = ini_get('upload_tmp_dir'); 2142 if ( is_dir($temp) && @is_writable($temp) ) 2143 return trailingslashit($temp); 2144 2145 $temp = '/tmp/'; 2146 return $temp; 2147 } 2148 2149 /** 2114 2150 * Get an array containing the current upload directory's path and url. 2115 2151 * 2116 2152 * Checks the 'upload_path' option, which should be from the web root folder, -
wp-admin/includes/file.php
153 153 } 154 154 155 155 /** 156 * Determines a writable directory for temporary files.157 * Function's preference is to WP_CONTENT_DIR followed by the return value of <code>sys_get_temp_dir()</code>, before finally defaulting to /tmp/158 *159 * In the event that this function does not find a writable location, It may be overridden by the <code>WP_TEMP_DIR</code> constant in your <code>wp-config.php</code> file.160 *161 * @since 2.5.0162 *163 * @return string Writable temporary directory164 */165 function get_temp_dir() {166 static $temp;167 if ( defined('WP_TEMP_DIR') )168 return trailingslashit(WP_TEMP_DIR);169 170 if ( $temp )171 return trailingslashit($temp);172 173 $temp = WP_CONTENT_DIR . '/';174 if ( is_dir($temp) && @is_writable($temp) )175 return $temp;176 177 if ( function_exists('sys_get_temp_dir') ) {178 $temp = sys_get_temp_dir();179 if ( @is_writable($temp) )180 return trailingslashit($temp);181 }182 183 $temp = ini_get('upload_tmp_dir');184 if ( is_dir($temp) && @is_writable($temp) )185 return trailingslashit($temp);186 187 $temp = '/tmp/';188 return $temp;189 }190 191 /**192 156 * Returns a filename of a Temporary unique file. 193 157 * Please note that the calling function must unlink() this itself. 194 158 *