MCPcopy Index your code
hub / github.com/di-sukharev/opencommit / handleRedirect

Function handleRedirect

out/cli.cjs:75547–75563  ·  view source on GitHub ↗
(next, response, maxRetries, currentRetries = 0)

Source from the content-addressed store, hash-verified

75545 return {
75546 name: redirectPolicyName,
75547 async sendRequest(request3, next) {
75548 const response = await next(request3);
75549 return handleRedirect(next, response, maxRetries);
75550 }
75551 };
75552}
75553async function handleRedirect(next, response, maxRetries, currentRetries = 0) {
75554 const { request: request3, status, headers } = response;
75555 const locationHeader = headers.get("location");
75556 if (locationHeader && (status === 300 || status === 301 && allowedRedirect.includes(request3.method) || status === 302 && allowedRedirect.includes(request3.method) || status === 303 && request3.method === "POST" || status === 307) && currentRetries < maxRetries) {
75557 const url2 = new URL(locationHeader, request3.url);
75558 request3.url = url2.toString();
75559 if (status === 303) {
75560 request3.method = "GET";
75561 request3.headers.delete("Content-Length");
75562 delete request3.body;
75563 }
75564 request3.headers.delete("Authorization");
75565 const res = await next(request3);
75566 return handleRedirect(next, res, maxRetries, currentRetries + 1);

Callers 1

sendRequestFunction · 0.85

Calls 5

nextFunction · 0.85
includesMethod · 0.80
getMethod · 0.45
toStringMethod · 0.45
deleteMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…