Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

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

May
3,515
5
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).
 
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...
 
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.
 
... and this may be why (or one of the reasons why) HTTP it is faster than FTP (a surmise on my part without ever analyzing the two protocols). Thanks for the answer.
 
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.
 
Rex:
Considering TheDave's response, possibly you could present this issue to the developers of ipworks? I presume COPY and all other commands accessing the internet utilize them...
 
Back
Top
[FOX] Ultimate Translator
Translate