On Wed, 27 Sep 2023 10:55:46 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.
>
> Vyom Tewari has updated the pull request incrementally with one additional
> commit since the last revision:
>
> Incorporated the review comments
Changes requested by dfuchs (Reviewer).
test/jdk/java/net/HttpURLConnection/HttpURLConnectionExpect100Test.java line 81:
> 79: //send expect continue
> 80: conn.setRequestProperty("Expect", "100-continue");
> 81: sendRequest(conn);
Could you call `conn.getResponseCode()` after `sendRequest` here and assert
that the returned code is the expected 417?
test/jdk/java/net/HttpURLConnection/HttpURLConnectionExpect100Test.java line 82:
> 80: conn.setRequestProperty("Expect", "100-continue");
> 81: sendRequest(conn);
> 82: getHeaderField(conn);
Could you call conn.getInputStream().readAllBytes() here to verify that it
doesn't throw? Also verify that you get the expected 0 length result.
test/jdk/java/net/HttpURLConnection/HttpURLConnectionExpect100Test.java line 97:
> 95: conn.setRequestMethod("PUT");
> 96: sendRequest(conn);
> 97: getHeaderField(conn);
Same here - please add a line to verify that the response code is 200, and that
the returned data is the expected RESPONSE.
-------------
PR Review: https://git.openjdk.org/jdk/pull/15483#pullrequestreview-1652728826
PR Review Comment: https://git.openjdk.org/jdk/pull/15483#discussion_r1342679549
PR Review Comment: https://git.openjdk.org/jdk/pull/15483#discussion_r1342682738
PR Review Comment: https://git.openjdk.org/jdk/pull/15483#discussion_r1342684206