| 508 | // 301/302 demote any non-GET/HEAD method to GET; the body and its content |
| 509 | // headers go with it. Only 307/308 replay the method and body. |
| 510 | const demoteToGet = (init: RequestInit | undefined): RequestInit => { |
| 511 | const headers = new Headers(init?.headers); |
| 512 | for (const name of CONTENT_HEADERS) headers.delete(name); |
| 513 | return { ...init, method: "GET", body: undefined, headers }; |
| 514 | }; |
| 515 | |
| 516 | // The WHATWG rule, which is narrower than "3xx that is not 307/308": 303 |
| 517 | // demotes everything except GET and HEAD, and 301/302 demote POST alone. |