or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

authentication.mdhttp-client.mdindex.mdproxy-support.md
tile.json

http-client.mddocs/

HTTP Client

Core HTTP client functionality providing all standard HTTP methods with automatic proxy detection, redirect handling, retry logic, and both raw and JSON-typed response handling.

Capabilities

HttpClient Class

Main HTTP client class for making requests with extensive configuration options.

/**
 * HTTP client optimized for GitHub Actions with automatic proxy support
 * @param userAgent - User agent string for requests
 * @param handlers - Array of request handlers for authentication
 * @param requestOptions - Configuration options for requests
 */
class HttpClient {
  constructor(
    userAgent?: string,
    handlers?: RequestHandler[],
    requestOptions?: RequestOptions
  );

  userAgent: string | undefined;
  handlers: RequestHandler[];
  requestOptions: RequestOptions | undefined;
}

HTTP Methods

Standard HTTP methods returning HttpClientResponse objects.

/**
 * Perform HTTP GET request
 * @param requestUrl - URL to request
 * @param additionalHeaders - Optional additional headers
 * @returns Promise resolving to HttpClientResponse
 */
get(requestUrl: string, additionalHeaders?: http.OutgoingHttpHeaders): Promise<HttpClientResponse>;

/**
 * Perform HTTP POST request
 * @param requestUrl - URL to request
 * @param data - Request body data as string
 * @param additionalHeaders - Optional additional headers
 * @returns Promise resolving to HttpClientResponse
 */
post(requestUrl: string, data: string, additionalHeaders?: http.OutgoingHttpHeaders): Promise<HttpClientResponse>;

/**
 * Perform HTTP PUT request
 * @param requestUrl - URL to request
 * @param data - Request body data as string
 * @param additionalHeaders - Optional additional headers
 * @returns Promise resolving to HttpClientResponse
 */
put(requestUrl: string, data: string, additionalHeaders?: http.OutgoingHttpHeaders): Promise<HttpClientResponse>;

/**
 * Perform HTTP PATCH request
 * @param requestUrl - URL to request
 * @param data - Request body data as string
 * @param additionalHeaders - Optional additional headers
 * @returns Promise resolving to HttpClientResponse
 */
patch(requestUrl: string, data: string, additionalHeaders?: http.OutgoingHttpHeaders): Promise<HttpClientResponse>;

/**
 * Perform HTTP DELETE request
 * @param requestUrl - URL to request
 * @param additionalHeaders - Optional additional headers
 * @returns Promise resolving to HttpClientResponse
 */
del(requestUrl: string, additionalHeaders?: http.OutgoingHttpHeaders): Promise<HttpClientResponse>;

/**
 * Perform HTTP HEAD request
 * @param requestUrl - URL to request
 * @param additionalHeaders - Optional additional headers
 * @returns Promise resolving to HttpClientResponse
 */
head(requestUrl: string, additionalHeaders?: http.OutgoingHttpHeaders): Promise<HttpClientResponse>;

/**
 * Perform HTTP OPTIONS request
 * @param requestUrl - URL to request
 * @param additionalHeaders - Optional additional headers
 * @returns Promise resolving to HttpClientResponse
 */
options(requestUrl: string, additionalHeaders?: http.OutgoingHttpHeaders): Promise<HttpClientResponse>;

JSON Methods

Type-safe JSON request methods with automatic serialization/deserialization.

/**
 * Perform GET request expecting JSON response with type safety
 * @param requestUrl - URL to request
 * @param additionalHeaders - Optional additional headers
 * @returns Promise resolving to TypedResponse with result of type T
 */
getJson<T>(requestUrl: string, additionalHeaders?: http.OutgoingHttpHeaders): Promise<TypedResponse<T>>;

/**
 * Perform POST request with JSON body and expect JSON response
 * @param requestUrl - URL to request
 * @param obj - Object to serialize as JSON request body
 * @param additionalHeaders - Optional additional headers
 * @returns Promise resolving to TypedResponse with result of type T
 */
postJson<T>(requestUrl: string, obj: any, additionalHeaders?: http.OutgoingHttpHeaders): Promise<TypedResponse<T>>;

/**
 * Perform PUT request with JSON body and expect JSON response
 * @param requestUrl - URL to request
 * @param obj - Object to serialize as JSON request body
 * @param additionalHeaders - Optional additional headers
 * @returns Promise resolving to TypedResponse with result of type T
 */
putJson<T>(requestUrl: string, obj: any, additionalHeaders?: http.OutgoingHttpHeaders): Promise<TypedResponse<T>>;

/**
 * Perform PATCH request with JSON body and expect JSON response
 * @param requestUrl - URL to request
 * @param obj - Object to serialize as JSON request body
 * @param additionalHeaders - Optional additional headers
 * @returns Promise resolving to TypedResponse with result of type T
 */
