eclipse-ee4j / eclipse-ee4j/jersey
HTTPUrlConnector: 40x Errors during large puts result in IOException
- Dominant language
- Java
- Stars
- 730
- Forks
- 382
- PR merge metrics
- No merged PRs in 30d
Description
I don't have an example yet, but it's fairly easy to describe.
* use HTTPUrlConnector
* enable streaming (fixed content length)
* do a put/post operation where the body is large (>20mb usually works)
* have the server return a 40x response after reading the headers and close the connection
This connector delegates to HttpUrlConnection, which during a streaming write, will attempt to validate there was no error (see 'checkError' on line 3477 line here):
[http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/8u40-b25/sun/net/www/protocol/http/HttpURLConnection.java#3470](http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/8u40-b25/sun/net/www/protocol/http/HttpURLConnection.java#3470)
In this case, the connector fails to read the response code because it received an IOException during entity write.
I haven't tried this, but I think if you surround the entire block in the connector that writes the entity if its not null (lines 359-397 in version 2.24.1) in a try/catch, and then attempt to read the response code it might work.
#### Environment
Mac, Linux
#### Affected Versions
[2.24.1]
Contributor guide
Assessment
This issue has not been assessed yet.