or run

tessl search
Log in

Version

Files

tile.json

task.mdevals/scenario-9/

Proxy-Aware HTTP Client

Build a small HTTP client wrapper that directs traffic through configured proxies, applies TLS credentials, caches DNS lookups, and reuses sockets efficiently.

Capabilities

Routes traffic through proxies

  • When given HTTP/HTTPS proxy URLs and a no-proxy host list, requests to bypassed hosts connect directly while other hosts go through the appropriate proxy. @test

Enforces TLS trust settings

  • With custom CA/cert/key and strict verification enabled, HTTPS requests only succeed when the server certificate chains to the provided CA bundle. @test
  • When strict verification is disabled, the client connects to a self-signed endpoint without throwing. @test

Caches DNS lookups

  • Repeated requests to the same hostname reuse cached DNS results within the TTL, and a fresh lookup occurs after the TTL expires. @test

Pools sockets per origin

  • Concurrent requests share keep-alive sockets up to the configured per-origin limit to avoid opening extra connections. @test

Implementation

@generates

API

export interface ProxyClientConfig {
  httpProxy?: string;
  httpsProxy?: string;
  noProxy?: string[]; // hostnames or domain suffixes to bypass proxies
  ca?: string | Buffer | Array<string | Buffer>;
  cert?: string | Buffer;
  key?: string | Buffer;
  strictSSL?: boolean;
  dns?: {
    ttl?: number;
  };
  maxSockets?: number; // per-origin socket pool limit
}

export interface RequestOptions {
  method?: string;
  headers?: Record<string, string>;
  body?: any;
}

export type FetchClient = (
  url: string,
  options?: RequestOptions
) => Promise<{
  status: number;
  headers: Record<string, string>;
  body: Buffer;
}>;

export function createFetchClient(config: ProxyClientConfig): FetchClient;

Dependencies { .dependencies }

make-fetch-happen { .dependency }

Fetch-compatible HTTP client with proxy routing, agent pooling, DNS cache controls, and TLS configuration hooks. @satisfied-by