patchJson<T>(requestUrl: string, obj: any, additionalHeaders?: http.OutgoingHttpHeaders): Promise<TypedResponse<T>>;

Stream Support

Support for streaming request bodies.

/**
 * Send HTTP request with streaming body
 * @param verb - HTTP method (GET, POST, etc.)
 * @param requestUrl - URL to request
 * @param stream - Readable stream for request body
 * @param additionalHeaders - Optional additional headers
 * @returns Promise resolving to HttpClientResponse
 */
sendStream(
  verb: string,
  requestUrl: string,
  stream: NodeJS.ReadableStream,
  additionalHeaders?: http.OutgoingHttpHeaders
): Promise<HttpClientResponse>;

Low-Level Request Methods

Direct request methods for advanced usage.

/**
 * Make raw HTTP request - foundation for all other request methods
 * @param verb - HTTP method
 * @param requestUrl - URL to request
 * @param data - Request body data or stream
 * @param headers - Request headers
 * @returns Promise resolving to HttpClientResponse
 */
request(
  verb: string,
  requestUrl: string,
  data: string | NodeJS.ReadableStream | null,
  headers?: http.OutgoingHttpHeaders
): Promise<HttpClientResponse>;

/**
 * Make raw HTTP request with RequestInfo structure
 * @param info - Pre-configured request information
 * @param data - Request body data or stream
 * @returns Promise resolving to HttpClientResponse
 */
requestRaw(
  info: RequestInfo,
  data: string | NodeJS.ReadableStream | null
): Promise<HttpClientResponse>;

/**
 * Make raw HTTP request with callback pattern
 * @param info - Pre-configured request information
 * @param data - Request body data or stream
 * @param onResult - Callback function for handling result
 */
requestRawWithCallback(
  info: RequestInfo,
  data: string | NodeJS.ReadableStream | null,
  onResult: (err?: Error, res?: HttpClientResponse) => void
): void;

Agent Management

HTTP agent management for proxy and connection pooling.

/**
 * Get HTTP agent for server URL with proxy support
 * @param serverUrl - Target server URL
 * @returns HTTP Agent configured for the URL
 */
getAgent(serverUrl: string): http.Agent;

/**
 * Get proxy agent dispatcher for undici
 * @param serverUrl - Target server URL
 * @returns ProxyAgent dispatcher or undefined
 */
getAgentDispatcher(serverUrl: string): ProxyAgent | undefined;

/**
 * Dispose of client and clean up agents (required when keepAlive is enabled)
 */
dispose(): void;

HttpClientResponse Class

Response object providing access to response data and metadata.

/**
 * HTTP response wrapper providing access to response data
 * @param message - Node.js HTTP IncomingMessage
 */
class HttpClientResponse {
  constructor(message: http.IncomingMessage);
  
  /** Raw HTTP IncomingMessage from Node.js */
  message: http.IncomingMessage;
  
  /**
   * Read response body as string
   * @returns Promise resolving to response body as string
   */
  readBody(): Promise<string>;
  
  /**
   * Read response body as Buffer (optional method)
   * @returns Promise resolving to response body as Buffer
   */
  readBodyBuffer?(): Promise<Buffer>;
}

Utility Functions

Helper functions for HTTP operations.

/**
 * Check if URL uses HTTPS protocol
 * @param requestUrl - URL to check
 * @returns True if URL uses HTTPS
 */
function isHttps(requestUrl: string): boolean;

Usage Examples:

import { HttpClient, HttpClientResponse } from "@actions/http-client";

// Basic GET request
const client = new HttpClient("my-action/1.0");
const response: HttpClientResponse = await client.get("https://api.github.com/user");
console.log(response.message.statusCode); // 200
const body = await response.readBody();

// POST with data
const postResponse = await client.post(
  "https://api.github.com/repos/owner/repo/issues",
  JSON.stringify({ title: "New Issue", body: "Issue description" }),
  { "Content-Type": "application/json" }
);

// Type-safe JSON operations
interface User {
  login: string;
  id: number;
  avatar_url: string;
}

const jsonResponse = await client.getJson<User>("https://api.github.com/user");
if (jsonResponse.result) {
  console.log(`User: ${jsonResponse.result.login}`);
}

// POST JSON with type safety
interface CreateIssueRequest {
  title: string;
  body: string;
  labels?: string[];
}

interface Issue {
  id: number;
  number: number;
  title: string;
}

const newIssue: CreateIssueRequest = {
  title: "Bug report",
  body: "Found a bug",
  labels: ["bug"]
};

const issueResponse = await client.postJson<Issue>(
  "https://api.github.com/repos/owner/repo/issues",
  newIssue
);

// Configure client with options
const configuredClient = new HttpClient("my-action/1.0", [], {
  allowRetries: true,
  maxRetries: 3,
  keepAlive: true,
  socketTimeout: 30000,
  ignoreSslError: false
});

// Remember to dispose when using keepAlive
configuredClient.dispose();