Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re^2: download JPG series with error-handling

by BrentDax (Hermit)
on Mar 28, 2005 at 04:26 UTC ( #442738=note: print w/replies, xml ) Need Help??


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.)

=cut
--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).

    --DrWhy

    "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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://442738]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (3)
As of 2022-01-25 16:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    In 2022, my preferred method to securely store passwords is:












    Results (67 votes). Check out past polls.

    Notices?