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
When using fetch() to make a PATCH request, sending the method name in all lowercase (which is arguably a programmer error) results in the actual HTTP request on the wire containing the method name as patch:
Then there's a discussion here, which gives explicit reasoning for not normalizing patch:
"HTTP verbs are case-sensitive. That we normalize a couple of them is already, strictly speaking, against the rules, but we have to do so for compatibility. If you want to use PATCH, write PATCH. If you want patch, write patch. If you want Patch, write Patch. Etc. None of this has anything to do with CORS, they should all work equally well."
thanks for the reference. I agree that 'patch' is a programmer error, but didn't realize the method normalization here was also following the spec. Thanks
Bug Description
When using
fetch()
to make aPATCH
request, sending the method name in all lowercase (which is arguably a programmer error) results in the actual HTTP request on the wire containing the method name aspatch
:whereas if you call fetch with
method: 'get'
, thenormalizeMethod()
function in lib/fetch.js will fix your mistake and translate it to upper-case:Expected Behavior
The
normalizeMethod(method)
undici's util.jsundici/lib/fetch/util.js
Lines 668 to 673 in f6323f6
PATCH
verb in its test so that a value like'patch'
is translated to upper-case.Environment
Node v18.12.1
The text was updated successfully, but these errors were encountered: