WC_API_Server::get_headers( array $server )

Extract headers from a PHP-style $_SERVER array


Description Description


Parameters Parameters

$server

(Required) Associative array similar to $_SERVER


Top ↑

Return Return

(array) Headers extracted from the input


Top ↑

Source Source

File: includes/legacy/api/v2/class-wc-api-server.php

	public function get_headers( $server ) {
		$headers = array();
		// CONTENT_* headers are not prefixed with HTTP_
		$additional = array( 'CONTENT_LENGTH' => true, 'CONTENT_MD5' => true, 'CONTENT_TYPE' => true );

		foreach ( $server as $key => $value ) {
			if ( strpos( $key, 'HTTP_' ) === 0 ) {
				$headers[ substr( $key, 5 ) ] = $value;
			} elseif ( isset( $additional[ $key ] ) ) {
				$headers[ $key ] = $value;
			}
		}

		return $headers;
	}

Top ↑

Changelog Changelog

Changelog
Version Description
2.1 Introduced.


Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.