WP_HTTP_Requests_Response::get_headers() WordPress Method

The get_headers() method in the WP_HTTP_Requests_Response class is used to get the HTTP headers from the response.

WP_HTTP_Requests_Response::get_headers() #

Retrieves headers associated with the response.


Return

(Requests_Utility_CaseInsensitiveDictionary) Map of header name to header value.


Top ↑

Source

File: wp-includes/class-wp-http-requests-response.php

	public function get_headers() {
		// Ensure headers remain case-insensitive.
		$converted = new 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;
	}


Top ↑

Changelog

Changelog
VersionDescription
4.6.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.