download word throneeds to ws an error if the request did not return a success code (reported by Chris Double)

db4
Slava Pestov 2009-04-09 08:18:26 -05:00
parent 30191f87e5
commit 694652590f
2 changed files with 5 additions and 2 deletions

View File

@ -165,7 +165,7 @@ ERROR: download-failed response ;
present file-name "?" split1 drop "/" ?tail drop ;
: download-to ( url file -- )
binary [ [ write ] with-http-get drop ] with-file-writer ;
binary [ [ write ] with-http-get check-response drop ] with-file-writer ;
: download ( url -- )
dup download-name download-to ;

View File

@ -392,4 +392,7 @@ SYMBOL: a
[ "OK" ] [ "data" "http://localhost/a" add-port http-post nip ] unit-test
[ ] [ "http://localhost/quit" add-port http-get 2drop ] unit-test
! Check that download throws errors (reported by Chris Double)
[ "http://localhost/tweet_my_twat" add-port download ] must-fail
[ ] [ "http://localhost/quit" add-port http-get 2drop ] unit-test