mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-12-06 12:51:58 +00:00
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. git-svn-id: https://develop.svn.wordpress.org/trunk@35773 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -1,6 +1,10 @@
|
||||
<?php
|
||||
|
||||
class Spy_REST_Server extends WP_REST_Server {
|
||||
|
||||
public $sent_headers = array();
|
||||
public $sent_body = '';
|
||||
|
||||
/**
|
||||
* Get the raw $endpoints data from the server
|
||||
*
|
||||
@@ -20,4 +24,16 @@ class Spy_REST_Server extends WP_REST_Server {
|
||||
public function __call( $method, $args ) {
|
||||
return call_user_func_array( array( $this, $method ), $args );
|
||||
}
|
||||
|
||||
public function send_header( $header, $value ) {
|
||||
$this->sent_headers[ $header ] = $value;
|
||||
}
|
||||
|
||||
public function serve_request( $path = null ) {
|
||||
|
||||
ob_start();
|
||||
$result = parent::serve_request( $path );
|
||||
$this->sent_body = ob_get_clean();
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user