1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

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

Discussion in 'Support' started by Steve Fabian, May 22, 2013.

  1. Steve Fabian

    Joined:
    May 20, 2008
    Messages:
    3,520
    Likes Received:
    4
    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).
     
  2. rconn

    rconn Administrator
    Staff Member

    Joined:
    May 14, 2008
    Messages:
    9,860
    Likes Received:
    83
    COPY doesn't set HTTP return codes -- if there's an error (of any time) COPY returns 2.
     
  3. Steve Fabian

    Joined:
    May 20, 2008
    Messages:
    3,520
    Likes Received:
    4
    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...
     
  4. rconn

    rconn Administrator
    Staff Member

    Joined:
    May 14, 2008
    Messages:
    9,860
    Likes Received:
    83
    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.
     
  5. Steve Fabian

    Joined:
    May 20, 2008
    Messages:
    3,520
    Likes Received:
    4
    ... 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.
     
  6. thedave

    Joined:
    Nov 13, 2008
    Messages:
    253
    Likes Received:
    2
    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.
     
  7. Steve Fabian

    Joined:
    May 20, 2008
    Messages:
    3,520
    Likes Received:
    4
    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...
     

Share This Page