ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Klaus Malorny <Klaus.Malo...@knipp.de>
Subject Re: How to capture HTTP response with the status 500?
Date Tue, 17 Jan 2017 08:17:04 GMT
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

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Mime
View raw message