HTTP API: Ensure the http_api_debug
hook is fired for all responses.
This means that logging and debugging functionality can access the error code and error message for erroneous responses under all conditions. The hook is not fired when a request is short-circuited with the `pre_http_request` filter, because this filter itself can be used in that situation. Fixes #25747 git-svn-id: https://develop.svn.wordpress.org/trunk@45504 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
c14ea1630f
commit
ea0a34c649
@ -272,11 +272,17 @@ class WP_Http {
|
|||||||
$arrURL = @parse_url( $url );
|
$arrURL = @parse_url( $url );
|
||||||
|
|
||||||
if ( empty( $url ) || empty( $arrURL['scheme'] ) ) {
|
if ( empty( $url ) || empty( $arrURL['scheme'] ) ) {
|
||||||
return new WP_Error( 'http_request_failed', __( 'A valid URL was not provided.' ) );
|
$response = new WP_Error( 'http_request_failed', __( 'A valid URL was not provided.' ) );
|
||||||
|
/** This action is documented in wp-includes/class-http.php */
|
||||||
|
do_action( 'http_api_debug', $response, 'response', 'Requests', $r, $url );
|
||||||
|
return $response;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( $this->block_request( $url ) ) {
|
if ( $this->block_request( $url ) ) {
|
||||||
return new WP_Error( 'http_request_failed', __( 'User has blocked requests through HTTP.' ) );
|
$response = new WP_Error( 'http_request_not_executed', __( 'User has blocked requests through HTTP.' ) );
|
||||||
|
/** This action is documented in wp-includes/class-http.php */
|
||||||
|
do_action( 'http_api_debug', $response, 'response', 'Requests', $r, $url );
|
||||||
|
return $response;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we are streaming to a file but no filename was given drop it in the WP temp dir
|
// If we are streaming to a file but no filename was given drop it in the WP temp dir
|
||||||
@ -289,7 +295,10 @@ class WP_Http {
|
|||||||
// Force some settings if we are streaming to a file and check for existence and perms of destination directory
|
// Force some settings if we are streaming to a file and check for existence and perms of destination directory
|
||||||
$r['blocking'] = true;
|
$r['blocking'] = true;
|
||||||
if ( ! wp_is_writable( dirname( $r['filename'] ) ) ) {
|
if ( ! wp_is_writable( dirname( $r['filename'] ) ) ) {
|
||||||
return new WP_Error( 'http_request_failed', __( 'Destination directory for file streaming does not exist or is not writable.' ) );
|
$response = new WP_Error( 'http_request_failed', __( 'Destination directory for file streaming does not exist or is not writable.' ) );
|
||||||
|
/** This action is documented in wp-includes/class-http.php */
|
||||||
|
do_action( 'http_api_debug', $response, 'response', 'Requests', $r, $url );
|
||||||
|
return $response;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user