HTTP API: Fix request header inconsistencies.
This changeset improves the consistency in capitalization of fetching and outputting of request headers. It also updates occurrences found in some docblocks. Props johnjamesjacoby, costdev, audrasjb, petitphp, mhkuu, SergeyBiryukov. Fixes #54225. Built from https://develop.svn.wordpress.org/trunk@55210 git-svn-id: http://core.svn.wordpress.org/trunk@54743 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
965fe8f209
commit
28358ab213
|
@ -2532,7 +2532,7 @@ function wp_ajax_upload_attachment() {
|
|||
check_ajax_referer( 'media-form' );
|
||||
/*
|
||||
* This function does not use wp_send_json_success() / wp_send_json_error()
|
||||
* as the html4 Plupload handler requires a text/html content-type for older IE.
|
||||
* as the html4 Plupload handler requires a text/html Content-Type for older IE.
|
||||
* See https://core.trac.wordpress.org/ticket/31037
|
||||
*/
|
||||
|
||||
|
|
|
@ -1184,7 +1184,7 @@ function download_url( $url, $timeout = 300, $signature_verification = false ) {
|
|||
return new WP_Error( 'http_404', trim( wp_remote_retrieve_response_message( $response ) ), $data );
|
||||
}
|
||||
|
||||
$content_disposition = wp_remote_retrieve_header( $response, 'content-disposition' );
|
||||
$content_disposition = wp_remote_retrieve_header( $response, 'Content-Disposition' );
|
||||
|
||||
if ( $content_disposition ) {
|
||||
$content_disposition = strtolower( $content_disposition );
|
||||
|
@ -1211,7 +1211,7 @@ function download_url( $url, $timeout = 300, $signature_verification = false ) {
|
|||
}
|
||||
}
|
||||
|
||||
$content_md5 = wp_remote_retrieve_header( $response, 'content-md5' );
|
||||
$content_md5 = wp_remote_retrieve_header( $response, 'Content-MD5' );
|
||||
|
||||
if ( $content_md5 ) {
|
||||
$md5_check = verify_file_md5( $tmpfname, $content_md5 );
|
||||
|
@ -1238,7 +1238,7 @@ function download_url( $url, $timeout = 300, $signature_verification = false ) {
|
|||
|
||||
// Perform signature valiation if supported.
|
||||
if ( $signature_verification ) {
|
||||
$signature = wp_remote_retrieve_header( $response, 'x-content-signature' );
|
||||
$signature = wp_remote_retrieve_header( $response, 'X-Content-Signature' );
|
||||
|
||||
if ( ! $signature ) {
|
||||
// Retrieve signatures from a file if the header wasn't included.
|
||||
|
|
|
@ -512,7 +512,7 @@ function wp_install_maybe_enable_pretty_permalinks() {
|
|||
* can block head requests.
|
||||
*/
|
||||
$response = wp_remote_get( $test_url, array( 'timeout' => 5 ) );
|
||||
$x_pingback_header = wp_remote_retrieve_header( $response, 'x-pingback' );
|
||||
$x_pingback_header = wp_remote_retrieve_header( $response, 'X-Pingback' );
|
||||
$pretty_permalinks = $x_pingback_header && get_bloginfo( 'pingback_url' ) === $x_pingback_header;
|
||||
|
||||
if ( $pretty_permalinks ) {
|
||||
|
|
|
@ -291,7 +291,7 @@ class Services_JSON
|
|||
{
|
||||
_deprecated_function( __METHOD__, '5.3.0', 'The PHP native JSON extension' );
|
||||
|
||||
header('Content-type: application/json');
|
||||
header('Content-Type: application/json');
|
||||
return $this->encodeUnsafe($var);
|
||||
}
|
||||
/**
|
||||
|
|
|
@ -1864,7 +1864,7 @@ class SimplePie
|
|||
}
|
||||
|
||||
/**
|
||||
* Send the content-type header with correct encoding
|
||||
* Send the Content-Type header with correct encoding
|
||||
*
|
||||
* This method ensures that the SimplePie-enabled page is being served with
|
||||
* the correct {@link http://www.iana.org/assignments/media-types/ mime-type}
|
||||
|
@ -1886,7 +1886,7 @@ class SimplePie
|
|||
{
|
||||
if (!headers_sent())
|
||||
{
|
||||
$header = "Content-type: $mime;";
|
||||
$header = "Content-Type: $mime;";
|
||||
if ($this->get_encoding())
|
||||
{
|
||||
$header .= ' charset=' . $this->get_encoding();
|
||||
|
|
|
@ -53,7 +53,7 @@ class Snoopy
|
|||
var $cookies = array(); // array of cookies to pass
|
||||
// $cookies["username"]="joe";
|
||||
var $rawheaders = array(); // array of raw headers to send
|
||||
// $rawheaders["Content-type"]="text/html";
|
||||
// $rawheaders["Content-Type"]="text/html";
|
||||
|
||||
var $maxredirs = 5; // http redirection depth maximum. 0 = disallow
|
||||
var $lastredirectaddr = ""; // contains address of last redirected address
|
||||
|
@ -825,13 +825,13 @@ class Snoopy
|
|||
$headers .= $headerKey.": ".$headerVal."\r\n";
|
||||
}
|
||||
if(!empty($content_type)) {
|
||||
$headers .= "Content-type: $content_type";
|
||||
$headers .= "Content-Type: $content_type";
|
||||
if ($content_type == "multipart/form-data")
|
||||
$headers .= "; boundary=".$this->_mime_boundary;
|
||||
$headers .= "\r\n";
|
||||
}
|
||||
if(!empty($body))
|
||||
$headers .= "Content-length: ".strlen($body)."\r\n";
|
||||
$headers .= "Content-Length: ".strlen($body)."\r\n";
|
||||
if(!empty($this->user) || !empty($this->pass))
|
||||
$headers .= "Authorization: Basic ".base64_encode($this->user.":".$this->pass)."\r\n";
|
||||
|
||||
|
@ -990,12 +990,12 @@ class Snoopy
|
|||
}
|
||||
if(!empty($content_type)) {
|
||||
if ($content_type == "multipart/form-data")
|
||||
$headers[] = "Content-type: $content_type; boundary=".$this->_mime_boundary;
|
||||
$headers[] = "Content-Type: $content_type; boundary=".$this->_mime_boundary;
|
||||
else
|
||||
$headers[] = "Content-type: $content_type";
|
||||
$headers[] = "Content-Type: $content_type";
|
||||
}
|
||||
if(!empty($body))
|
||||
$headers[] = "Content-length: ".strlen($body);
|
||||
$headers[] = "Content-Length: ".strlen($body);
|
||||
if(!empty($this->user) || !empty($this->pass))
|
||||
$headers[] = "Authorization: BASIC ".base64_encode($this->user.":".$this->pass);
|
||||
|
||||
|
|
|
@ -2824,12 +2824,12 @@ function discover_pingback_server_uri( $url, $deprecated = '' ) {
|
|||
return false;
|
||||
}
|
||||
|
||||
if ( wp_remote_retrieve_header( $response, 'x-pingback' ) ) {
|
||||
return wp_remote_retrieve_header( $response, 'x-pingback' );
|
||||
if ( wp_remote_retrieve_header( $response, 'X-Pingback' ) ) {
|
||||
return wp_remote_retrieve_header( $response, 'X-Pingback' );
|
||||
}
|
||||
|
||||
// Not an (x)html, sgml, or xml page, no use going further.
|
||||
if ( preg_match( '#(image|audio|video|model)/#is', wp_remote_retrieve_header( $response, 'content-type' ) ) ) {
|
||||
if ( preg_match( '#(image|audio|video|model)/#is', wp_remote_retrieve_header( $response, 'Content-Type' ) ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -943,8 +943,8 @@ function do_enclose( $content, $post ) {
|
|||
|
||||
$headers = wp_get_http_headers( $url );
|
||||
if ( $headers ) {
|
||||
$len = isset( $headers['content-length'] ) ? (int) $headers['content-length'] : 0;
|
||||
$type = isset( $headers['content-type'] ) ? $headers['content-type'] : '';
|
||||
$len = isset( $headers['Content-Length'] ) ? (int) $headers['Content-Length'] : 0;
|
||||
$type = isset( $headers['Content-Type'] ) ? $headers['Content-Type'] : '';
|
||||
$allowed_types = array( 'video', 'audio' );
|
||||
|
||||
// Check to see if we can figure out the mime type from the extension.
|
||||
|
|
|
@ -755,7 +755,7 @@ function bloginfo( $show = '' ) {
|
|||
* - 'admin_email' - Admin email (set in Settings > General)
|
||||
* - 'charset' - The "Encoding for pages and feeds" (set in Settings > Reading)
|
||||
* - 'version' - The current WordPress version
|
||||
* - 'html_type' - The content-type (default: "text/html"). Themes and plugins
|
||||
* - 'html_type' - The Content-Type (default: "text/html"). Themes and plugins
|
||||
* can override the default value using the {@see 'pre_option_html_type'} filter
|
||||
* - 'text_direction' - The text direction determined by the site's language. is_rtl()
|
||||
* should be used instead
|
||||
|
|
|
@ -463,7 +463,7 @@ if ( ! function_exists( 'wp_mail' ) ) :
|
|||
|
||||
// Set Content-Type and charset.
|
||||
|
||||
// If we don't have a content-type from the input headers.
|
||||
// If we don't have a Content-Type from the input headers.
|
||||
if ( ! isset( $content_type ) ) {
|
||||
$content_type = 'text/plain';
|
||||
}
|
||||
|
|
|
@ -291,16 +291,16 @@ class WP_REST_Request implements ArrayAccess {
|
|||
}
|
||||
|
||||
/**
|
||||
* Retrieves the content-type of the request.
|
||||
* Retrieves the Content-Type of the request.
|
||||
*
|
||||
* @since 4.4.0
|
||||
*
|
||||
* @return array|null Map containing 'value' and 'parameters' keys
|
||||
* or null when no valid content-type header was
|
||||
* or null when no valid Content-Type header was
|
||||
* available.
|
||||
*/
|
||||
public function get_content_type() {
|
||||
$value = $this->get_header( 'content-type' );
|
||||
$value = $this->get_header( 'Content-Type' );
|
||||
if ( empty( $value ) ) {
|
||||
return null;
|
||||
}
|
||||
|
@ -325,11 +325,11 @@ class WP_REST_Request implements ArrayAccess {
|
|||
}
|
||||
|
||||
/**
|
||||
* Checks if the request has specified a JSON content-type.
|
||||
* Checks if the request has specified a JSON Content-Type.
|
||||
*
|
||||
* @since 5.6.0
|
||||
*
|
||||
* @return bool True if the content-type header is JSON.
|
||||
* @return bool True if the Content-Type header is JSON.
|
||||
*/
|
||||
public function is_json_content_type() {
|
||||
$content_type = $this->get_content_type();
|
||||
|
@ -719,7 +719,7 @@ class WP_REST_Request implements ArrayAccess {
|
|||
$this->parsed_body = true;
|
||||
|
||||
/*
|
||||
* Check that we got URL-encoded. Treat a missing content-type as
|
||||
* Check that we got URL-encoded. Treat a missing Content-Type as
|
||||
* URL-encoded for maximum compatibility.
|
||||
*/
|
||||
$content_type = $this->get_content_type();
|
||||
|
|
|
@ -123,7 +123,7 @@ class WP_Sitemaps_Renderer {
|
|||
* @param array $sitemaps Array of sitemap URLs.
|
||||
*/
|
||||
public function render_index( $sitemaps ) {
|
||||
header( 'Content-type: application/xml; charset=UTF-8' );
|
||||
header( 'Content-Type: application/xml; charset=UTF-8' );
|
||||
|
||||
$this->check_for_simple_xml_availability();
|
||||
|
||||
|
@ -188,7 +188,7 @@ class WP_Sitemaps_Renderer {
|
|||
* @param array $url_list Array of URLs for a sitemap.
|
||||
*/
|
||||
public function render_sitemap( $url_list ) {
|
||||
header( 'Content-type: application/xml; charset=UTF-8' );
|
||||
header( 'Content-Type: application/xml; charset=UTF-8' );
|
||||
|
||||
$this->check_for_simple_xml_availability();
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ class WP_Sitemaps_Stylesheet {
|
|||
* @param string $type Stylesheet type. Either 'sitemap' or 'index'.
|
||||
*/
|
||||
public function render_stylesheet( $type ) {
|
||||
header( 'Content-type: application/xml; charset=UTF-8' );
|
||||
header( 'Content-Type: application/xml; charset=UTF-8' );
|
||||
|
||||
if ( 'sitemap' === $type ) {
|
||||
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- All content escaped below.
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '6.2-alpha-55209';
|
||||
$wp_version = '6.2-alpha-55210';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
|
|
@ -171,7 +171,7 @@ for ( $i = 1; $i <= $count; $i++ ) {
|
|||
$content = explode( '--' . $boundary, $content );
|
||||
$content = $content[2];
|
||||
|
||||
// Match case-insensitive content-transfer-encoding.
|
||||
// Match case-insensitive Content-Transfer-Encoding.
|
||||
if ( preg_match( '/Content-Transfer-Encoding: quoted-printable/i', $content, $delim ) ) {
|
||||
$content = explode( $delim[0], $content );
|
||||
$content = $content[1];
|
||||
|
|
Loading…
Reference in New Issue