wppaste
WordPress

WP_HTTP_Requests_Response

Since
4.6.0
Source
wp-includes/class-wp-http-requests-response.php:17
Core wrapper object for a WpOrg\Requests\Response for standardization.

Compatibility

WordPress
since 4.6.0
  • 6.7.7
  • 6.8.8
  • 6.9.7
  • 7.0.4
  • 7.1.0

Present in every tracked release (6.7.7 to 7.1.0).

Properties · 2

$responseWpOrg\Requests\Responseprotected
Requests Response object.
$filenamestring|nullprotected
Filename the response was saved to.

Methods · 11

Source code

class WP_HTTP_Requests_Response extends WP_HTTP_Response {	/**	 * Requests Response object.	 *	 * @since 4.6.0	 * @var \WpOrg\Requests\Response	 */	protected $response; 	/**	 * Filename the response was saved to.	 *	 * @since 4.6.0	 * @var string|null	 */	protected $filename; 	/**	 * Constructor.	 *	 * @since 4.6.0	 *	 * @param \WpOrg\Requests\Response $response HTTP response.	 * @param string                   $filename Optional. File name. Default empty.	 */	public function __construct( WpOrg\Requests\Response $response, $filename = '' ) {		$this->response = $response;		$this->filename = $filename;	} 	/**	 * Retrieves the response object for the request.	 *	 * @since 4.6.0	 *	 * @return WpOrg\Requests\Response HTTP response.	 */	public function get_response_object() {		return $this->response;	} 	/**	 * Retrieves headers associated with the response.	 *	 * @since 4.6.0	 *	 * @return \WpOrg\Requests\Utility\CaseInsensitiveDictionary Map of header name to header value.	 */	public function get_headers() {		// Ensure headers remain case-insensitive.		$converted = new WpOrg\Requests\Utility\CaseInsensitiveDictionary(); 		foreach ( $this->response->headers->getAll() as $key => $value ) {			if ( count( $value ) === 1 ) {				$converted[ $key ] = $value[0];			} else {				$converted[ $key ] = $value;			}		} 		return $converted;	} 	/**	 * Sets all header values.	 *	 * @since 4.6.0	 *	 * @param array $headers Map of header name to header value.	 */	public function set_headers( $headers ) {		$this->response->headers = new WpOrg\Requests\Response\Headers( $headers );	} 	/**	 * Sets a single HTTP header.	 *	 * @since 4.6.0	 *	 * @param string $key     Header name.

Changelog

Introduced in 4.6.0. Unchanged from 6.7.7 through 7.1.0.

  1. 6.7.7
  2. 6.8.8
  3. 6.9.7
  4. 7.0.4
  5. 7.1.0

Signature, return type and hooks compared across 5 parsed releases.

About this page

Parsed data
Generated from the wordpress-develop 6.8.8 tag, from src/wp-includes/class-wp-http-requests-response.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it.
Corrections
Something wrong on this page? Report it and it gets fixed in the next regeneration.