Make WordPress Core


Ignore:
Timestamp:
12/04/2015 11:35:54 PM (9 years ago)
Author:
wonderboymusic
Message:

REST API: Core typically sends nocache headers on all auth'ed responses, as in wp, admin-ajax, etc. Because the REST API infrastructure is hooked in pre-wp, we should be setting this ourselves.

Adds unit tests.

Props joehoyle.
Fixes #34832.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/includes/spy-rest-server.php

    r34928 r35773  
    22
    33class Spy_REST_Server extends WP_REST_Server {
     4
     5    public $sent_headers = array();
     6    public $sent_body = '';
     7
    48    /**
    59     * Get the raw $endpoints data from the server
     
    2125        return call_user_func_array( array( $this, $method ), $args );
    2226    }
     27
     28    public function send_header( $header, $value ) {
     29        $this->sent_headers[ $header ] = $value;
     30    }
     31
     32    public function serve_request( $path = null ) {
     33
     34        ob_start();
     35        $result = parent::serve_request( $path );
     36        $this->sent_body = ob_get_clean();
     37        return $result;
     38    }
    2339}
Note: See TracChangeset for help on using the changeset viewer.