113 $ssl_verify = isset( $parsed_args['sslverify'] ) && $parsed_args['sslverify']; |
113 $ssl_verify = isset( $parsed_args['sslverify'] ) && $parsed_args['sslverify']; |
114 if ( $is_local ) { |
114 if ( $is_local ) { |
115 /** This filter is documented in wp-includes/class-wp-http-streams.php */ |
115 /** This filter is documented in wp-includes/class-wp-http-streams.php */ |
116 $ssl_verify = apply_filters( 'https_local_ssl_verify', $ssl_verify, $url ); |
116 $ssl_verify = apply_filters( 'https_local_ssl_verify', $ssl_verify, $url ); |
117 } elseif ( ! $is_local ) { |
117 } elseif ( ! $is_local ) { |
118 /** This filter is documented in wp-includes/class-http.php */ |
118 /** This filter is documented in wp-includes/class-wp-http.php */ |
119 $ssl_verify = apply_filters( 'https_ssl_verify', $ssl_verify, $url ); |
119 $ssl_verify = apply_filters( 'https_ssl_verify', $ssl_verify, $url ); |
120 } |
120 } |
121 |
121 |
122 /* |
122 /* |
123 * CURLOPT_TIMEOUT and CURLOPT_CONNECTTIMEOUT expect integers. Have to use ceil since. |
123 * CURLOPT_TIMEOUT and CURLOPT_CONNECTTIMEOUT expect integers. Have to use ceil since. |
254 'cookies' => array(), |
254 'cookies' => array(), |
255 ); |
255 ); |
256 } |
256 } |
257 |
257 |
258 curl_exec( $handle ); |
258 curl_exec( $handle ); |
259 $theHeaders = WP_Http::processHeaders( $this->headers, $url ); |
259 |
260 $theBody = $this->body; |
260 $processed_headers = WP_Http::processHeaders( $this->headers, $url ); |
|
261 $body = $this->body; |
261 $bytes_written_total = $this->bytes_written_total; |
262 $bytes_written_total = $this->bytes_written_total; |
262 |
263 |
263 $this->headers = ''; |
264 $this->headers = ''; |
264 $this->body = ''; |
265 $this->body = ''; |
265 $this->bytes_written_total = 0; |
266 $this->bytes_written_total = 0; |
266 |
267 |
267 $curl_error = curl_errno( $handle ); |
268 $curl_error = curl_errno( $handle ); |
268 |
269 |
269 // If an error occurred, or, no response. |
270 // If an error occurred, or, no response. |
270 if ( $curl_error || ( 0 == strlen( $theBody ) && empty( $theHeaders['headers'] ) ) ) { |
271 if ( $curl_error || ( 0 === strlen( $body ) && empty( $processed_headers['headers'] ) ) ) { |
271 if ( CURLE_WRITE_ERROR /* 23 */ == $curl_error ) { |
272 if ( CURLE_WRITE_ERROR /* 23 */ === $curl_error ) { |
272 if ( ! $this->max_body_length || $this->max_body_length != $bytes_written_total ) { |
273 if ( ! $this->max_body_length || $this->max_body_length !== $bytes_written_total ) { |
273 if ( $parsed_args['stream'] ) { |
274 if ( $parsed_args['stream'] ) { |
274 curl_close( $handle ); |
275 curl_close( $handle ); |
275 fclose( $this->stream_handle ); |
276 fclose( $this->stream_handle ); |
276 return new WP_Error( 'http_request_failed', __( 'Failed to write request to temporary file.' ) ); |
277 return new WP_Error( 'http_request_failed', __( 'Failed to write request to temporary file.' ) ); |
277 } else { |
278 } else { |
297 if ( $parsed_args['stream'] ) { |
298 if ( $parsed_args['stream'] ) { |
298 fclose( $this->stream_handle ); |
299 fclose( $this->stream_handle ); |
299 } |
300 } |
300 |
301 |
301 $response = array( |
302 $response = array( |
302 'headers' => $theHeaders['headers'], |
303 'headers' => $processed_headers['headers'], |
303 'body' => null, |
304 'body' => null, |
304 'response' => $theHeaders['response'], |
305 'response' => $processed_headers['response'], |
305 'cookies' => $theHeaders['cookies'], |
306 'cookies' => $processed_headers['cookies'], |
306 'filename' => $parsed_args['filename'], |
307 'filename' => $parsed_args['filename'], |
307 ); |
308 ); |
308 |
309 |
309 // Handle redirects. |
310 // Handle redirects. |
310 $redirect_response = WP_HTTP::handle_redirects( $url, $parsed_args, $response ); |
311 $redirect_response = WP_Http::handle_redirects( $url, $parsed_args, $response ); |
311 if ( false !== $redirect_response ) { |
312 if ( false !== $redirect_response ) { |
312 return $redirect_response; |
313 return $redirect_response; |
313 } |
314 } |
314 |
315 |
315 if ( true === $parsed_args['decompress'] && true === WP_Http_Encoding::should_decode( $theHeaders['headers'] ) ) { |
316 if ( true === $parsed_args['decompress'] |
316 $theBody = WP_Http_Encoding::decompress( $theBody ); |
317 && true === WP_Http_Encoding::should_decode( $processed_headers['headers'] ) |
317 } |
318 ) { |
318 |
319 $body = WP_Http_Encoding::decompress( $body ); |
319 $response['body'] = $theBody; |
320 } |
|
321 |
|
322 $response['body'] = $body; |
320 |
323 |
321 return $response; |
324 return $response; |
322 } |
325 } |
323 |
326 |
324 /** |
327 /** |