Re: How to capture HTTP response with the status 500?

Klaus Malorny <[email protected]>
Newsgroups gmane.comp.jakarta.ant.user
Message-ID <[email protected]>
On 17.01.17 08:08, Al Le wrote:
>> So maybe it's because of the inbuilt JDK's implementation of
>> connection.getInputStream (it throws an exception if the status is 500).
> 
> I've debugged it and found out that
> the connection object is of type 'sun.net.www.protocol.https.HttpsURLConnectionImpl'
> which delegates the getInputStream() method to 'sun.net.www.protocol.http.HttpURLConnection'
> which throws an exception if the status is greater than or equal to 400.
> 
> This makes me think that it will not be possible to get the full response without a custom implementation of URLConnection.
> 
> AL
> 


Hi AL,

I don't think you'll need to have a custom implementation. I cannot remember 
whether I have ever used it, but I am quite confident that you can call the 
Method HttpURLConnection.getErrorStream within the respective catch block to 
read the body of the HTTP response. Hope that helps.

Regards,

Klaus
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.