JDK-8294196 : Investigate introducing an API on the HttpClient which allows applications to get access to "interim" HTTP responses
  • Type: Enhancement
  • Component: core-libs
  • Sub-Component: java.net
  • Priority: P4
  • Status: Open
  • Resolution: Unresolved
  • Submitted: 2022-09-22
  • Updated: 2024-11-05
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
tbdUnresolved
Related Reports
Relates :  
Description
HTTP RFC states that informational 1xx response codes are considered interim responses. https://bugs.openjdk.org/browse/JDK-8292044 fixed the HttpClient to not deliver such responses as final responses to applications.

This current JBS issue is to investigate any new API on the HttpClient to allow applications to get access to such interim responses. The linked JBS proposed:

"For the mainline we should probably add a new no-op method with an empty default body to the BodyHandler interface to give the caller a chance to intercept the 1xx response."

Additionally in the PR discussion for the linked issue, one such proposed API looks like:


> "Regarding a new API, maybe a method could be added to HttpResponse.BodyHandler to supply intermediate responses?"
...
> I had a look at the HttpClient API and as you note, we could add a new method on BodyHandler to provide the application with these interim responses. Something like:
>
>/**
>* Invoked when the client receives an interim informational (1xx) response for
> * a request.
> * @param responseInfo The interim response
> */
> default void applyInterim(ResponseInfo responseInfo) {
>    // do nothing by default
> }