On Wed, 30 Aug 2023 09:23:34 GMT, Vyom Tewari <[email protected]> wrote:

> With the current implementation of HttpURLConnection  if server rejects the  
> “Expect 100-continue” then there will be ‘java.net.ProtocolException’ will be 
> thrown from 'expect100Continue()' method. 
> 
> After the exception thrown, If we call any other method on the same instance 
> (ex getHeaderField(), or getHeaderFields()). They will internally call 
> getOuputStream() which invokes writeRequests(), which make the actual server 
> call.
> 
> The code change will sets the existing variable ‘rememberedException’ when 
> there is exception and getOutputStream0() will re-throw ‘rememberedException’ 
>  if the ‘rememberedException’ is not null. 
> 
> Note: getOutputStream0() also call’s  ‘expect100Continue()’  if 
> ‘expectContinue’ is true.

test/jdk/java/net/HttpURLConnection/HttpURLConnectionExpect100Test.java line 
200:

> 198:             try ( BufferedReader in = new BufferedReader(
> 199:                 new InputStreamReader(client.getInputStream()));
> 200:                 PrintStream out = new 
> PrintStream(client.getOutputStream());) {

Suggestion:

                PrintStream out = new PrintStream(client.getOutputStream())) {

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

PR Review Comment: https://git.openjdk.org/jdk/pull/15483#discussion_r1313490078

Reply via email to