MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / demoteToGet

Function demoteToGet

packages/core/sdk/src/hosted-http-client.ts:510–514  ·  view source on GitHub ↗
(init: RequestInit | undefined)

Source from the content-addressed store, hash-verified

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.
510const 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.

Callers 1

guardFetchFunction · 0.85

Calls 1

deleteMethod · 0.65

Tested by

no test coverage detected