How to? How do I distinguish missing source file from download error when using HTTP?

  • This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.
#1
When I use "copy http://..." how can I distinguish between a data transfer error of an existing source file and the inavailability of the source file? Presumably the exit code of the COPY command provides that information, but I cannot find where its documented (it is not in the COPY command).
 
#3
Rex, I presume you meant that any unsuccessful attempt to download a file from a website via HTTP the COPY command exit code will be 2, regardless of the reason for the failure.

Does the HTTP include a method to determine whether or not a downloadable source file exists (analogous to the IF ISFILE status test in TCC)? Or is the only thing a user can do is to try repeatedly and eventually give up? Based on your above answer this question might better be in the Open Forum, but it is a logical outgrowth of the original question...
 

rconn

Administrator
Staff member
May 14, 2008
10,101
85
#4
Does the HTTP include a method to determine whether or not a downloadable source file exists (analogous to the IF ISFILE status test in TCC)? Or is the only thing a user can do is to try repeatedly and eventually give up? Based on your above answer this question might better be in the Open Forum, but it is a logical outgrowth of the original question...
The HTTP protocol doesn't have any means of determining a file's existence. And you can't even rely on an error being returned, because the site could redirect you to another file (or page), and return a completely different result.
 
#6
The HTTP protocol doesn't have any means of determining a file's existence. And you can't even rely on an error being returned, because the site could redirect you to another file (or page), and return a completely different result.
I'd argue that the HEAD command could be used for this. A 200 means the content exists, a 404 means it does not exist. Other error codes are somewhat more ambiguous.

Perhaps IFF EXISTS http:// could call the HEAD method, return true for 200, false for anything else and set a _httpstatuscode _httpredirect with the actual result so that the user can script how to proceed? Obviously _httpredirect would only return something if we have a 301/302/303/307/308 status code.