wip
This commit is contained in:
@@ -240,16 +240,27 @@ class WP_Http_Curl {
|
||||
curl_exec( $handle );
|
||||
|
||||
$curl_error = curl_error( $handle );
|
||||
|
||||
if ( $curl_error ) {
|
||||
curl_close( $handle );
|
||||
if ( PHP_VERSION_ID < 80000 ) { // curl_close() has no effect as of PHP 8.0.
|
||||
curl_close( $handle );
|
||||
}
|
||||
|
||||
return new WP_Error( 'http_request_failed', $curl_error );
|
||||
}
|
||||
|
||||
if ( in_array( curl_getinfo( $handle, CURLINFO_HTTP_CODE ), array( 301, 302 ), true ) ) {
|
||||
curl_close( $handle );
|
||||
if ( PHP_VERSION_ID < 80000 ) { // curl_close() has no effect as of PHP 8.0.
|
||||
curl_close( $handle );
|
||||
}
|
||||
|
||||
return new WP_Error( 'http_request_failed', __( 'Too many redirects.' ) );
|
||||
}
|
||||
|
||||
curl_close( $handle );
|
||||
if ( PHP_VERSION_ID < 80000 ) { // curl_close() has no effect as of PHP 8.0.
|
||||
curl_close( $handle );
|
||||
}
|
||||
|
||||
return array(
|
||||
'headers' => array(),
|
||||
'body' => '',
|
||||
@@ -278,28 +289,45 @@ class WP_Http_Curl {
|
||||
if ( CURLE_WRITE_ERROR /* 23 */ === $curl_error ) {
|
||||
if ( ! $this->max_body_length || $this->max_body_length !== $bytes_written_total ) {
|
||||
if ( $parsed_args['stream'] ) {
|
||||
curl_close( $handle );
|
||||
if ( PHP_VERSION_ID < 80000 ) { // curl_close() has no effect as of PHP 8.0.
|
||||
curl_close( $handle );
|
||||
}
|
||||
|
||||
fclose( $this->stream_handle );
|
||||
|
||||
return new WP_Error( 'http_request_failed', __( 'Failed to write request to temporary file.' ) );
|
||||
} else {
|
||||
curl_close( $handle );
|
||||
if ( PHP_VERSION_ID < 80000 ) { // curl_close() has no effect as of PHP 8.0.
|
||||
curl_close( $handle );
|
||||
}
|
||||
|
||||
return new WP_Error( 'http_request_failed', curl_error( $handle ) );
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$curl_error = curl_error( $handle );
|
||||
|
||||
if ( $curl_error ) {
|
||||
curl_close( $handle );
|
||||
if ( PHP_VERSION_ID < 80000 ) { // curl_close() has no effect as of PHP 8.0.
|
||||
curl_close( $handle );
|
||||
}
|
||||
|
||||
return new WP_Error( 'http_request_failed', $curl_error );
|
||||
}
|
||||
}
|
||||
|
||||
if ( in_array( curl_getinfo( $handle, CURLINFO_HTTP_CODE ), array( 301, 302 ), true ) ) {
|
||||
curl_close( $handle );
|
||||
if ( PHP_VERSION_ID < 80000 ) { // curl_close() has no effect as of PHP 8.0.
|
||||
curl_close( $handle );
|
||||
}
|
||||
|
||||
return new WP_Error( 'http_request_failed', __( 'Too many redirects.' ) );
|
||||
}
|
||||
}
|
||||
|
||||
curl_close( $handle );
|
||||
if ( PHP_VERSION_ID < 80000 ) { // curl_close() has no effect as of PHP 8.0.
|
||||
curl_close( $handle );
|
||||
}
|
||||
|
||||
if ( $parsed_args['stream'] ) {
|
||||
fclose( $this->stream_handle );
|
||||
|
||||
Reference in New Issue
Block a user