CtrlK
CommunityDocumentationLog inGet started
Tessl Logo

tessl/npm-xmlhttprequest

tessl install tessl/npm-xmlhttprequest@1.8.0

XMLHttpRequest for Node.js that emulates the browser XMLHttpRequest object

Agent Success

Agent success rate when using this tile

75%

Improvement

Agent success rate improvement when using this tile compared to baseline

1.15x

Baseline

Agent success rate without this tile

65%

task.mdevals/scenario-2/

Streaming Response Collector

Build a helper that issues an HTTP request and progressively reports incoming text chunks while also exposing the final status code and status message provided by the server.

Capabilities

Streams chunks before completion

  • When the server returns multiple text fragments (for example "alpha", "beta", "gamma") with short delays, the provided chunk handler is called for each fragment in order before the request finishes, and the resolved body concatenates them in the same order to "alphabetagamma". @test

Returns final status and message

  • For a successful response returning status 200 and message "OK READY", the function resolves with an object containing status: 200, statusText: "OK READY", and a body containing the full response text. @test

Surfaces error details with partial data

  • If the server responds with status 503 and a short text payload "busy", the function resolves with status: 503, preserves the status message from the server, and returns a body of "busy" even though the response indicates failure. @test

Handles header-only responses

  • When the server sends a header-only response (such as a HEAD request), the function returns the reported status and status message, an empty string body, and does not invoke the chunk handler. @test

Implementation

@generates

API

/**
 * Performs an HTTP request that streams text chunks to an optional handler and resolves when the response finishes.
 *
 * @param {Object} options
 * @param {string} options.url - Target URL to request.
 * @param {string} [options.method="GET"] - HTTP method to use; must support GET and HEAD at minimum.
 * @param {(chunk: string) => void} [options.onChunk] - Invoked immediately for each incoming text fragment, in order.
 * @returns {Promise<{ status: number, statusText: string, body: string }>} Resolves with final status details and concatenated body.
 */
export async function fetchWithStreaming(options);

Dependencies { .dependencies }

xmlhttprequest { .dependency }

Provides an HTTP client capable of streaming response text and exposing status information.

Version

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
npmpkg:npm/xmlhttprequest@1.8.x
tile.json