I just had a look at the source code.
There is a special handling for HTTP-ResponseCodes for
- MOVED --> follow redirect if specified
-- 301: Moved Permanently
-- 302: Temporary Redirect
-- 303: See Other
-- 307: Temporary Redirect
- HTTP_NOT_MODIFIED (304 Not Modified) --> dont download if use timestamp
- HTTP_UNAUTHORIZED (401: Unauthorized) --> maybe throw BuildException, dont
download
Otherwise the return of the url.openConnection().getInputStream() is copied to
local file.
So a response for a 500-error should be captured to file.
_But_ that file is deleted if an error (non-success, e.g. catched IOException)
occured.
(org.apache.tools.ant.taskdefs.Get:887).
For a workaround you could
- get the <get> source code
- modify the deletion logic
- compile that code
- include your modified code via <taskdef name="get2" classname="..."
classpath="..."/>
- try it out
(- provide a patch ;)
Maybe we could also tune that task.
- support of HTTP 308 Permanent Redirect
- store the HTTP-returncode in a map (URL-RC) for access via property
${get-rc.http://ant.apache.org}==200
- parallel downloads?
- different "delete" logic as specified via new attribute
-- delete (old behaviour)
-- move to different folder
-- move to different name/folder (e.g.
get-error/http-ant.apache.org--207_MULTI_STATUS)
Jan
Jan
> -----Ursprüngliche Nachricht-----
> Von: Al Le [mailto:[email protected]]
> Gesendet: Samstag, 14. Januar 2017 01:11
> An: Ant Users List
> Betreff: How to capture HTTP response with the status 500?
>
> Hello,
>
> the GET task allows to save the response of a HTTP server. One URL I
> try to get returns the HTTP status 500 (internal server error). Along
> with the status, some data is returned in the response (I verified this
> with
> cUrl) which provides some details about the error. However this data is
> not captured by ant.
>
> Is it possible (and how) to capture the contents of a server response
> with the status 500?
>
> After the data has been captured (saved to file), the execution of the
> build should proceed as usual, i.e. go further of fail according to
> "ignoreerrors".
>
> Thanks!
> AL
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected] For additional
> commands, e-mail: [email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]