# sindresorhus/got — codebase unpack

> Canonical page: https://codevetter.com/unpack/got

This is a deterministic Repo Unpack scan of sindresorhus/got — a structural map, not a review, security audit, or maintainer-endorsed description.

- Scanned commit: e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4 (2026-09-20)
- Last upstream commit: More tests
- Generated by codevetter 1.15.0 on 2026-10-02
- 129 files scanned · 1.8 MB

Source inspection; upstream code and tests were not executed.

## Languages

- TypeScript: 84 files
- Markdown: 27 files
- JavaScript: 6 files
- JSON: 2 files
- YAML: 2 files

## Repository structure

- test/ — 57 files
- source/ — 27 files
- documentation/ — 26 files
- .github/ — 7 files
- benchmark/ — 2 files
- media/ — 1 files

Probable source entrypoint: `source/index.ts` (inferred from the tree, not upstream docs)

## Source layout — source/

- source/as-promise/ — 2 files
- source/core/ — 22 files
- source/create.ts — 1 file
- source/index.ts — 1 file
- source/types.ts — 1 file

## Package

- package.json: got v16.0.0 — 50 declared dependencies

## Structural health signals

Average score 8.2/10 across 90 files; 8 hotspots. These are deterministic review leads, not proof of a bug.

## Recent history

- e1d87d2ced01 (2026-09-18) More tests
- df33cdb510c2 (2026-09-18) Replace the request timeout budget arithmetic with one per-request timer
- c36ad5155133 (2026-09-18) Strip one leading byte order mark when decoding UTF-8 and UTF-16LE text
- 0deff95160aa (2026-09-18) Add regression tests for redirect bodies, retry delays, cache bypass, and option resets
- e1ff206d2a9e (2026-09-18) Share the next-request option merging between afterResponse retries and pagination

## Overview

Got 16 is a TypeScript HTTP client library for Node.js 22 and newer, distributed as native ESM. It serves applications that need buffered Promise requests, streaming uploads and downloads, pagination, configurable retries, and detailed transport control. Its distinctive architecture shares a Duplex request engine across both APIs while allowing custom instances, middleware handlers, lifecycle hooks, cache adapters, and request implementations.

## System map

