[wp-trac] [WordPress Trac] #45753: REST API: Allow header not set when OPTIONS request is made to a route that contains URL params
WordPress Trac
noreply at wordpress.org
Mon Dec 24 04:54:34 UTC 2018
#45753: REST API: Allow header not set when OPTIONS request is made to a route that
contains URL params
--------------------------+-----------------------------
Reporter: noisysocks | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: REST API | Version: 5.0.2
Severity: normal | Keywords:
Focuses: |
--------------------------+-----------------------------
The REST API does not correctly set an `Allow` header when an `OPTIONS`
request is made to a route that contains a URL param, e.g.
`/wp/v2/posts/(?P<id>[\d]+)`. This affects the `posts` and `blocks`
routes.
**Steps to reproduce:**
1. Create and publish a post. Note the ID of the post.
1. As an admin, make an `OPTIONS http://local.wordpress.test/wp-
json/wp/v2/posts/123` request, replacing `local.wordpress.test` with the
URL of your testing environment, and `123` with the ID you noted in (1).
**Expected result:**
The response headers should contain an `Allow` header:
{{{
Allow: GET, POST, PUT, PATCH, DELETE
}}}
**Actual result:**
The response is missing an `Allow` header.
**Possible cause:**
This is possibly to do with `rest_handle_options_request` not calling
`$request->set_url_params()` unlike `dispatch` which correctly parses and
sets URL parameters.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/45753>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list