feat(gax): add getFirstHeader to HttpHeadersUtils - #14137
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces a new utility method getFirstHeader in HttpHeadersUtils to retrieve the first string value of a header by case-insensitive name from a headers map, along with a helper method extractFirstString to handle different header value types (such as iterables and non-string objects). Comprehensive unit tests have also been added to cover various scenarios, including case-insensitivity, iterable values, null values, and non-existent headers. There are no review comments, and I have no feedback to provide.
7c7cb65 to
d1c96b2
Compare
|
|




The GAX HTTP/JSON stack stores response headers in a Map<String, Object> where values may be Strings, numbers, Iterables, etc., and header names may vary in casing depending on the HTTP version. This method provides case-insensitive lookup and safely extracts the first string value in a typesafe way.
This will be used in resumable upload support to retrieve protocol header values (e.g. X-Goog-Upload-URL, Location, and X-Goog-Upload-Status).