Changeset 25303
- Timestamp:
- 09/09/2013 01:17:17 AM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/class-http.php
r25225 r25303 865 865 } 866 866 867 if ( isset( $r['limit_response_size'] ) && ( $bytes_written + strlen( $block ) ) > $r['limit_response_size'] ) 867 $this_block_size = strlen( $block ); 868 869 if ( isset( $r['limit_response_size'] ) && ( $bytes_written + $this_block_size ) > $r['limit_response_size'] ) 868 870 $block = substr( $block, 0, ( $r['limit_response_size'] - $bytes_written ) ); 869 871 870 $bytes_written += fwrite( $stream_handle, $block ); 872 $bytes_written_to_file = fwrite( $stream_handle, $block ); 873 874 if ( $bytes_written_to_file != $this_block_size ) { 875 fclose( $handle ); 876 fclose( $stream_handle ); 877 return new WP_Error( 'http_request_failed', __( 'Failed to write request to temporary file.' ) ); 878 } 879 880 $bytes_written += $bytes_written_to_file; 871 881 872 882 $keep_reading = !isset( $r['limit_response_size'] ) || $bytes_written < $r['limit_response_size']; … … 1230 1240 $this->body = ''; 1231 1241 1232 // If no response 1233 if ( 0 == strlen( $theBody ) && empty( $theHeaders['headers'] ) ) { 1242 $curl_error = curl_errno( $handle ); 1243 1244 // If an error occured, or, no response 1245 if ( $curl_error || ( 0 == strlen( $theBody ) && empty( $theHeaders['headers'] ) ) ) { 1246 if ( CURLE_WRITE_ERROR /* 23 */ == $curl_error && $r['stream'] ) { 1247 fclose( $this->stream_handle ); 1248 return new WP_Error( 'http_request_failed', __( 'Failed to write request to temporary file.' ) ); 1249 } 1234 1250 if ( $curl_error = curl_error( $handle ) ) { 1235 1251 curl_close( $handle ); … … 1301 1317 } 1302 1318 1303 if ( $this->max_body_length && ( strlen( $this->body ) + strlen( $data ) ) > $this->max_body_length ) 1304 $data = substr( $data, 0, ( $this->max_body_length - strlen( $this->body ) ) ); 1305 1306 if ( $this->stream_handle ) 1307 fwrite( $this->stream_handle, $data ); 1308 else 1319 $data_length = strlen( $data ); 1320 1321 if ( $this->max_body_length && ( strlen( $this->body ) + $data_length ) > $this->max_body_length ) 1322 $data = substr( $data, 0, ( $this->max_body_length - $data_length ) ); 1323 1324 if ( $this->stream_handle ) { 1325 $bytes_written = fwrite( $this->stream_handle, $data ); 1326 } else { 1309 1327 $this->body .= $data; 1310 1311 $data_length = strlen( $data );1328 $bytes_written = $data_length; 1329 } 1312 1330 1313 1331 if ( isset( $mb_encoding ) ) 1314 1332 mb_internal_encoding( $mb_encoding ); 1315 1333 1316 return $data_length; 1334 // Upon event of this function returning less than strlen( $data ) curl will error with CURLE_WRITE_ERROR 1335 return $bytes_written; 1317 1336 } 1318 1337
Note: See TracChangeset
for help on using the changeset viewer.