XMLHttpRequest for Node.js that emulates the browser XMLHttpRequest object
Overall
score
75%
A lightweight HTTP helper focused on spec-compliant header handling for outgoing requests and response inspection.
X-Trace-Id: abc123), the request includes the header and the returned sentHeaders map exposes it regardless of casing. @testContent-Length) without opting into overrides, that header is omitted from the outgoing request and absent from the sentHeaders map. @testX-Reply-Token: ok-42) and a cookie header, the resolved headers map exposes the custom header case-insensitively and does not surface cookie headers. @test@generates
/**
* Sends an HTTP(S) request with spec-compliant header handling.
*
* @param {string} url - Target endpoint.
* @param {object} [options]
* @param {string} [options.method="GET"] - HTTP method to use.
* @param {Record<string, string>} [options.headers] - Request headers to apply.
* @param {boolean} [options.allowForbiddenHeaders=false] - Whether to permit headers that are normally disallowed.
* @param {string|Buffer} [options.body] - Optional request payload for non-GET/HEAD methods.
* @returns {Promise<{status: number, body: string, headers: Record<string, string>, sentHeaders: Record<string, string>}>}
* Resolves when the request completes with response metadata and normalized header maps.
*/
export async function sendWithHeaders(url, options = {}) {}Node-friendly implementation of the browser request API with header management utilities.
@satisfied-by
Install with Tessl CLI
npx tessl i tessl/npm-xmlhttprequestdocs
evals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
scenario-10