WordPress.org

Make WordPress Core


Ignore:
Timestamp:
03/03/2016 09:54:32 AM (4 years ago)
Author:
joehoyle
Message:

OPTIONS requests to REST API should return Allow header.

An OPTIONS request was incorrectly returning an "Accept" header which
was a typo of "Allow". This meant Accept was showing "GET, POST" for example,
however it was also not running the permission checks on the endpoints.

Instead, the correct route needs to be set on the request object, which means
the normal handling for the Allow header will kick in. This technically
breaks backwards compatibility, however given the value of Accept was also wrong
then this should not be an issue.

Fixes #35975.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/rest-api.php

    r36529 r36829  
    432432
    433433        $data = $handler->get_data_for_route( $route, $endpoints, 'help' );
    434         $accept = array_merge( $accept, $data['methods'] );
     434        $response->set_matched_route( $route );
    435435        break;
    436436    }
    437     $response->header( 'Accept', implode( ', ', $accept ) );
    438437
    439438    $response->set_data( $data );
Note: See TracChangeset for help on using the changeset viewer.