Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options

Re^3: download JPG series with error-handling

by DrWhy (Chaplain)
on Mar 28, 2005 at 05:33 UTC ( [id://442744]=note: print w/replies, xml ) Need Help??

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

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

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

Replies are listed 'Best First'.
Re^4: download JPG series with error-handling
by ikegami (Patriarch) on Mar 28, 2005 at 06:09 UTC
    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?

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

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (3)
As of 2024-06-24 03:05 GMT
Find Nodes?
    Voting Booth?

    No recent polls found

    erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.