in reply to Re: download JPG series with error-handling
in thread download JPG series with error-handling

410 (Gone) is another valid "this doesn't exist" response, and 403 might also be important. You might as well just detect any error return--the design might change in the future, after all. (HTTP errors start with a 4 or 5.)

--Brent Dax
There is no sig.

  • Comment on Re^2: download JPG series with error-handling

Replies are listed 'Best First'.
Re^3: download JPG series with error-handling
by DrWhy (Chaplain) on Mar 28, 2005 at 05:33 UTC
    To be really safe here, you might check for a success code (I think it's 202, but don't " me) rather than trying to think of all the possible error codes you might get.

    Also, just to throw another wrench in, just checking MIME type might not be good enough. What if the error "page" you get back is itself actually a jpeg image? I've seen that before. Don't know a way around it unless you are also checking the error code (and the webmaster configured the server sensibly to send back error codes).


    "If God had meant for us to think for ourselves he would have given us brains. Oh, wait..."

      All 200s are successes. 200 ("OK") is the usual case. is_success (on the return value of getstore and getprint) checks for a return code in the 200s. But as moot mentioned, some servers return success (200) with an HTML message instead of a 404 (with or without an HTML message) when an file cannot be found. That's why I mentioned checking Content-Type in addition to the return code.