CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-xmlhttprequest

XMLHttpRequest for Node.js that emulates the browser XMLHttpRequest object

Overall
score

75%

Overview
Eval results
Files

task.mdevals/scenario-4/

Redirect Resolver

Implement a helper that issues HTTP(S) requests and automatically follows redirect responses while exposing the full redirect chain.

Capabilities

Follow basic redirects

  • Requesting a URL that responds with a 301 or 302 and a Location header returns the final 200 response body and includes both the original and final URLs in the redirect history. @test

Handle 303 method switch

  • Starting from a POST request that receives a 303 redirect, the helper retries the redirected request as a GET without a body and returns the target's 200 response text while preserving the redirect history order. @test

Preserve method for 307

  • When a POST request receives a 307 redirect, the helper repeats the POST (including its original body) to the redirected URL and returns the target's 200 response text; the redirect history lists each hop. @test

Implementation

@generates

API

export interface RedirectResult {
  status: number;
  body: string;
  history: string[];
}

export interface RequestOptions {
  method?: 'GET' | 'POST' | 'PUT' | 'DELETE';
  headers?: Record<string, string>;
  body?: string | Buffer;
  timeoutMs?: number;
}

export function requestWithRedirects(
  url: string,
  options?: RequestOptions
): Promise<RedirectResult>;

Dependencies { .dependencies }

xmlhttprequest { .dependency }

Provides a browser-style HTTP request interface with automatic redirect handling.

Install with Tessl CLI

npx tessl i tessl/npm-xmlhttprequest

tile.json