-
Notifications
You must be signed in to change notification settings - Fork 346
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
🐛 Bug Report — Request Throws 'Invalid HTTP method' Error when Using Lowercase Method "patch" #2516
Comments
@harrishancock I don't suppose you remember why we're only case-insensitive for those six method names? Was this in the spec or something? |
If by spec you mean the http spec, there's nothing about special handling casing of only these basic 6 methods. Per the spec, all http methods are case sensitive. https://www.rfc-editor.org/rfc/rfc7231#section-4
So we really ought to be treating For the original ask here, |
Testing chromium, it does appear that chromium's implementation will automatically convert It even calls out So it would appear that our implemented behavior is correct per the fetch spec and accordingly bends a rule of the HTTP RFC to special case these six methods. Good fun. Quick test across run times for
|
I guess we're still violating spec either way in that if you specify Arguably we should actually expand the underlying KJ HTTP implementation to support arbitrary method names, rather than restricting them to an enum. I'm not excited about doing that, though, as:
So I'd be in favor of just upper-casing all methods. |
To be fair, they probably wouldn't. If they needed a method that didn't work in workers they're more likely to just not use workers than to complain about it not working That said, upper-casing all methods is fine as a first step, I think. Likely requires a compat flag tho. |
Marking as a feature request rather than a bug. |
This introduces a non-standard behavior to uppercase *all* HTTP methods in fetch requests rather than just the limited set defined by the standard. Fixes: #2516
This introduces a non-standard behavior to uppercase *all* HTTP methods in fetch requests rather than just the limited set defined by the standard. Fixes: #2516
This was closed automatically because the fix has been landed. The actual change will not go out to production for another week. Note that the change will become the default behavior for new workers deployed on-or-after Nov 14th (as currently planned). Workers using a compat date prior to that will need to opt in with a compatibility flag. |
The Issue
new Request('', {method: 'patch'})
unexpectedly throws error 'Invalid HTTP method string: patch' butnew Request('', {method: 'PATCH'})
works fine.Minimal Reproducible Example: Workers Playground
Expected Behaviour
Both lowercase and uppercase method string should be supported (other methods support both lowercase and uppercase).
Suspected Cause
L1000 of workerd/api/http.c++:
Presumably, the switch statement will run when a lowercase method string is passed to the constructor as
tryParseHttpMethod
failed to parse the lowercase method string. Yet,PATCH
is missing from the switch statement, so the error is thrown. I am not particularly familiar with C++ so I might be wrong with this.The text was updated successfully, but these errors were encountered: