RFR: 8351347: HttpClient Improve logging of response headers

Volkan Yazici vyazici at openjdk.org
Wed May 14 09:38:52 UTC 2025


On Tue, 13 May 2025 13:53:05 GMT, Daniel Fuchs <dfuchs at openjdk.org> wrote:

>> Includes request method, request URI, response status code, and HTTP/2 stream ID while logging response headers in the HTTP Client.
>> 
>> ### Demonstration
>> 
>> Snippets from running JTreg against `test/jdk/java/net/httpclient/HeadTest.java`:
>> 
>> **Before:**
>> 
>> INFO: HEADERS: REQUEST HEADERS:
>> HEAD /transfer/ HTTP/1.1
>> Content-Length: 0
>> Host: 127.0.0.1:43647
>> ...
>> INFO: HEADERS: RESPONSE HEADERS:
>>     connection: Upgrade
>>     upgrade: h2c
>> ...
>> INFO: HEADERS: RESPONSE HEADERS:
>>     :status: 304
>>     content-length: 300
>> ...
>> INFO: HEADERS: HEADERS FRAME (streamid=1):
>>     :authority: 127.0.0.1:50611
>>     :method: GET
>>     :path: /
>> 
>> 
>> **After:** 
>> 
>> INFO: HEADERS: REQUEST HEADERS:
>>   HEAD /transfer/
>>     Content-Length: 0
>>     Host: 127.0.0.1:43647
>> ...
>> INFO: HEADERS: RESPONSE HEADERS:
>>   GET http://127.0.0.1:48497/ 101
>>     connection: Upgrade
>>     upgrade: h2c
>> ...
>> INFO: HEADERS: RESPONSE HEADERS (streamid=1):
>>   GET http://127.0.0.1:48497/ 304
>>     :status: 304
>>     content-length: 300
>> ...
>> INFO: HEADERS: HEADERS FRAME (streamid=1):
>>   GET https://127.0.0.1:50611/
>>     :authority: 127.0.0.1:50611
>>     :method: GET
>>     :path: /
>
> Very nice!
> 
> It would be good to add the `(streamId=<streamId>)` at line 676 too in Stream.java (Trailing Headers),  and to add the whole line (`GET <uri> <status-code>`) at line 1782 (push response headers).

@dfuch, I've updated all usages of `Log::logHeaders`, see the updated BEFORE and AFTER snippets in the PR description. Two particular spots of importance:

1. Updated `Http1Request::logHeaders`
2. `HEADERS FRAME` logs don't contain the response code for those are outgoing

-------------

PR Comment: https://git.openjdk.org/jdk/pull/25201#issuecomment-2879508082


More information about the net-dev mailing list