or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

api-requests.mdauthentication.mddependencies.mddiscovery.mdhttp2.mdindex.mdutilities.md
tile.json

http2.mddocs/

HTTP/2 Support

HTTP/2 response interface that maintains compatibility with standard Gaxios responses while supporting HTTP/2 headers. This provides improved performance for Google API requests when HTTP/2 is available.

Capabilities

HTTP/2 Response Interface

Enhanced response interface that extends GaxiosResponse with HTTP/2 compatibility.

/**
 * Enhanced Gaxios response with HTTP/2 compatibility
 * Extends the standard GaxiosResponse with HTTP/2-compatible headers
 */
interface GaxiosResponseWithHTTP2<T = any> extends GaxiosResponse<T> {
  /** HTTP/2-compatible headers as plain object */
  headers: Record<string, string>;
  /** Response data */
  data: T;
  /** HTTP status code */
  status: number;
  /** HTTP status text */
  statusText: string;
  /** Request configuration used */
  config: GaxiosOptions;
  /** Original request object */
  request?: any;
}

Usage Examples:

import { GaxiosResponseWithHTTP2, createAPIRequest } from "googleapis-common";

// API request returns HTTP/2-compatible response
const response: GaxiosResponseWithHTTP2<{items: any[]}> = await createAPIRequest({
  options: {
    url: 'https://www.googleapis.com/drive/v3/files',
    method: 'GET',
    http2: true  // Enable HTTP/2 (handled internally)
  },
  params: {},
  requiredParams: [],
  pathParams: [],
  context: { _options: { auth: googleAuth } }
});

// Access HTTP/2-compatible headers (always plain objects)
console.log('Content-Type:', response.headers['content-type']);
console.log('Response data:', response.data);

// Headers are guaranteed to be plain objects, not Headers instances
const headerKeys = Object.keys(response.headers);
response.headers.forEach // Error: forEach not available (good - it's a plain object)

// Type-safe access to response data
interface ApiData {
  files: Array<{id: string; name: string}>;
}

const typedResponse: GaxiosResponseWithHTTP2<ApiData> = await createAPIRequest({
  options: { url: 'https://www.googleapis.com/drive/v3/files', method: 'GET' },
  params: {},
  requiredParams: [],
  pathParams: [],
  context: { _options: { auth: googleAuth } }
});

console.log(typedResponse.data.files[0].name); // Type-safe access

Integration with Core Functions

The HTTP/2 response type is primarily returned by core API functions when HTTP/2 is used internally.

/**
 * Example showing how GaxiosResponseWithHTTP2 integrates with core functions
 */
interface CoreFunctionIntegration {
  /** createAPIRequest returns HTTP/2-compatible responses */
  createAPIRequest: <T>(params: APIRequestParams<T>) => Promise<GaxiosResponseWithHTTP2<T>>;
  
  /** Response marshalling ensures HTTP/2 compatibility */
  marshallGaxiosResponse: <T>(res?: GaxiosResponse<T>) => GaxiosResponseWithHTTP2<T>;
}

Usage with Response Marshalling:

import { 
  marshallGaxiosResponse, 
  GaxiosResponseWithHTTP2,
  GaxiosResponse 
} from "googleapis-common";

// Convert standard Gaxios response to HTTP/2-compatible format
function processApiResponse<T>(response: GaxiosResponse<T>): GaxiosResponseWithHTTP2<T> {
  // Ensure headers are plain objects for HTTP/2 compatibility
  const http2Response = marshallGaxiosResponse(response);
  
  // Headers are now guaranteed to be plain objects
  console.log(typeof http2Response.headers); // 'object'
  console.log(http2Response.headers['content-type']); // Direct property access
  
  return http2Response;
}