Tinkex.API.Headers (Tinkex v0.3.4)
View SourceHTTP header building and management for Tinkex API requests.
Handles:
- Standard headers (accept, content-type, user-agent, etc.)
- Authentication headers (API key)
- Stainless SDK headers
- Cloudflare Access headers
- Request-specific headers (idempotency, sampling, retry count)
- OpenTelemetry trace context propagation (opt-in)
- Header deduplication
Summary
Functions
Builds complete headers list for a request.
Deduplicates headers, keeping the last occurrence of each header name.
Finds a header value by name (case-insensitive).
Retrieves a header value by name (case-insensitive).
Adds or replaces a header in the headers list.
Adds or updates retry-related headers to a request.
Redacts sensitive header values for logging.
Converts a headers list to a map with lowercased keys.
Functions
Builds complete headers list for a request.
Combines headers from multiple sources in priority order:
- Standard headers (accept, content-type, etc.)
- Stainless SDK headers
- Cloudflare Access headers
- Config default headers
- Request-specific headers
- Method-specific headers (idempotency, sampling)
- User-provided headers from opts
- OpenTelemetry trace context (if enabled)
Lower priority headers are overridden by higher priority ones.
Deduplicates headers, keeping the last occurrence of each header name.
Comparison is case-insensitive, but the original case of the last occurrence is preserved.
Finds a header value by name (case-insensitive).
Returns the original value (not lowercased) if found, nil otherwise.
Retrieves a header value by name (case-insensitive).
Returns the lowercased and trimmed value if found, nil otherwise.
Adds or replaces a header in the headers list.
Case-insensitive replacement - if a header with the same name exists (regardless of case), it will be replaced.
@spec put_retry_headers(Finch.Request.t(), non_neg_integer(), timeout()) :: Finch.Request.t()
Adds or updates retry-related headers to a request.
Sets:
- x-stainless-retry-count: Current retry attempt number
- x-stainless-read-timeout: Request timeout (if not already set)
Redacts sensitive header values for logging.
Redacts:
- x-api-key
- cf-access-client-secret
- authorization
- proxy-authorization
Converts a headers list to a map with lowercased keys.