You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am sending "faked PUT" requests using POST method and header X-HTTP-METHOD-OVERRIDE:PUT, but the dumped uri.method is still "POST". I can see why: it's because PHP is presenting the headers with different names to what the code is matching:
if ($method === 'POST' && isset($_SERVER['X-HTTP-METHOD-OVERRIDE'])) {
Dumping $_SERVER and using Inspector, I see the header is expressed by PHP as $_SERVER['HTTP_X_HTTP_METHOD_OVERRIDE'] instead.
For context, I'm using a template as a REST endpoint, and GET and POST are working just fine. I am sending the requests with JQuery.ajax() and the request leaves them intact. In Twig, I have a simple branch to handle different HTTP methods like:
A previous attempt sent a real PUT request, but I found there was no way to access the request parameters or the request body/payload. Then I tried a fake PUT with my own attempt to read the header, but didn't seem to be able to access that either (for the request).
Then I dug into the source code and found that line, which looks like it should have done the heavy lifting of faking PUT for me.
My research suggests PHP is doing the header key rewriting. Is this always done, or only for Ajax requests? Looks like Uri->getContentType() would fail to match in a similar way.
Some comments [1][2] allude to PHP mangling header names and this being standard. I'm having trouble following. Might help.
The text was updated successfully, but these errors were encountered:
I think you are correct, it does look like the proper syntax per the spec is the lower case version with dashes, but PHP uses the uppercase with underscores.
I am sending "faked PUT" requests using POST method and header
X-HTTP-METHOD-OVERRIDE:PUT
, but the dumpeduri.method
is still "POST". I can see why: it's because PHP is presenting the headers with different names to what the code is matching:Dumping
$_SERVER
and using Inspector, I see the header is expressed by PHP as$_SERVER['HTTP_X_HTTP_METHOD_OVERRIDE']
instead.For context, I'm using a template as a REST endpoint, and GET and POST are working just fine. I am sending the requests with
JQuery.ajax()
and the request leaves them intact. In Twig, I have a simple branch to handle different HTTP methods like:A previous attempt sent a real PUT request, but I found there was no way to access the request parameters or the request body/payload. Then I tried a fake PUT with my own attempt to read the header, but didn't seem to be able to access that either (for the request).
Then I dug into the source code and found that line, which looks like it should have done the heavy lifting of faking PUT for me.
My research suggests PHP is doing the header key rewriting. Is this always done, or only for Ajax requests? Looks like
Uri->getContentType()
would fail to match in a similar way.Some comments [1] [2] allude to PHP mangling header names and this being standard. I'm having trouble following. Might help.
The text was updated successfully, but these errors were encountered: