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

Method onHeaders

out/cli.cjs:58172–58262  ·  view source on GitHub ↗
(statusCode, rawHeaders, resume2, statusMessage)

Source from the content-addressed store, hash-verified

58170 if (retryAfterHeader) {
58171 retryAfterHeader = Number(retryAfterHeader);
58172 retryAfterHeader = isNaN(retryAfterHeader) ? calculateRetryAfterHeader(retryAfterHeader) : retryAfterHeader * 1e3;
58173 }
58174 const retryTimeout = retryAfterHeader > 0 ? Math.min(retryAfterHeader, maxTimeout) : Math.min(currentTimeout * timeoutFactor ** counter, maxTimeout);
58175 state2.currentTimeout = retryTimeout;
58176 setTimeout(() => cb(null), retryTimeout);
58177 }
58178 onHeaders(statusCode, rawHeaders, resume2, statusMessage) {
58179 const headers = parseHeaders(rawHeaders);
58180 this.retryCount += 1;
58181 if (statusCode >= 300) {
58182 this.abort(
58183 new RequestRetryError("Request failed", statusCode, {
58184 headers,
58185 count: this.retryCount
58186 })
58187 );
58188 return false;
58189 }
58190 if (this.resume != null) {
58191 this.resume = null;
58192 if (statusCode !== 206) {
58193 return true;
58194 }
58195 const contentRange = parseRangeHeader(headers["content-range"]);
58196 if (!contentRange) {
58197 this.abort(
58198 new RequestRetryError("Content-Range mismatch", statusCode, {
58199 headers,
58200 count: this.retryCount
58201 })
58202 );
58203 return false;
58204 }
58205 if (this.etag != null && this.etag !== headers.etag) {
58206 this.abort(
58207 new RequestRetryError("ETag mismatch", statusCode, {
58208 headers,
58209 count: this.retryCount
58210 })
58211 );
58212 return false;
58213 }
58214 const { start, size, end = size } = contentRange;
58215 assert2(this.start === start, "content-range mismatch");
58216 assert2(this.end == null || this.end === end, "content-range mismatch");
58217 this.resume = resume2;
58218 return true;
58219 }
58220 if (this.end == null) {
58221 if (statusCode === 206) {
58222 const range = parseRangeHeader(headers["content-range"]);
58223 if (range == null) {
58224 return this.handler.onHeaders(
58225 statusCode,
58226 rawHeaders,
58227 resume2,
58228 statusMessage
58229 );

Callers

nothing calls this directly

Calls 5

parseHeadersFunction · 0.85
parseRangeHeaderFunction · 0.85
isFiniteMethod · 0.80
abortMethod · 0.45
onHeadersMethod · 0.45

Tested by

no test coverage detected