Make WordPress Core


Ignore:
Timestamp:
02/03/2023 01:33:18 PM (16 months 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-users-controller.php

    r55104 r55210  
    12311231
    12321232        $request = new WP_REST_Request( 'POST', '/wp/v2/users' );
    1233         $request->add_header( 'content-type', 'application/x-www-form-urlencoded' );
     1233        $request->add_header( 'Content-Type', 'application/x-www-form-urlencoded' );
    12341234        $request->set_body_params( $params );
    12351235        $response = rest_get_server()->dispatch( $request );
     
    12641264
    12651265        $request = new WP_REST_Request( 'POST', '/wp/v2/users' );
    1266         $request->add_header( 'content-type', 'application/x-www-form-urlencoded' );
     1266        $request->add_header( 'Content-Type', 'application/x-www-form-urlencoded' );
    12671267        $request->set_body_params( $params );
    12681268        $response = rest_get_server()->dispatch( $request );
     
    13091309
    13101310        $request = new WP_REST_Request( 'POST', '/wp/v2/users' );
    1311         $request->add_header( 'content-type', 'application/x-www-form-urlencoded' );
     1311        $request->add_header( 'Content-Type', 'application/x-www-form-urlencoded' );
    13121312        $request->set_body_params( $params );
    13131313        $response = rest_get_server()->dispatch( $request );
     
    13391339
    13401340        $request = new WP_REST_Request( 'POST', '/wp/v2/users' );
    1341         $request->add_header( 'content-type', 'application/x-www-form-urlencoded' );
     1341        $request->add_header( 'Content-Type', 'application/x-www-form-urlencoded' );
    13421342        $request->set_body_params( $params );
    13431343        $response = rest_get_server()->dispatch( $request );
     
    13701370
    13711371        $request = new WP_REST_Request( 'POST', '/wp/v2/users' );
    1372         $request->add_header( 'content-type', 'application/x-www-form-urlencoded' );
     1372        $request->add_header( 'Content-Type', 'application/x-www-form-urlencoded' );
    13731373        $request->set_body_params( $params );
    13741374        $response = rest_get_server()->dispatch( $request );
     
    13931393
    13941394        $request = new WP_REST_Request( 'POST', '/wp/v2/users' );
    1395         $request->add_header( 'content-type', 'application/x-www-form-urlencoded' );
     1395        $request->add_header( 'Content-Type', 'application/x-www-form-urlencoded' );
    13961396        $request->set_body_params( $params );
    13971397        $response = rest_get_server()->dispatch( $request );
     
    14231423
    14241424        $request = new WP_REST_Request( 'POST', '/wp/v2/users' );
    1425         $request->add_header( 'content-type', 'application/x-www-form-urlencoded' );
     1425        $request->add_header( 'Content-Type', 'application/x-www-form-urlencoded' );
    14261426        $request->set_body_params( $params );
    14271427        $response = rest_get_server()->dispatch( $request );
     
    14321432
    14331433        $request = new WP_REST_Request( 'POST', '/wp/v2/users' );
    1434         $request->add_header( 'content-type', 'application/x-www-form-urlencoded' );
     1434        $request->add_header( 'Content-Type', 'application/x-www-form-urlencoded' );
    14351435        $request->set_body_params( $params );
    14361436        $switched_response = rest_get_server()->dispatch( $request );
     
    14711471
    14721472        $request = new WP_REST_Request( 'POST', '/wp/v2/users' );
    1473         $request->add_header( 'content-type', 'application/json' );
     1473        $request->add_header( 'Content-Type', 'application/json' );
    14741474        $request->set_body( wp_json_encode( $params ) );
    14751475        $response = rest_get_server()->dispatch( $request );
     
    14881488
    14891489        $request = new WP_REST_Request( 'POST', '/wp/v2/users' );
    1490         $request->add_header( 'content-type', 'application/x-www-form-urlencoded' );
     1490        $request->add_header( 'Content-Type', 'application/x-www-form-urlencoded' );
    14911491        $request->set_body_params( $params );
    14921492        $response = rest_get_server()->dispatch( $request );
     
    15081508
    15091509        $request = new WP_REST_Request( 'POST', '/wp/v2/users' );
    1510         $request->add_header( 'content-type', 'application/x-www-form-urlencoded' );
     1510        $request->add_header( 'Content-Type', 'application/x-www-form-urlencoded' );
    15111511        $request->set_body_params( $params );
    15121512        $response = rest_get_server()->dispatch( $request );
     
    15271527
    15281528        $request = new WP_REST_Request( 'POST', '/wp/v2/users' );
    1529         $request->add_header( 'content-type', 'application/x-www-form-urlencoded' );
     1529        $request->add_header( 'Content-Type', 'application/x-www-form-urlencoded' );
    15301530        $request->set_body_params( $params );
    15311531        $response = rest_get_server()->dispatch( $request );
     
    15471547
    15481548        $request = new WP_REST_Request( 'POST', '/wp/v2/users' );
    1549         $request->add_header( 'content-type', 'application/x-www-form-urlencoded' );
     1549        $request->add_header( 'Content-Type', 'application/x-www-form-urlencoded' );
    15501550        $request->set_body_params( $params );
    15511551        $response = rest_get_server()->dispatch( $request );
     
    15801580
    15811581        $request = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/users/%d', $user_id ) );
    1582         $request->add_header( 'content-type', 'application/x-www-form-urlencoded' );
     1582        $request->add_header( 'Content-Type', 'application/x-www-form-urlencoded' );
    15831583        $request->set_body_params( $_POST );
    15841584        $response = rest_get_server()->dispatch( $request );
     
    18271827
    18281828        $request = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/users/%d', $user_id ) );
    1829         $request->add_header( 'content-type', 'application/json' );
     1829        $request->add_header( 'Content-Type', 'application/json' );
    18301830        $request->set_body( wp_json_encode( $params ) );
    18311831
     
    20092009
    20102010        $request = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/users/%d', self::$user ) );
    2011         $request->add_header( 'content-type', 'application/x-www-form-urlencoded' );
     2011        $request->add_header( 'Content-Type', 'application/x-www-form-urlencoded' );
    20122012        $request->set_body_params( $params );
    20132013        $response = rest_get_server()->dispatch( $request );
     
    20162016
    20172017        $request = new WP_REST_Request( 'PUT', '/wp/v2/users/me' );
    2018         $request->add_header( 'content-type', 'application/x-www-form-urlencoded' );
     2018        $request->add_header( 'Content-Type', 'application/x-www-form-urlencoded' );
    20192019        $request->set_body_params( $params );
    20202020        $response = rest_get_server()->dispatch( $request );
     
    20362036
    20372037        $request = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/users/%d', self::$editor ) );
    2038         $request->add_header( 'content-type', 'application/x-www-form-urlencoded' );
     2038        $request->add_header( 'Content-Type', 'application/x-www-form-urlencoded' );
    20392039        $request->set_body_params( $params );
    20402040        $response = rest_get_server()->dispatch( $request );
     
    28932893
    28942894        $request = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/users/%d', $user_id ) );
    2895         $request->add_header( 'content-type', 'application/x-www-form-urlencoded' );
     2895        $request->add_header( 'Content-Type', 'application/x-www-form-urlencoded' );
    28962896        $request->set_body_params( array( 'first_name' => 'New Name' ) );
    28972897        $response = rest_get_server()->dispatch( $request );
     
    29152915
    29162916        $request = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/users/%d', $user_id ) );
    2917         $request->add_header( 'content-type', 'application/x-www-form-urlencoded' );
     2917        $request->add_header( 'Content-Type', 'application/x-www-form-urlencoded' );
    29182918        $request->set_body_params( array( 'first_name' => 'New Name' ) );
    29192919        $response = rest_get_server()->dispatch( $request );
Note: See TracChangeset for help on using the changeset viewer.