The runtime is a callable library instance built around a shared request engine. Factory code selects the outward Promise or stream interface, while Options centralizes configuration and Request owns transport lifecycle state. HTTP caching, DNS caching, and HTTP/2 pooling occupy separate state boundaries. Distribution and CI are defined by package.json, tsconfig.json, and one inspected GitHub Actions workflow.
- source/index.ts creates the default Got instance from new Options(), an empty handler list, and mutableDefaults:false, then exports the instance plus configuration, response, error, diagnostics, and factory APIs. — [source/index.ts#L1-L27](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/source/index.ts#L1-L27)
- create() constructs Request before dispatching handlers; its lastHandler calls flush() and returns either the Request stream or an asPromise() wrapper according to isStream. — [source/create.ts#L85-L118](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/source/create.ts#L85-L118) [source/create.ts#L120-L148](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/source/create.ts#L120-L148)
- Options owns cloned internals, raw merge history, and explicit-header state; merge() runs init hooks before assigning validated option setters and rejects unknown option keys. — [source/core/options.ts#L1643-L1653](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/source/core/options.ts#L1643-L1653) [source/core/options.ts#L1696-L1738](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/source/core/options.ts#L1696-L1738)
- Request extends Node Duplex and owns response metadata, redirect history, retry count, upload/download counters, active request, queued writes, timeout cancellation, and abort disposal. — [source/core/index.ts#L298-L342](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/source/core/index.ts#L298-L342)
- Default HTTPS transport uses https.request unless http2 is enabled; HTTP/2 auto() negotiates ALPN, chooses requestHttp2 for h2, and falls back to HTTP/1.1. — [source/core/options.ts#L3740-L3748](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/source/core/options.ts#L3740-L3748) [source/core/utils/http2-client.ts#L1674-L1708](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/source/core/utils/http2-client.ts#L1674-L1708)
- HTTP cache wrappers are retained per storage adapter by cacheableStore; DNS state is owned by DnsCache, and HTTP/2 connections are pooled in Http2Agent.sessions with pending-session and queue state. — [source/core/index.ts#L2174-L2179](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/source/core/index.ts#L2174-L2179) [source/core/index.ts#L2292-L2296](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/source/core/index.ts#L2292-L2296) [source/core/utils/dns-cache.ts#L242-L259](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/source/core/utils/dns-cache.ts#L242-L259) [source/core/utils/http2-client.ts#L639-L659](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/source/core/utils/http2-client.ts#L639-L659)
- The npm package is ESM, requires Node >=22, and publishes dist/source; build deletes dist and runs tsc, prepare invokes build, and tsconfig compiles source, test, and benchmark using an ES2024 target. — [package.json#L8-L26](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/package.json#L8-L26) [tsconfig.json#L1-L17](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/tsconfig.json#L1-L17)
- npm test chains XO, tsc --noEmit, and AVA with the tsx ESM import hook; CI specifies npm install and npm run test on Ubuntu for Node 22, 24, and 26. — [package.json#L17-L22](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/package.json#L17-L22) [.github/workflows/main.yml#L8-L26](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/.github/workflows/main.yml#L8-L26)

## Feature catalog

The public surface includes ordinary HTTP calls, buffered body shortcuts, Duplex streams, and asynchronous pagination. Reliability controls include redirects, retry rules, timeouts, abort signals, and structured errors. Custom instances and hooks let applications adapt the client to particular services. Transport, caching, and diagnostic APIs expose capabilities needed by Node applications beyond a basic request wrapper.
- Got installs get, post, put, patch, head, delete, and query shortcuts for both Promise and stream calls; arbitrary configured methods remain available through Options.method. — [source/create.ts#L30-L38](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/source/create.ts#L30-L38) [source/create.ts#L353-L363](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/source/create.ts#L353-L363) [source/core/options.ts#L3219-L3223](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/source/core/options.ts#L3219-L3223)
- Buffered requests expose .json(), .text(), and .buffer(); responseType selects parsing, resolveBodyOnly selects the return shape, and buffer results are Uint8Array rather than necessarily Node Buffer. — [source/as-promise/index.ts#L151-L160](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/source/as-promise/index.ts#L151-L160) [source/as-promise/index.ts#L288-L305](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/source/as-promise/index.ts#L288-L305) [source/core/response.ts#L178-L204](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/source/core/response.ts#L178-L204) [source/as-promise/types.ts#L13-L25](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/source/as-promise/types.ts#L13-L25)
- Uploads accept JSON, URL-encoded forms, native FormData, strings, byte views, Node streams, and iterable bodies; streams expose request, response, redirect, uploadProgress, and downloadProgress events. — [source/core/index.ts#L973-L1008](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/source/core/index.ts#L973-L1008) [source/core/index.ts#L1811-L1839](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/source/core/index.ts#L1811-L1839) [source/as-promise/index.ts#L30-L36](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/source/as-promise/index.ts#L30-L36)
- Reliability controls include two retries by default for configured methods/errors/statuses, exponential delay with noise and Retry-After handling, eight timeout settings, and AbortSignal cancellation. — [source/core/options.ts#L1299-L1336](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/source/core/options.ts#L1299-L1336) [source/core/calculate-retry-delay.ts#L16-L41](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/source/core/calculate-retry-delay.ts#L16-L41) [source/core/timed-out.ts#L14-L23](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/source/core/timed-out.ts#L14-L23) [source/core/index.ts#L910-L921](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/source/core/index.ts#L910-L921)
- Redirects follow by default with maxRedirects:10; method rewriting distinguishes 303, cross-origin POST 301/302, optional methodRewriting, and body-preserving 307/308. — [source/core/options.ts#L1282-L1283](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/source/core/options.ts#L1282-L1283) [source/core/index.ts#L1258-L1260](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/source/core/index.ts#L1258-L1260) [source/core/index.ts#L1301-L1318](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/source/core/index.ts#L1301-L1318)
- got.extend() composes defaults and handlers; lifecycle hooks include init, beforeRequest, beforeRedirect, beforeRetry, beforeCache, afterResponse, and beforeError. — [source/create.ts#L154-L181](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/source/create.ts#L154-L181) [source/core/options.ts#L1273-L1280](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/source/core/options.ts#L1273-L1280) [documentation/lets-make-a-plugin.md#L85-L115](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/documentation/lets-make-a-plugin.md#L85-L115)
- got.paginate()/each yield items asynchronously and paginate.all collects them; callbacks control transformation, filtering, continuation, and next-request options, with count/request limits and backoff. — [source/create.ts#L194-L204](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/source/create.ts#L194-L204) [source/create.ts#L224-L255](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/source/create.ts#L224-L255) [source/create.ts#L346-L351](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/source/create.ts#L346-L351)
- Advanced integrations include TLS configuration, custom agents and connections, DNS caching, opt-in Unix sockets, cookie jars, HTTP cache adapters, diagnostic channels, and RequestError metadata. — [source/core/options.ts#L3556-L3593](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/source/core/options.ts#L3556-L3593) [source/core/options.ts#L2187-L2208](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/source/core/options.ts#L2187-L2208) [source/core/options.ts#L2527-L2540](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/source/core/options.ts#L2527-L2540) [source/core/diagnostics-channel.ts#L6-L14](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/source/core/diagnostics-channel.ts#L6-L14) [source/core/errors.ts#L48-L84](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/source/core/errors.ts#L48-L84)

## Data flow

Inputs become normalized Options before native transport options are constructed. Request serializes payloads, prepares generated headers, and reconciles hook mutations before sending data. Incoming messages become decorated responses and either flow outward as stream chunks or accumulate for Promise parsing. Cache adapters, cookie jars, DNS stores, and HTTP/2 pools retain different kinds of state across calls.
- The public factory rejects url properties inside options objects; Options clones defaults, merges overrides, then assigns the URL so explicit searchParams replace URL query parameters. — [source/create.ts#L40-L68](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/source/create.ts#L40-L68) [source/core/options.ts#L1643-L1684](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/source/core/options.ts#L1643-L1684) [source/core/options.ts#L2172-L2175](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/source/core/options.ts#L2172-L2175)
- _finalizeBody() turns form into URLSearchParams text, JSON into stringifyJson output, and native FormData into a serialized body; generated content-type and known content-length headers accompany those transformations. — [source/core/index.ts#L973-L1008](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/source/core/index.ts#L973-L1008) [source/core/index.ts#L1011-L1028](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/source/core/index.ts#L1011-L1028)
- _makeRequest() derives Basic authorization from username/password unless overridden or explicitly omitted, obtains cookie strings from the jar, then awaits beforeRequest hooks before reconciling changed headers and URL boundaries. — [source/core/index.ts#L2422-L2424](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/source/core/index.ts#L2422-L2424) [source/core/index.ts#L2464-L2474](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/source/core/index.ts#L2464-L2474) [source/core/index.ts#L2489-L2519](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/source/core/index.ts#L2489-L2519) [source/core/index.ts#L2544-L2567](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/source/core/index.ts#L2544-L2567)
- createNativeRequestOptions() maps TLS settings, headers, agent, lookup, family, and createConnection into Node transport fields; Unix URLs become socketPath/path options only when enableUnixSockets permits them. — [source/core/options.ts#L3536-L3554](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/source/core/options.ts#L3536-L3554) [source/core/options.ts#L3556-L3593](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/source/core/options.ts#L3556-L3593)
- _onResponseBase() attaches sanitized final URL, original request URL, redirects, request reference, cache origin, IP, and retry count; final responses are decompressed when enabled, while followed redirect bodies are drained without decompression. — [source/core/index.ts#L1073-L1094](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/source/core/index.ts#L1073-L1094) [source/core/index.ts#L1249-L1256](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/source/core/index.ts#L1249-L1256)
- Promise mode gathers chunks with _setRawBody() into Uint8Array, optionally caches incremental UTF-8 decoding, then parseBody() produces text, JSON, or bytes; stream mode emits response and forwards readable data without that buffered completion gate. — [source/core/index.ts#L1529-L1552](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/source/core/index.ts#L1529-L1552) [source/core/index.ts#L1594-L1620](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/source/core/index.ts#L1594-L1620) [source/core/response.ts#L178-L204](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/source/core/response.ts#L178-L204)
- Cross-origin follow-up options are merged through mergeNextRequestOptions(), which handles explicit body replacement, cookie-jar removal, URL/query overrides, and stripping inherited credentials/body unless replacements were explicitly supplied. — [source/core/options.ts#L2905-L2921](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/source/core/options.ts#L2905-L2921) [source/core/options.ts#L2932-L2959](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/source/core/options.ts#L2932-L2959) [source/as-promise/index.ts#L100-L131](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/source/as-promise/index.ts#L100-L131) [source/create.ts#L310-L315](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/source/create.ts#L310-L315)
- State retention is delegated: Set-Cookie values are written to the supplied jar in wire order, HTTP representations use the supplied cache adapter, and DnsCache stores resolved entries with clear-version checks that prevent stale asynchronous writes from surviving invalidation. — [source/core/index.ts#L1221-L1233](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/source/core/index.ts#L1221-L1233) [source/core/index.ts#L2292-L2296](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/source/core/index.ts#L2292-L2296) [source/core/utils/dns-cache.ts#L562-L588](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/source/core/utils/dns-cache.ts#L562-L588)

## Behavior traces

Eight source walks cover instance initialization and the main user-visible execution paths. The Promise and stream paths share normalization and transport setup but differ in upload completion and response buffering. Redirect and retry paths preserve or replace request state under distinct rules. Cache reuse, cookie persistence, and pagination reconnect retained state to later requests.
- Initialization: source/index.ts creates Options → create(defaults) clones options/handlers → attaches extend, pagination, stream, and method shortcuts → freezes defaults unless mutableDefaults → exports got. — [source/index.ts#L5-L13](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/source/index.ts#L5-L13) [source/create.ts#L48-L59](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/source/create.ts#L48-L59) [source/create.ts#L346-L378](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/source/create.ts#L346-L378)
- JSON POST: got.post() → makeRequest() → new Request/new Options → handler chain/lastHandler → flush() → _finalizeBody() serializes JSON → _makeRequest(); response buffering precedes parseBody() and afterResponse hooks, then .json() returns the parsed body. — [source/create.ts#L85-L118](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/source/create.ts#L85-L118) [source/core/index.ts#L451-L473](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/source/core/index.ts#L451-L473) [source/core/index.ts#L1000-L1008](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/source/core/index.ts#L1000-L1008) [source/as-promise/index.ts#L57-L100](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/source/as-promise/index.ts#L57-L100) [source/as-promise/index.ts#L288-L297](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/source/as-promise/index.ts#L288-L297)
- Stream upload: got.stream.post() → makeRequest(...,true) → Request.flush() → _onRequest() → _sendBody(); without a configured body, a payload-capable stream waits for caller writes/end, then response data is exposed through the Duplex. — [source/create.ts#L353-L362](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/source/create.ts#L353-L362) [source/core/index.ts#L1724-L1733](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/source/core/index.ts#L1724-L1733) [source/core/index.ts#L1862-L1877](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/source/core/index.ts#L1862-L1877) [source/core/index.ts#L1513-L1552](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/source/core/index.ts#L1513-L1552)
- Redirect: _onResponseBase() evaluates redirect policy → drains response → checks maxRedirects → clones Options/resolves Location → rewrites method/body and strips cross-origin state → runs beforeRedirect hooks → validates replayability → emits redirect and calls _makeRequest() again. — [source/core/index.ts#L1249-L1299](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/source/core/index.ts#L1249-L1299) [source/core/index.ts#L1301-L1339](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/source/core/index.ts#L1301-L1339) [source/core/index.ts#L1359-L1378](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/source/core/index.ts#L1359-L1378) [source/core/index.ts#L1445-L1481](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/source/core/index.ts#L1445-L1481)
- Retry: _beforeError() normalizes failure and Retry-After → calculateRetryDelay() and optional calculateDelay → backoff timer → beforeRetry hooks → cleanup/body preservation → retry event; asPromise() rejects an unchanged consumed body or constructs and flushes the next Request. — [source/core/index.ts#L494-L509](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/source/core/index.ts#L494-L509) [source/core/index.ts#L534-L609](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/source/core/index.ts#L534-L609) [source/core/index.ts#L625-L687](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/source/core/index.ts#L625-L687) [source/as-promise/index.ts#L209-L237](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/source/as-promise/index.ts#L209-L237)
- HTTP cache reuse: _makeRequest() selects eligible bodies → _prepareCache() creates/reuses a CacheableRequest wrapper → _createCacheableRequest() resolves a native request or cached ResponseLike → _onResponse() follows the normal response path and sets isFromCache; freshness/revalidation policy belongs to the dependency. — [source/core/index.ts#L2702-L2720](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/source/core/index.ts#L2702-L2720) [source/core/index.ts#L2174-L2179](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/source/core/index.ts#L2174-L2179) [source/core/index.ts#L2299-L2346](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/source/core/index.ts#L2299-L2346) [source/core/index.ts#L1073-L1079](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/source/core/index.ts#L1073-L1079) [documentation/cache.md#L5-L9](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/documentation/cache.md#L5-L9)
- Cookie persistence: _makeRequest() awaits getCookieString(URL) → sends generated Cookie unless omitted → _onResponseBase() writes each Set-Cookie sequentially → only then completes response/redirect handling; a later call consults the same caller-owned jar. — [source/core/index.ts#L2455-L2465](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/source/core/index.ts#L2455-L2465) [source/core/index.ts#L2502-L2507](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/source/core/index.ts#L2502-L2507) [source/core/index.ts#L1213-L1246](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/source/core/index.ts#L1213-L1246)
- Pagination: paginateEach() normalizes/validates callbacks → waits inter-page backoff → forces full-response resolution → calls got() → transform/filter/shouldContinue → yields items under limits → paginate() supplies follow-up options → applies cross-origin merge rules and refreshes pagination settings. — [source/create.ts#L194-L230](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/source/create.ts#L194-L230) [source/create.ts#L235-L275](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/source/create.ts#L235-L275) [source/create.ts#L277-L315](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/source/create.ts#L277-L315) [source/create.ts#L329-L342](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/source/create.ts#L329-L342)

## Testing signals

Tests and CI were inspected, not executed; no passing result or measured coverage is asserted. The inspected suite uses AVA, TypeScript assertions, local HTTP servers, and selected fake timers. Regression cases exercise transport identity, cross-origin behavior, buffering, caching, retries, and timeout budgets. The inventory is bounded, and explicit skipped or expected-failing cases limit what test presence establishes.
- AVA runs test/* excluding *.types.ts, treats TypeScript as modules, uses a ten-minute timeout, and disables worker threads; the script first runs XO and tsc --noEmit with tsx supplying ESM execution support. — [package.json#L17-L19](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/package.json#L17-L19) [package.json#L107-L116](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/package.json#L107-L116)
- withServer creates a real HTTP server, optionally installs fake timers, builds a Got instance with that server's prefixUrl, and closes the server in finally; maintainer.md explicitly discourages nock because of process-wide interception. — [test/helpers/with-server.ts#L22-L39](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/test/helpers/with-server.ts#L22-L39) [test/helpers/with-server.ts#L49-L78](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/test/helpers/with-server.ts#L49-L78) [maintainer.md#L3-L5](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/maintainer.md#L3-L5)
- Promise tests assert request/response events, raw Uint8Array behavior with decompression disabled, and abort propagation through .json(); extend.types.ts checks inferred instance/default merges using expect-type under TypeScript checking. — [test/promise.ts#L9-L50](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/test/promise.ts#L9-L50) [test/promise.ts#L66-L99](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/test/promise.ts#L66-L99) [test/extend.types.ts#L20-L49](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/test/extend.types.ts#L20-L49) [tsconfig.json#L13-L17](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/tsconfig.json#L13-L17)
- Cross-origin regressions distinguish POST 302 body removal from 307 body preservation with credential stripping; pagination tests check authorization removal and rejection of absolute Link URLs or in-place origin mutations. — [test/redirects.ts#L933-L947](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/test/redirects.ts#L933-L947) [test/redirects.ts#L1287-L1308](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/test/redirects.ts#L1287-L1308) [test/pagination.ts#L807-L836](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/test/pagination.ts#L807-L836) [test/pagination.ts#L1453-L1495](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/test/pagination.ts#L1453-L1495)
- Retry tests assert a consumed generator produces only one upload and a replay error; request-timeout tests cover slow redirects, stalled downloads/uploads, and the intentional exclusion of initial beforeRequest hook time. — [test/retry.ts#L1863-L1892](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/test/retry.ts#L1863-L1892) [test/request-timeout.ts#L15-L46](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/test/request-timeout.ts#L15-L46) [test/request-timeout.ts#L71-L96](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/test/request-timeout.ts#L71-L96) [test/request-timeout.ts#L113-L128](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/test/request-timeout.ts#L113-L128)
- Transport tests assert HTTP/2 pooled-socket reuse and separation by checkServerIdentity function identity; DnsCache tests inject resolvers to verify answer reuse and requested IPv4-family selection. — [test/https.ts#L2548-L2564](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/test/https.ts#L2548-L2564) [test/https.ts#L2594-L2619](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/test/https.ts#L2594-L2619) [test/dns-cache.ts#L45-L90](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/test/dns-cache.ts#L45-L90)
- Cache tests assert cacheable GET/POST reuse, QUERY bypass, 304 refresh of existing metadata, and uncached native FormData/Web-stream uploads; a separate test.failing documents missing new metadata from 304 responses. — [test/cache.ts#L35-L73](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/test/cache.ts#L35-L73) [test/cache.ts#L1053-L1100](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/test/cache.ts#L1053-L1100) [test/cache.ts#L1327-L1366](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/test/cache.ts#L1327-L1366)
- Inspection identified a skipped unhandled-body-error test and an expected-failing cache case; CI specifies Ubuntu Node 22/24/26 and npm test, while coverage is a separate c8 script with text/HTML/lcov output and is not invoked by the inspected workflow. — [test/stream.ts#L929-L939](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/test/stream.ts#L929-L939) [test/cache.ts#L1082-L1100](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/test/cache.ts#L1082-L1100) [.github/workflows/main.yml#L13-L26](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/.github/workflows/main.yml#L13-L26) [package.json#L18-L19](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/package.json#L18-L19) [package.json#L118-L127](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/package.json#L118-L127)

## Risk map

These are source observations and explicitly labeled hypotheses, not confirmed vulnerabilities. Important boundaries include inherited credentials, redirect payload replay, diagnostic subscribers, local sockets, and caller-supplied transport settings. Async hooks and stream cleanup couple several request states, making seemingly small edits consequential. Buffering and a documented cache dependency limitation warrant targeted validation in a later execution-authorized task.
- Cross-origin 307/308 redirects intentionally preserve replayable bodies while removing inherited credentials; applications cannot equate credential stripping with preventing payload disclosure to a redirect destination. — [source/core/index.ts#L1301-L1326](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/source/core/index.ts#L1301-L1326) [test/redirects.ts#L1287-L1308](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/test/redirects.ts#L1287-L1308)
- allowAbsoluteUrls:false restricts explicit inputs with prefixUrl, but internal redirects temporarily permit resolved absolute URLs; Unix sockets are separately opt-in and redirects cannot switch socket paths. These controls have distinct scopes. — [source/core/options.ts#L1021-L1057](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/source/core/options.ts#L1021-L1057) [source/core/options.ts#L2147-L2159](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/source/core/options.ts#L2147-L2159) [source/core/index.ts#L1282-L1293](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/source/core/index.ts#L1282-L1293) [source/core/index.ts#L1332-L1339](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/source/core/index.ts#L1332-L1339)
- Diagnostic URLs have username/password removed, but request-start and response-start publications include full headers; subscribers therefore receive potentially sensitive Authorization, Cookie, or Set-Cookie values. — [source/core/utils/strip-url-auth.ts#L4-L8](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/source/core/utils/strip-url-auth.ts#L4-L8) [source/core/index.ts#L1646-L1652](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/source/core/index.ts#L1646-L1652) [source/core/index.ts#L1116-L1123](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/source/core/index.ts#L1116-L1123) [source/core/diagnostics-channel.ts#L109-L112](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/source/core/diagnostics-channel.ts#L109-L112)
- Hypothesis: large or highly compressed responses can impose substantial memory pressure in Promise mode because _setRawBody() materializes chunks and concatenated bytes, while text/JSON paths can also retain decoded strings; strictContentLength validates transferred length rather than a decoded-size ceiling. (inferred) — [source/core/index.ts#L1594-L1620](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/source/core/index.ts#L1594-L1620) [source/core/index.ts#L937-L947](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/source/core/index.ts#L937-L947) [source/core/index.ts#L1092-L1101](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/source/core/index.ts#L1092-L1101)
- timeout.request starts only once initial setup is complete, so an initial beforeRequest hook can outlast that configured budget; a dedicated regression test explicitly expects a 1500ms hook to succeed with a 1000ms request timeout. — [source/core/index.ts#L2516-L2520](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/source/core/index.ts#L2516-L2520) [source/core/index.ts#L2725-L2727](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/source/core/index.ts#L2725-L2727) [source/core/index.ts#L2353-L2364](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/source/core/index.ts#L2353-L2364) [test/request-timeout.ts#L113-L128](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/test/request-timeout.ts#L113-L128)
- Retry cleanup is tightly coupled to body identity: Request temporarily clears a replacement body during destroy(), preserves it for the next attempt, and asPromise rejects unchanged non-replayable bodies; incorrect ordering can destroy the replacement or reuse consumed input. — [source/core/index.ts#L625-L660](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/source/core/index.ts#L625-L660) [source/as-promise/index.ts#L220-L231](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/source/as-promise/index.ts#L220-L231) [source/core/utils/is-non-replayable-body.ts#L3-L9](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/source/core/utils/is-non-replayable-body.ts#L3-L9)
- HTTP/2 protocol/session identity includes certificate settings, rejectUnauthorized, checkServerIdentity, and lookup identity; removing these key components could defeat the separation that the checkServerIdentity regression test expects. (inferred) — [source/core/utils/http2-client.ts#L209-L233](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/source/core/utils/http2-client.ts#L209-L233) [source/core/utils/http2-client.ts#L319-L327](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/source/core/utils/http2-client.ts#L319-L327) [source/core/utils/http2-client.ts#L725-L728](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/source/core/utils/http2-client.ts#L725-L728) [test/https.ts#L2594-L2619](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/test/https.ts#L2594-L2619)
- test/cache.ts explicitly attributes dropped newly introduced 304 metadata to http-cache-semantics and marks the scenario test.failing; this is a documented source-level limitation, not a failure reproduced during this inspection. — [test/cache.ts#L1082-L1100](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/test/cache.ts#L1082-L1100)

## Extension points

Extension is primarily instance composition and callback-based customization. Handler middleware wraps the request interface, while lifecycle hooks operate at specific normalization and transport stages. Request functions, connection factories, agents, cookie jars, and cache adapters substitute infrastructure without replacing the public client. Pagination and JSON callbacks customize data interpretation and follow-up behavior.
- got.extend(...instancesOrOptions) merges option histories, concatenates handlers, carries mutableDefaults settings, and calls create() to produce a new instance. — [source/create.ts#L154-L181](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/source/create.ts#L154-L181)
- HandlerFunction receives Options and next(options); iterateHandlers dispatches them in order and preserves Promise helper descriptors on wrapped results. Stream handlers must return synchronously according to the instance documentation. — [source/types.ts#L42-L48](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/source/types.ts#L42-L48) [source/create.ts#L120-L144](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/source/create.ts#L120-L144) [documentation/10-instances.md#L70-L85](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/documentation/10-instances.md#L70-L85)
- Hook registration accepts only recognized hook events and function arrays; merging appends hooks, and init hooks can consume custom raw options into context before unknown-option validation. — [source/core/options.ts#L2447-L2473](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/source/core/options.ts#L2447-L2473) [source/core/options.ts#L1712-L1728](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/source/core/options.ts#L1712-L1728) [documentation/lets-make-a-plugin.md#L87-L111](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/documentation/lets-make-a-plugin.md#L87-L111)
- The request option can supply a custom request/response synchronously or asynchronously; undefined results fall back to the built-in transport. A beforeRequest hook can short-circuit later hooks by returning a request or response. — [source/core/options.ts#L3606-L3635](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/source/core/options.ts#L3606-L3635) [source/core/options.ts#L3775-L3785](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/source/core/options.ts#L3775-L3785) [source/core/index.ts#L2516-L2531](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/source/core/index.ts#L2516-L2531)
- Transport customization uses protocol-specific agents, createConnection, dnsLookup/dnsCache, and h2session; stable wrapped DNS lookup identity is deliberately maintained for HTTP/2 session reuse. — [source/core/options.ts#L1195-L1206](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/source/core/options.ts#L1195-L1206) [source/core/options.ts#L3578-L3593](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/source/core/options.ts#L3578-L3593) [source/core/utils/http2-client.ts#L1686-L1699](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/source/core/utils/http2-client.ts#L1686-L1699)
- Cache storage accepts Map-like adapters, with QuickLRU TTL translation; beforeCache hooks synchronously mutate cache metadata or return false to prevent storage, and Promise returns are rejected. — [documentation/cache.md#L27-L42](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/documentation/cache.md#L27-L42) [source/core/options.ts#L1209-L1235](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/source/core/options.ts#L1209-L1235) [source/core/index.ts#L2206-L2231](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/source/core/index.ts#L2206-L2231)
- Pagination customization replaces transform, filter, shouldContinue, and paginate callbacks; paginate can stop with false or supply updated options, and returned pagination settings affect subsequent iterations. — [source/create.ts#L198-L204](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/source/create.ts#L198-L204) [source/create.ts#L235-L255](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/source/create.ts#L235-L255) [source/create.ts#L263-L275](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/source/create.ts#L263-L275) [source/create.ts#L339-L342](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/source/create.ts#L339-L342)
- parseJson/stringifyJson replace JSON codecs; cookieJar implements getCookieString/setCookie, with legacy callback jars promisified; diagnostics subscribers consume typed lifecycle messages through Node channels. — [source/core/options.ts#L1297-L1298](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/source/core/options.ts#L1297-L1298) [source/core/response.ts#L193-L199](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/source/core/response.ts#L193-L199) [source/core/index.ts#L1005-L1008](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/source/core/index.ts#L1005-L1008) [source/core/options.ts#L2195-L2208](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/source/core/options.ts#L2195-L2208) [source/core/diagnostics-channel.ts#L6-L14](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/source/core/diagnostics-channel.ts#L6-L14)

## Contributor handoff

Begin at the factory, normalized options, shared Request engine, and Promise adapter before editing public behavior. Tests and CI were inspected, not executed, and this brief does not establish exhaustive coverage or passing checks. Focus changes on the owning layer while checking the corresponding Promise, stream, and follow-up paths. Preserve public typing, generated-header distinctions, and resource cleanup contracts.
- Read source/index.ts and create.ts for public dispatch, Options for normalization, Request.flush() for lifecycle entry, and asPromise() for buffered completion before changing request semantics. — [source/index.ts#L1-L27](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/source/index.ts#L1-L27) [source/create.ts#L85-L118](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/source/create.ts#L85-L118) [source/core/index.ts#L451-L490](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/source/core/index.ts#L451-L490) [source/as-promise/index.ts#L38-L55](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/source/as-promise/index.ts#L38-L55)
- Public API changes must account for source/types.ts, RequestPromise types, exports, and compile-time assertions; RequestPromise is intentionally a type alias and does not support interface-merging augmentation. — [source/types.ts#L42-L72](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/source/types.ts#L42-L72) [source/as-promise/types.ts#L4-L30](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/source/as-promise/types.ts#L4-L30) [source/index.ts#L15-L27](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/source/index.ts#L15-L27) [test/extend.types.ts#L20-L49](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/test/extend.types.ts#L20-L49)
- Preserve the public URL call contract and explicit-header semantics: url inside options objects is rejected, while sensitive follow-up headers explicitly supplied by callers are handled differently from inherited/generated headers. — [source/create.ts#L40-L68](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/source/create.ts#L40-L68) [source/core/options.ts#L2850-L2884](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/source/core/options.ts#L2850-L2884) [source/core/index.ts#L2468-L2474](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/source/core/index.ts#L2468-L2474)
- For later authorized validation, select relevant AVA files such as retry.ts, redirects.ts, pagination.ts, request-timeout.ts, cache.ts, or https.ts under the tsx import hook; npm run test is the repository's combined lint/type/runtime check and coverage has its own script. — [package.json#L17-L19](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/package.json#L17-L19) [test/retry.ts#L1863-L1892](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/test/retry.ts#L1863-L1892) [test/pagination.ts#L1453-L1495](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/test/pagination.ts#L1453-L1495) [test/request-timeout.ts#L15-L29](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/test/request-timeout.ts#L15-L29)
- Use withServer/withServer.exec and real local test servers for regressions; maintainer.md identifies nock's process-wide interception as a test isolation trap. — [maintainer.md#L3-L5](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/maintainer.md#L3-L5) [test/helpers/with-server.ts#L22-L31](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/test/helpers/with-server.ts#L22-L31) [test/helpers/with-server.ts#L67-L73](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/test/helpers/with-server.ts#L67-L73) [test/redirects.ts#L910-L915](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/test/redirects.ts#L910-L915)
- Preserve tab indentation, LF endings, ESM .js import suffixes, and npm's package-lock=false configuration; generated dist is ignored, and npm run build deletes it before compilation. — [.editorconfig#L1-L12](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/.editorconfig#L1-L12) [.npmrc#L1-L1](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/.npmrc#L1-L1) [.gitignore#L1-L5](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/.gitignore#L1-L5) [source/index.ts#L1-L3](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/source/index.ts#L1-L3) [package.json#L21-L25](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/package.json#L21-L25)
- Treat retry/body cleanup, cross-origin follow-up merges, and HTTP/2 pool identity as coupled edit boundaries; shared helpers are used by both afterResponse retry callbacks and pagination. — [source/core/index.ts#L625-L660](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/source/core/index.ts#L625-L660) [source/core/options.ts#L2887-L2921](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/source/core/options.ts#L2887-L2921) [source/as-promise/index.ts#L125-L131](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/source/as-promise/index.ts#L125-L131) [source/create.ts#L310-L315](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/source/create.ts#L310-L315) [source/core/utils/http2-client.ts#L209-L233](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/source/core/utils/http2-client.ts#L209-L233)
- Tests and CI in this brief were inspected, not executed; the Ubuntu-only workflow, skipped body-error test, and expected-failing 304 metadata test define concrete limits on evidence, so future agents must report actual runtime results separately. — [.github/workflows/main.yml#L13-L26](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/.github/workflows/main.yml#L13-L26) [test/stream.ts#L929-L939](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/test/stream.ts#L929-L939) [test/cache.ts#L1082-L1100](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/test/cache.ts#L1082-L1100)

Source repository: https://github.com/sindresorhus/got
Full evidence corpus: https://github.com/Codevetter/codevetter/tree/main/benchmarks/repo-unpacks/got.json

## Public product links

- [CodeVetter](https://codevetter.com/)
- [Download](https://codevetter.com/download)
- [Documentation](https://codevetter.com/docs/)
- [Source](https://github.com/Codevetter/codevetter)
