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-comments-controller.php

    r55104 r55210  
    11341134
    11351135        $request = new WP_REST_Request( 'POST', '/wp/v2/comments' );
    1136         $request->add_header( 'content-type', 'application/json' );
     1136        $request->add_header( 'Content-Type', 'application/json' );
    11371137        $request->set_body( wp_json_encode( $params ) );
    11381138
     
    12401240
    12411241        $request = new WP_REST_Request( 'POST', '/wp/v2/comments' );
    1242         $request->add_header( 'content-type', 'application/json' );
     1242        $request->add_header( 'Content-Type', 'application/json' );
    12431243        $request->set_body( wp_json_encode( $params ) );
    12441244
     
    12651265
    12661266        $request = new WP_REST_Request( 'POST', '/wp/v2/comments' );
    1267         $request->add_header( 'content-type', 'application/json' );
     1267        $request->add_header( 'Content-Type', 'application/json' );
    12681268        $request->set_body( wp_json_encode( $params ) );
    12691269
     
    12881288
    12891289        $request = new WP_REST_Request( 'POST', '/wp/v2/comments' );
    1290         $request->add_header( 'content-type', 'application/json' );
     1290        $request->add_header( 'Content-Type', 'application/json' );
    12911291        $request->set_body( wp_json_encode( $params ) );
    12921292
     
    13081308
    13091309        $request = new WP_REST_Request( 'POST', '/wp/v2/comments' );
    1310         $request->add_header( 'content-type', 'application/json' );
     1310        $request->add_header( 'Content-Type', 'application/json' );
    13111311        $request->set_body( wp_json_encode( $params ) );
    13121312
     
    13281328
    13291329        $request = new WP_REST_Request( 'POST', '/wp/v2/comments' );
    1330         $request->add_header( 'content-type', 'application/json' );
     1330        $request->add_header( 'Content-Type', 'application/json' );
    13311331        $request->set_body( wp_json_encode( $params ) );
    13321332
     
    13481348
    13491349        $request = new WP_REST_Request( 'POST', '/wp/v2/comments' );
    1350         $request->add_header( 'content-type', 'application/json' );
     1350        $request->add_header( 'Content-Type', 'application/json' );
    13511351        $request->set_body( wp_json_encode( $params ) );
    13521352
     
    13661366
    13671367        $request = new WP_REST_Request( 'POST', '/wp/v2/comments' );
    1368         $request->add_header( 'content-type', 'application/json' );
     1368        $request->add_header( 'Content-Type', 'application/json' );
    13691369        $request->set_body( wp_json_encode( $params ) );
    13701370        $response = rest_get_server()->dispatch( $request );
     
    13871387
    13881388        $request = new WP_REST_Request( 'POST', '/wp/v2/comments' );
    1389         $request->add_header( 'content-type', 'application/json' );
     1389        $request->add_header( 'Content-Type', 'application/json' );
    13901390        $request->set_body( wp_json_encode( $params ) );
    13911391
     
    14141414
    14151415        $request = new WP_REST_Request( 'POST', '/wp/v2/comments' );
    1416         $request->add_header( 'content-type', 'application/json' );
     1416        $request->add_header( 'Content-Type', 'application/json' );
    14171417        $request->set_body( wp_json_encode( $params ) );
    14181418
     
    14361436
    14371437        $request = new WP_REST_Request( 'POST', '/wp/v2/comments' );
    1438         $request->add_header( 'content-type', 'application/json' );
     1438        $request->add_header( 'Content-Type', 'application/json' );
    14391439        $request->set_body( wp_json_encode( $params ) );
    14401440
     
    14611461
    14621462        $request = new WP_REST_Request( 'POST', '/wp/v2/comments' );
    1463         $request->add_header( 'content-type', 'application/json' );
     1463        $request->add_header( 'Content-Type', 'application/json' );
    14641464        $request->set_body( wp_json_encode( $params ) );
    14651465
     
    14821482
    14831483        $request = new WP_REST_Request( 'POST', '/wp/v2/comments' );
    1484         $request->add_header( 'content-type', 'application/json' );
     1484        $request->add_header( 'Content-Type', 'application/json' );
    14851485        $request->set_body( wp_json_encode( $params ) );
    14861486
     
    15111511
    15121512        $request = new WP_REST_Request( 'POST', '/wp/v2/comments' );
    1513         $request->add_header( 'content-type', 'application/json' );
     1513        $request->add_header( 'Content-Type', 'application/json' );
    15141514        $request->set_body( wp_json_encode( $params ) );
    15151515        $response = rest_get_server()->dispatch( $request );
     
    15371537
    15381538        $request = new WP_REST_Request( 'POST', '/wp/v2/comments' );
    1539         $request->add_header( 'content-type', 'application/json' );
     1539        $request->add_header( 'Content-Type', 'application/json' );
    15401540        $request->set_body( wp_json_encode( $params ) );
    15411541
     
    15761576
    15771577        $request = new WP_REST_Request( 'POST', '/wp/v2/comments' );
    1578         $request->add_header( 'content-type', 'application/json' );
     1578        $request->add_header( 'Content-Type', 'application/json' );
    15791579        $request->set_body( wp_json_encode( $params ) );
    15801580
     
    15991599
    16001600        $request = new WP_REST_Request( 'POST', '/wp/v2/comments' );
    1601         $request->add_header( 'content-type', 'application/json' );
     1601        $request->add_header( 'Content-Type', 'application/json' );
    16021602        $request->set_body( wp_json_encode( $params ) );
    16031603
     
    16261626
    16271627        $request = new WP_REST_Request( 'POST', '/wp/v2/comments' );
    1628         $request->add_header( 'content-type', 'application/json' );
     1628        $request->add_header( 'Content-Type', 'application/json' );
    16291629        $request->set_body( wp_json_encode( $params ) );
    16301630        $response = rest_get_server()->dispatch( $request );
     
    16551655
    16561656        $request = new WP_REST_Request( 'POST', '/wp/v2/comments' );
    1657         $request->add_header( 'content-type', 'application/json' );
     1657        $request->add_header( 'Content-Type', 'application/json' );
    16581658        $request->set_body( wp_json_encode( $params ) );
    16591659        $response = rest_get_server()->dispatch( $request );
     
    16801680
    16811681        $request = new WP_REST_Request( 'POST', '/wp/v2/comments' );
    1682         $request->add_header( 'content-type', 'application/json' );
     1682        $request->add_header( 'Content-Type', 'application/json' );
    16831683        $request->set_body( wp_json_encode( $params ) );
    16841684        $response = rest_get_server()->dispatch( $request );
     
    17001700
    17011701        $request = new WP_REST_Request( 'POST', '/wp/v2/comments' );
    1702         $request->add_header( 'content-type', 'application/json' );
     1702        $request->add_header( 'Content-Type', 'application/json' );
    17031703        $request->set_body( wp_json_encode( $params ) );
    17041704        $response = rest_get_server()->dispatch( $request );
     
    17211721
    17221722        $request = new WP_REST_Request( 'POST', '/wp/v2/comments' );
    1723         $request->add_header( 'content-type', 'application/json' );
     1723        $request->add_header( 'Content-Type', 'application/json' );
    17241724        $request->set_body( wp_json_encode( $params ) );
    17251725        $response = rest_get_server()->dispatch( $request );
     
    17451745
    17461746        $request = new WP_REST_Request( 'POST', '/wp/v2/comments' );
    1747         $request->add_header( 'content-type', 'application/json' );
     1747        $request->add_header( 'Content-Type', 'application/json' );
    17481748        $request->set_body( wp_json_encode( $params ) );
    17491749
     
    17691769
    17701770        $request = new WP_REST_Request( 'POST', '/wp/v2/comments' );
    1771         $request->add_header( 'content-type', 'application/json' );
    1772         $request->add_header( 'user_agent', 'Mozilla/4.0 (compatible; MSIE 5.5; AOL 4.0; Windows 95)' );
     1771        $request->add_header( 'Content-Type', 'application/json' );
     1772        $request->add_header( 'User_Agent', 'Mozilla/4.0 (compatible; MSIE 5.5; AOL 4.0; Windows 95)' );
    17731773        $request->set_body( wp_json_encode( $params ) );
    17741774
     
    17951795        );
    17961796        $request = new WP_REST_Request( 'POST', '/wp/v2/comments' );
    1797         $request->add_header( 'content-type', 'application/json' );
     1797        $request->add_header( 'Content-Type', 'application/json' );
    17981798        $request->set_body( wp_json_encode( $params ) );
    17991799        $response    = rest_get_server()->dispatch( $request );
     
    18161816        );
    18171817        $request = new WP_REST_Request( 'POST', '/wp/v2/comments' );
    1818         $request->add_header( 'content-type', 'application/json' );
     1818        $request->add_header( 'Content-Type', 'application/json' );
    18191819        $request->set_body( wp_json_encode( $params ) );
    18201820
     
    18361836
    18371837        $request = new WP_REST_Request( 'POST', '/wp/v2/comments' );
    1838         $request->add_header( 'content-type', 'application/json' );
     1838        $request->add_header( 'Content-Type', 'application/json' );
    18391839        $request->set_body( wp_json_encode( $params ) );
    18401840        $response = rest_get_server()->dispatch( $request );
     
    18561856
    18571857        $request = new WP_REST_Request( 'POST', '/wp/v2/comments' );
    1858         $request->add_header( 'content-type', 'application/json' );
     1858        $request->add_header( 'Content-Type', 'application/json' );
    18591859        $request->set_body( wp_json_encode( $params ) );
    18601860        $response    = rest_get_server()->dispatch( $request );
     
    18761876
    18771877        $request = new WP_REST_Request( 'POST', '/wp/v2/comments' );
    1878         $request->add_header( 'content-type', 'application/json' );
     1878        $request->add_header( 'Content-Type', 'application/json' );
    18791879        $request->set_body( wp_json_encode( $params ) );
    18801880
     
    18961896
    18971897        $request = new WP_REST_Request( 'POST', '/wp/v2/comments' );
    1898         $request->add_header( 'content-type', 'application/json' );
     1898        $request->add_header( 'Content-Type', 'application/json' );
    18991899        $request->set_body( wp_json_encode( $params ) );
    19001900
     
    19161916
    19171917        $request = new WP_REST_Request( 'POST', '/wp/v2/comments' );
    1918         $request->add_header( 'content-type', 'application/json' );
     1918        $request->add_header( 'Content-Type', 'application/json' );
    19191919        $request->set_body( wp_json_encode( $params ) );
    19201920
     
    19361936
    19371937        $request = new WP_REST_Request( 'POST', '/wp/v2/comments' );
    1938         $request->add_header( 'content-type', 'application/json' );
     1938        $request->add_header( 'Content-Type', 'application/json' );
    19391939        $request->set_body( wp_json_encode( $params ) );
    19401940
     
    19561956
    19571957        $request = new WP_REST_Request( 'POST', '/wp/v2/comments' );
    1958         $request->add_header( 'content-type', 'application/json' );
     1958        $request->add_header( 'Content-Type', 'application/json' );
    19591959        $request->set_body( wp_json_encode( $params ) );
    19601960
     
    19771977
    19781978        $request = new WP_REST_Request( 'POST', '/wp/v2/comments' );
    1979         $request->add_header( 'content-type', 'application/json' );
     1979        $request->add_header( 'Content-Type', 'application/json' );
    19801980        $request->set_body( wp_json_encode( $params ) );
    19811981
     
    19971997
    19981998        $request = new WP_REST_Request( 'POST', '/wp/v2/comments' );
    1999         $request->add_header( 'content-type', 'application/json' );
     1999        $request->add_header( 'Content-Type', 'application/json' );
    20002000        $request->set_body( wp_json_encode( $params ) );
    20012001
     
    20242024
    20252025        $request = new WP_REST_Request( 'POST', '/wp/v2/comments' );
    2026         $request->add_header( 'content-type', 'application/json' );
     2026        $request->add_header( 'Content-Type', 'application/json' );
    20272027        $request->set_body( wp_json_encode( $params ) );
    20282028        $response = rest_get_server()->dispatch( $request );
     
    20452045
    20462046        $request = new WP_REST_Request( 'POST', '/wp/v2/comments' );
    2047         $request->add_header( 'content-type', 'application/json' );
     2047        $request->add_header( 'Content-Type', 'application/json' );
    20482048        $request->set_body( wp_json_encode( $params ) );
    20492049        $response = rest_get_server()->dispatch( $request );
     
    20762076
    20772077        $request = new WP_REST_Request( 'POST', '/wp/v2/comments' );
    2078         $request->add_header( 'content-type', 'application/json' );
     2078        $request->add_header( 'Content-Type', 'application/json' );
    20792079        $request->set_body( wp_json_encode( $params ) );
    20802080
     
    20942094
    20952095        $request = new WP_REST_Request( 'POST', '/wp/v2/comments' );
    2096         $request->add_header( 'content-type', 'application/json' );
     2096        $request->add_header( 'Content-Type', 'application/json' );
    20972097        $request->set_body( wp_json_encode( $params ) );
    20982098
     
    21182118
    21192119        $request = new WP_REST_Request( 'POST', '/wp/v2/comments' );
    2120         $request->add_header( 'content-type', 'application/json' );
     2120        $request->add_header( 'Content-Type', 'application/json' );
    21212121        $request->set_body( wp_json_encode( $params ) );
    21222122
     
    21332133
    21342134        $request = new WP_REST_Request( 'POST', '/wp/v2/comments' );
    2135         $request->add_header( 'content-type', 'application/json' );
     2135        $request->add_header( 'Content-Type', 'application/json' );
    21362136        $request->set_body( wp_json_encode( $params ) );
    21372137
     
    21572157
    21582158        $request = new WP_REST_Request( 'POST', '/wp/v2/comments' );
    2159         $request->add_header( 'content-type', 'application/json' );
     2159        $request->add_header( 'Content-Type', 'application/json' );
    21602160        $request->set_body( wp_json_encode( $params ) );
    21612161
     
    21842184        $request = new WP_REST_Request( 'POST', '/wp/v2/comments' );
    21852185
    2186         $request->add_header( 'content-type', 'application/json' );
     2186        $request->add_header( 'Content-Type', 'application/json' );
    21872187        $request->set_body( wp_json_encode( $params ) );
    21882188        $response = rest_get_server()->dispatch( $request );
     
    22082208        $request = new WP_REST_Request( 'POST', '/wp/v2/comments' );
    22092209
    2210         $request->add_header( 'content-type', 'application/json' );
     2210        $request->add_header( 'Content-Type', 'application/json' );
    22112211        $request->set_body( wp_json_encode( $params ) );
    22122212        $response = rest_get_server()->dispatch( $request );
     
    22322232        $request = new WP_REST_Request( 'POST', '/wp/v2/comments' );
    22332233
    2234         $request->add_header( 'content-type', 'application/json' );
     2234        $request->add_header( 'Content-Type', 'application/json' );
    22352235        $request->set_body( wp_json_encode( $params ) );
    22362236        $response = rest_get_server()->dispatch( $request );
     
    22562256        $request = new WP_REST_Request( 'POST', '/wp/v2/comments' );
    22572257
    2258         $request->add_header( 'content-type', 'application/json' );
     2258        $request->add_header( 'Content-Type', 'application/json' );
    22592259        $request->set_body( wp_json_encode( $params ) );
    22602260        $response = rest_get_server()->dispatch( $request );
     
    22762276        $request = new WP_REST_Request( 'POST', '/wp/v2/comments' );
    22772277
    2278         $request->add_header( 'content-type', 'application/json' );
     2278        $request->add_header( 'Content-Type', 'application/json' );
    22792279        $request->set_body( wp_json_encode( $params ) );
    22802280        $response = rest_get_server()->dispatch( $request );
     
    22972297        $request = new WP_REST_Request( 'POST', '/wp/v2/comments' );
    22982298
    2299         $request->add_header( 'content-type', 'application/json' );
     2299        $request->add_header( 'Content-Type', 'application/json' );
    23002300        $request->set_body( wp_json_encode( $params ) );
    23012301        $response = rest_get_server()->dispatch( $request );
     
    23202320
    23212321        $request = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/comments/%d', self::$approved_id ) );
    2322         $request->add_header( 'content-type', 'application/json' );
     2322        $request->add_header( 'Content-Type', 'application/json' );
    23232323        $request->set_body( wp_json_encode( $params ) );
    23242324
     
    24252425
    24262426        $request = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/comments/%d', $comment_id ) );
    2427         $request->add_header( 'content-type', 'application/json' );
     2427        $request->add_header( 'Content-Type', 'application/json' );
    24282428        $request->set_body( wp_json_encode( $params ) );
    24292429
     
    24532453
    24542454        $request = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/comments/%d', $comment_id ) );
    2455         $request->add_header( 'content-type', 'application/json' );
     2455        $request->add_header( 'Content-Type', 'application/json' );
    24562456        $request->set_body( wp_json_encode( $params ) );
    24572457
     
    24752475
    24762476        $request = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/comments/%d', self::$approved_id ) );
    2477         $request->add_header( 'content-type', 'application/json' );
     2477        $request->add_header( 'Content-Type', 'application/json' );
    24782478        $request->set_body( wp_json_encode( $params ) );
    24792479
     
    24992499
    25002500        $request = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/comments/%d', self::$approved_id ) );
    2501         $request->add_header( 'content-type', 'application/json' );
     2501        $request->add_header( 'Content-Type', 'application/json' );
    25022502        $request->set_body( wp_json_encode( $params ) );
    25032503
     
    25192519
    25202520        $request = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/comments/%d', self::$approved_id ) );
    2521         $request->add_header( 'content-type', 'application/json' );
     2521        $request->add_header( 'Content-Type', 'application/json' );
    25222522        $request->set_body( wp_json_encode( $params ) );
    25232523
     
    25382538
    25392539        $request = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/comments/%d', self::$approved_id ) );
    2540         $request->add_header( 'content-type', 'application/json' );
     2540        $request->add_header( 'Content-Type', 'application/json' );
    25412541        $request->set_body( wp_json_encode( $params ) );
    25422542
     
    25582558
    25592559        $request = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/comments/%d', self::$approved_id ) );
    2560         $request->add_header( 'content-type', 'application/json' );
     2560        $request->add_header( 'Content-Type', 'application/json' );
    25612561        $request->set_body( wp_json_encode( $params ) );
    25622562
     
    25762576
    25772577        $request = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/comments/%d', self::$approved_id ) );
    2578         $request->add_header( 'content-type', 'application/json' );
     2578        $request->add_header( 'Content-Type', 'application/json' );
    25792579        $request->set_body( wp_json_encode( $params ) );
    25802580        $response = rest_get_server()->dispatch( $request );
     
    25932593
    25942594        $request = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/comments/%d', self::$approved_id ) );
    2595         $request->add_header( 'content-type', 'application/json' );
     2595        $request->add_header( 'Content-Type', 'application/json' );
    25962596        $request->set_body( wp_json_encode( $params ) );
    25972597
     
    26102610
    26112611        $request = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/comments/%d', self::$approved_id ) );
    2612         $request->add_header( 'content-type', 'application/json' );
     2612        $request->add_header( 'Content-Type', 'application/json' );
    26132613        $request->set_body( wp_json_encode( $params ) );
    26142614
     
    26312631
    26322632        $request = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/comments/%d', self::$approved_id ) );
    2633         $request->add_header( 'content-type', 'application/json' );
     2633        $request->add_header( 'Content-Type', 'application/json' );
    26342634        $request->set_body( wp_json_encode( $params ) );
    26352635
     
    26472647
    26482648        $request = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/comments/%d', self::$approved_id ) );
    2649         $request->add_header( 'content-type', 'application/json' );
     2649        $request->add_header( 'Content-Type', 'application/json' );
    26502650        $request->set_body( wp_json_encode( $params ) );
    26512651
     
    26622662
    26632663        $request = new WP_REST_Request( 'PUT', '/wp/v2/comments/' . REST_TESTS_IMPOSSIBLY_HIGH_NUMBER );
    2664         $request->add_header( 'content-type', 'application/json' );
     2664        $request->add_header( 'Content-Type', 'application/json' );
    26652665        $request->set_body( wp_json_encode( $params ) );
    26662666
     
    26872687
    26882688        $request = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/comments/%d', self::$hold_id ) );
    2689         $request->add_header( 'content-type', 'application/json' );
     2689        $request->add_header( 'Content-Type', 'application/json' );
    26902690        $request->set_body( wp_json_encode( $params ) );
    26912691
     
    27062706
    27072707        $request = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/comments/%d', self::$approved_id ) );
    2708         $request->add_header( 'content-type', 'application/json' );
     2708        $request->add_header( 'Content-Type', 'application/json' );
    27092709        $request->set_body( wp_json_encode( $params ) );
    27102710
     
    27362736
    27372737        $request = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/comments/%d', $private_comment_id ) );
    2738         $request->add_header( 'content-type', 'application/json' );
     2738        $request->add_header( 'Content-Type', 'application/json' );
    27392739        $request->set_body( wp_json_encode( $params ) );
    27402740
     
    27952795        $request = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/comments/%d', self::$approved_id ) );
    27962796
    2797         $request->add_header( 'content-type', 'application/json' );
     2797        $request->add_header( 'Content-Type', 'application/json' );
    27982798        $request->set_body( wp_json_encode( $params ) );
    27992799        $response = rest_get_server()->dispatch( $request );
     
    28152815        $request = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/comments/%d', self::$approved_id ) );
    28162816
    2817         $request->add_header( 'content-type', 'application/json' );
     2817        $request->add_header( 'Content-Type', 'application/json' );
    28182818        $request->set_body( wp_json_encode( $params ) );
    28192819        $response = rest_get_server()->dispatch( $request );
     
    28352835        $request = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/comments/%d', self::$approved_id ) );
    28362836
    2837         $request->add_header( 'content-type', 'application/json' );
     2837        $request->add_header( 'Content-Type', 'application/json' );
    28382838        $request->set_body( wp_json_encode( $params ) );
    28392839        $response = rest_get_server()->dispatch( $request );
     
    28542854        $request = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/comments/%d', self::$approved_id ) );
    28552855
    2856         $request->add_header( 'content-type', 'application/json' );
     2856        $request->add_header( 'Content-Type', 'application/json' );
    28572857        $request->set_body( wp_json_encode( $params ) );
    28582858        $response = rest_get_server()->dispatch( $request );
     
    28752875        $request = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/comments/%d', self::$approved_id ) );
    28762876
    2877         $request->add_header( 'content-type', 'application/json' );
     2877        $request->add_header( 'Content-Type', 'application/json' );
    28782878        $request->set_body( wp_json_encode( $params ) );
    28792879        $response = rest_get_server()->dispatch( $request );
Note: See TracChangeset for help on using the changeset viewer.