Make WordPress Core


Ignore:
Timestamp:
02/03/2023 01:33:18 PM (2 years ago)
Author:
audrasjb
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/rest-api/rest-request.php

    r52235 r55210  
    204204     * @dataProvider alternate_json_content_type_provider
    205205     *
    206      * @param string $content_type The content-type header.
     206     * @param string $content_type The Content-Type header.
    207207     * @param string $source       The source value.
    208208     * @param bool   $accept_json  The accept_json value.
     
    235235     * @dataProvider is_json_content_type_provider
    236236     *
    237      * @param string $content_type The content-type header.
     237     * @param string $content_type The Content-Type header.
    238238     * @param bool   $is_json      The is_json value.
    239239     */
     
    243243        $this->request->set_header( 'Content-Type', $content_type );
    244244
    245         // Check for JSON content-type.
     245        // Check for JSON Content-Type.
    246246        $this->assertSame( $is_json, $this->request->is_json_content_type() );
    247247    }
     
    362362
    363363        $this->request->set_method( 'PUT' );
    364         $this->request->add_header( 'content-type', 'application/json' );
     364        $this->request->add_header( 'Content-Type', 'application/json' );
    365365        $this->request->set_body( wp_json_encode( $data ) );
    366366
     
    384384
    385385        $this->request->set_method( 'POST' );
    386         $this->request->add_header( 'content-type', 'application/json' );
     386        $this->request->add_header( 'Content-Type', 'application/json' );
    387387        $this->request->set_body( wp_json_encode( $data ) );
    388388
     
    865865    public function test_set_param_follows_parameter_order() {
    866866        $request = new WP_REST_Request();
    867         $request->add_header( 'content-type', 'application/json' );
     867        $request->add_header( 'Content-Type', 'application/json' );
    868868        $request->set_method( 'POST' );
    869869        $request->set_body(
     
    893893    public function test_set_param_updates_param_in_json_and_query() {
    894894        $request = new WP_REST_Request();
    895         $request->add_header( 'content-type', 'application/json' );
     895        $request->add_header( 'Content-Type', 'application/json' );
    896896        $request->set_method( 'POST' );
    897897        $request->set_body(
     
    920920    public function test_set_param_updates_param_if_already_exists_in_query() {
    921921        $request = new WP_REST_Request();
    922         $request->add_header( 'content-type', 'application/json' );
     922        $request->add_header( 'Content-Type', 'application/json' );
    923923        $request->set_method( 'POST' );
    924924        $request->set_body(
     
    954954    public function test_set_param_to_null_updates_param_in_json_and_query() {
    955955        $request = new WP_REST_Request();
    956         $request->add_header( 'content-type', 'application/json' );
     956        $request->add_header( 'Content-Type', 'application/json' );
    957957        $request->set_method( 'POST' );
    958958        $request->set_body(
     
    981981    public function test_set_param_from_null_updates_param_in_json_and_query_with_null() {
    982982        $request = new WP_REST_Request();
    983         $request->add_header( 'content-type', 'application/json' );
     983        $request->add_header( 'Content-Type', 'application/json' );
    984984        $request->set_method( 'POST' );
    985985        $request->set_body(
     
    10081008    public function test_set_param_with_invalid_json() {
    10091009        $request = new WP_REST_Request();
    1010         $request->add_header( 'content-type', 'application/json' );
     1010        $request->add_header( 'Content-Type', 'application/json' );
    10111011        $request->set_method( 'POST' );
    10121012        $request->set_body( '' );
Note: See TracChangeset for help on using the changeset viewer.