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.headersengine.headers.set('Authorization', 'Bearer token');engine.headers.set({ 'X-API-Key': 'abc', 'X-Request-ID': '123' });// Method-specific headersengine.headers.set('Content-Type', 'application/json', 'POST');// Remove headersengine.headers.remove('Authorization');engine.headers.remove(['X-API-Key', 'X-Request-ID']);// Check if header existsif (engine.headers.has('Authorization')) { ... }// Get resolved headers for a requestconst headers = engine.headers.resolve('POST', { 'X-Override': 'value' }); Copy
// Access via engine.headersengine.headers.set('Authorization', 'Bearer token');engine.headers.set({ 'X-API-Key': 'abc', 'X-Request-ID': '123' });// Method-specific headersengine.headers.set('Content-Type', 'application/json', 'POST');// Remove headersengine.headers.remove('Authorization');engine.headers.remove(['X-API-Key', 'X-Request-ID']);// Check if header existsif (engine.headers.has('Authorization')) { ... }// Get resolved headers for a requestconst headers = engine.headers.resolve('POST', { 'X-Override': 'value' });
Headers type
Internal
Get the underlying PropertyStore for internal use.
Exposed for FetchEngineCore compliance. Internal components (executor, policies) access the store directly for resolution.
Get all headers including method overrides.
const all = engine.headers.all;// { default: { Authorization: '...' }, post: { 'Content-Type': '...' } } Copy
const all = engine.headers.all;// { default: { Authorization: '...' }, post: { 'Content-Type': '...' } }
Get the default headers (without method overrides).
Get method-specific headers only (not merged with defaults).
Check if a header exists globally or for a specific method.
Optional
if (engine.headers.has('Authorization')) { console.log('Auth header is set');} Copy
if (engine.headers.has('Authorization')) { console.log('Auth header is set');}
Remove a header globally or for a specific method.
engine.headers.remove('Authorization');engine.headers.remove('Content-Type', 'POST'); Copy
engine.headers.remove('Authorization');engine.headers.remove('Content-Type', 'POST');
Remove multiple headers globally or for a specific method.
engine.headers.remove(['Authorization', 'X-API-Key']);engine.headers.remove(['Content-Type'], 'POST'); Copy
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.
const headers = engine.headers.resolve('POST', { 'X-Request-ID': '123' }); Copy
const headers = engine.headers.resolve('POST', { 'X-Request-ID': '123' });
Set a header value globally or for a specific method.
engine.headers.set('Authorization', 'Bearer token');engine.headers.set('Content-Type', 'application/json', 'POST'); Copy
engine.headers.set('Authorization', 'Bearer token');engine.headers.set('Content-Type', 'application/json', 'POST');
Set multiple header values globally or for a specific method.
engine.headers.set({ Authorization: 'Bearer token', 'X-API-Key': 'abc' });engine.headers.set({ 'Content-Type': 'application/json' }, 'POST'); Copy
engine.headers.set({ Authorization: 'Bearer token', 'X-API-Key': 'abc' });engine.headers.set({ 'Content-Type': 'application/json' }, 'POST');
Manages HTTP headers for FetchEngine with event emission.
Wraps PropertyStore with FetchEngine-specific event emission. Pulls initial headers and validation from engine options.
Example