hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sachin Nikumbh <saniku...@gmail.com>
Subject Unable to get HttpStatus.SC_REQUEST_TOO_LONG status successfully
Date Wed, 31 Oct 2012 13:19:19 GMT
Hi,

I am using HttpClient (version 4.2.2) to communicate with a server using
POST requests. The server can be configured to set request size limit. Once
the request content exceeds this limit, it sends HTTP 413 response status
and closes the connection.

In my simple application written using Apache HttpClient, I send a POST
request with request content too large for the server using something like
following:

***************************************************
DefaultHttpClient httpClient = new DefaultHttpClient();
...
...
HttpPost postReq = new HttpPost(url);
....
HttpResponse response = httpClient.execute(postReq);
***************************************************

I am expecting the response.getStatusLine().getStatusCode() to
return  HttpStatus.SC_REQUEST_TOO_LONG. But instead, I am getting a
SocketException with message :

***************************************************
Connection reset by peer: socket write error
***************************************************

I have used WireShark to see what's being sent and received. Wireshark
shows the response with 413 status from server the moment client exceeds
the request size limit. But it looks like HttpClient is ignoring it and
still continues to send the remaining request.

Is there something that I am missing or is this not supported?

Any help will be greatly appreciated,

Thanks
Sachin

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message