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

"Al Le" <[email protected]>
Newsgroups gmane.comp.jakarta.ant.user
Message-ID <trinity-56d6acb2-e40a-42c3-914c-cd813546ba9d-1484654703710@3capp-gmx-bs24>
Hello Klaus,

> 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.

Thank you for the tip! I didn't know of that method!

Indeed, with getErrorStream() I could read out the response (had to downcast to HttpURLConnection first of course).

IMO it would be a very useful enhancement to the Get task if one could

1. Specify the property to write the response code (status code) to

2. Specify the file to write the error response to (or if the task just wrote it to the file specified by 'dest'). If 'ignoreerrors' is set to false, the build should fail as usual.

With these two enhancements, the script could set 'ignoreerrors' to 'true' and then analyze what happened and proceed as it fits.

AL
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.