@@ -313,21 +313,28 @@ class Request {
313313 // 1. Let method be init["method"].
314314 let method = init . method
315315
316- // 2. If method is not a method or method is a forbidden method, then
317- // throw a TypeError.
318- if ( ! isValidHTTPToken ( method ) ) {
319- throw new TypeError ( `'${ method } ' is not a valid HTTP method.` )
320- }
316+ const mayBeNormalized = normalizeMethodRecord [ method ]
321317
322- if ( forbiddenMethodsSet . has ( method . toUpperCase ( ) ) ) {
323- throw new TypeError ( `'${ method } ' HTTP method is unsupported.` )
324- }
318+ if ( mayBeNormalized !== undefined ) {
319+ // Note: Bypass validation DELETE, GET, HEAD, OPTIONS, POST, PUT, PATCH and these lowercase ones
320+ request . method = mayBeNormalized
321+ } else {
322+ // 2. If method is not a method or method is a forbidden method, then
323+ // throw a TypeError.
324+ if ( ! isValidHTTPToken ( method ) ) {
325+ throw new TypeError ( `'${ method } ' is not a valid HTTP method.` )
326+ }
325327
326- // 3. Normalize method.
327- method = normalizeMethodRecord [ method ] ?? normalizeMethod ( method )
328+ if ( forbiddenMethodsSet . has ( method . toUpperCase ( ) ) ) {
329+ throw new TypeError ( `'${ method } ' HTTP method is unsupported.` )
330+ }
331+
332+ // 3. Normalize method.
333+ method = normalizeMethod ( method )
328334
329- // 4. Set request’s method to method.
330- request . method = method
335+ // 4. Set request’s method to method.
336+ request . method = method
337+ }
331338 }
332339
333340 // 26. If init["signal"] exists, then set signal to it.
0 commit comments