elastic / elastic/integrations
[Custom API httpjson]: Preserve casing of custom request headers in Elastic Agent Custom API Integration
- Dominant language
- Handlebars
- Stars
- 333
- Forks
- 647
- Avg merge
- 2d 17h
- Merged PRs (30d)
- 225
Description
### Integration Name
Custom API [httpjson]
### Dataset Name
_No response_
### Integration Version
1.24.0
### Agent Version
8.19
### OS Version and Architecture
N/A
### User Goal
It would be helpful to preserve the casing of header keys defined in `request.transforms` because some API endpoints expect specific casing. This is despite [Section 3.2 of RFC 7230](https://datatracker.ietf.org/doc/html/rfc7230#section-3.2), which states:
>Each header field consists of a case-insensitive field name followed by a colon (":"), optional leading whitespace, the field value, and optional trailing whitespace.
The [documentation](https://pkg.go.dev/net/http#Header.Set) for Golang's `Header.Set`, which is used to define the custom headers, indicates that non-canonical keys can be directly assigned to the map to preserve casing. Otherwise, the header keys are automatically canonicalized. This automatic canonicalization results in keys defined like `x-api-key` being sent as `X-Api-Key`.
### Existing Features
The automatic canonicalization discards the original casing defined for the header key.
### What did you see?
The automatic canonicalization discards the original casing defined for the header key.
### Anything else?
_No response_
Contributor guide
Research direction
Start by locating the Custom API httpjson handling for request.transforms and the use of Go's net/http Header.Set. Verify how custom header keys are currently built and define done as sending the configured header names with their original casing; add or run the relevant integration test if one is present.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100