evals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
Build an HTTP helper that makes requests to a configurable base URL, handles redirects across protocols, and exposes redirect metadata for callers.
http://service.local/start that responds with a 301 to https://service.local/data yields status 200, body text {"ok":true}, finalUrl https://service.local/data, and records a single redirect entry with 301 and the https location. @testLocation header value, and records exactly one redirect entry for that hop. @testmaxRedirects set to 2, a POST request receiving a 303 to https://api.test/form and then a 301 to https://api.test/final completes with a GET to the final URL, drops the original body on the redirected request, and records both redirects in order without exceeding the limit. @testexport interface RedirectClientOptions {
baseUrl?: string;
maxRedirects?: number;
mode?: 'auto' | 'manual' | 'fail';
}
export interface RedirectMetadata {
status: number;
location: string;
}
export interface RedirectResult {
status: number;
finalUrl: string;
body: any;
redirects: RedirectMetadata[];
location?: string;
}
export function buildClient(defaults?: RedirectClientOptions): {
request(
path: string,
options?: RedirectClientOptions & {
method?: string;
body?: any;
headers?: Record<string, string>;
}
): Promise<RedirectResult>;
};HTTP client used for redirect handling, including redirect modes, max follow configuration, protocol switch support, and redirect-related errors. @satisfied-by