WP_Http_Encoding::should_decode() WordPress Method

The WP_Http_Encoding::should_decode() function is used to check if a string needs to be decoded before being sent to an HTTP request. This is useful for ensuring that data is correctly encoded before being sent to a server.

WP_Http_Encoding::should_decode( array|string $headers ) #

Whether the content be decoded based on the headers.


Parameters

$headers

(array|string)(Required)All of the available headers.


Top ↑

Return

(bool)


Top ↑

Source

File: wp-includes/class-wp-http-encoding.php

	public static function should_decode( $headers ) {
		if ( is_array( $headers ) ) {
			if ( array_key_exists( 'content-encoding', $headers ) && ! empty( $headers['content-encoding'] ) ) {
				return true;
			}
		} elseif ( is_string( $headers ) ) {
			return ( stripos( $headers, 'content-encoding:' ) !== false );
		}

		return false;
	}


Top ↑

Changelog

Changelog
VersionDescription
2.8.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.