Skip to content

Commit 597bfd5

Browse files
committed
feat: Normalize HTTP headers to lower case
HTTP headers are case-insensitive by spec. Different HTTP libraries treat them differently — some preserve case, some change case. This can cause unnecessary differences in AppMap between library versions. This change normalizes all HTTP headers to lower case for consistency.
1 parent 408e3c3 commit 597bfd5

2 files changed

Lines changed: 4 additions & 2 deletions

File tree

agent/src/main/java/com/appland/appmap/reflect/HttpHeaders.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,14 @@ default Enumeration<String> getHeaderNames() {
3232

3333
/**
3434
* Non-standard utility method. Retrieves all headers.
35+
* Header names are normalized to lowercase since HTTP headers are case-insensitive.
3536
*/
3637
default Map<String, String> getHeaders() {
3738
HashMap<String, String> headers = new HashMap<>();
3839

3940
for (Enumeration<String> e = getHeaderNames(); e.hasMoreElements();) {
4041
String headerName = (String) e.nextElement();
41-
headers.put(headerName, this.getHeader(headerName));
42+
headers.put(headerName.toLowerCase(), this.getHeader(headerName));
4243
}
4344

4445
return headers;

agent/test/petclinic/petclinic.bats

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,8 @@ setup() {
211211
assert_success
212212
stop_recording
213213

214-
assert_json_eq '.events[] | .http_server_response | .headers["Content-Type"]' "text/html;charset=UTF-8"
214+
# HTTP headers are case-insensitive and are normalized to lowercase
215+
assert_json_eq '.events[] | .http_server_response | .headers["content-type"]' "text/html;charset=UTF-8"
215216
}
216217

217218
@test "recordings capture elapsed time" {

0 commit comments

Comments
 (0)