Logos DX
    Preparing search index...

    Manages HTTP headers for FetchEngine with event emission.

    Wraps PropertyStore with FetchEngine-specific event emission. Pulls initial headers and validation from engine options.

    // Access via engine.headers
    engine.headers.set('Authorization', 'Bearer token');
    engine.headers.set({ 'X-API-Key': 'abc', 'X-Request-ID': '123' });

    // Method-specific headers
    engine.headers.set('Content-Type', 'application/json', 'POST');

    // Remove headers
    engine.headers.remove('Authorization');
    engine.headers.remove(['X-API-Key', 'X-Request-ID']);

    // Check if header exists
    if (engine.headers.has('Authorization')) { ... }

    // Get resolved headers for a request
    const headers = engine.headers.resolve('POST', { 'X-Override': 'value' });

    Type Parameters

    • H = unknown

      Headers type

    Index

    Constructors

    Accessors

    • get $store(): PropertyStore<DictAndT<H>>
      Internal

      Get the underlying PropertyStore for internal use.

      Exposed for FetchEngineCore compliance. Internal components (executor, policies) access the store directly for resolution.

      Returns PropertyStore<DictAndT<H>>

    • get all(): { default: DictAndT<H> } & Record<string, Partial<DictAndT<H>>>

      Get all headers including method overrides.

      Returns { default: DictAndT<H> } & Record<string, Partial<DictAndT<H>>>

      const all = engine.headers.all;
      // { default: { Authorization: '...' }, post: { 'Content-Type': '...' } }
    • get defaults(): DictAndT<H>

      Get the default headers (without method overrides).

      Returns DictAndT<H>

    Methods

    • Get method-specific headers only (not merged with defaults).

      Parameters

      • method: string

      Returns Partial<DictAndT<H>>

    • Check if a header exists globally or for a specific method.

      Parameters

      • key: string
      • Optionalmethod: string

      Returns boolean

      if (engine.headers.has('Authorization')) {
      console.log('Auth header is set');
      }
    • Remove a header globally or for a specific method.

      Parameters

      • key: string
      • Optionalmethod: string

      Returns void

      engine.headers.remove('Authorization');
      engine.headers.remove('Content-Type', 'POST');
    • Remove multiple headers globally or for a specific method.

      Parameters

      • keys: string[]
      • Optionalmethod: string

      Returns void

      engine.headers.remove(['Authorization', 'X-API-Key']);
      engine.headers.remove(['Content-Type'], 'POST');
    • Resolve the final headers for a specific method.

      Merges in order: defaults → method overrides → request overrides.

      Parameters

      Returns DictAndT<H>

      const headers = engine.headers.resolve('POST', { 'X-Request-ID': '123' });
      
    • Set a header value globally or for a specific method.

      Parameters

      • key: string
      • value: string
      • Optionalmethod: string

      Returns void

      engine.headers.set('Authorization', 'Bearer token');
      engine.headers.set('Content-Type', 'application/json', 'POST');
    • Set multiple header values globally or for a specific method.

      Parameters

      Returns void

      engine.headers.set({ Authorization: 'Bearer token', 'X-API-Key': 'abc' });
      engine.headers.set({ 'Content-Type': 'application/json' }, 'POST');