Catch tcp failures in the http verification.

This commit is contained in:
Eli Barzilay 2011-10-07 11:05:15 -04:00
parent a68ea14d8b
commit f5230d858f

View File

@ -127,12 +127,10 @@ Polling a URL can result in one of four options:
;; need to mimic HEAD requests too.
(define (verify-http url)
(call/input-url (string->url url) head-impure-port
(lambda (inp)
(define (check-contents inp)
(define status (read-line inp))
(define status* (regexp-match #rx"^HTTP/[0-9.]+ ([0-9]+)" status))
(cond
[(not status*)
(cond [(not status*)
(eprintf "WARNING: bad status line for ~a:\n ~s\n" url status)
#f]
[(not (regexp-match #rx"^2..$" (cadr status*)))
@ -145,7 +143,14 @@ Polling a URL can result in one of four options:
=> (compose string->number cadr)]
[else #f]))
(begin (eprintf "WARNING: no `content-length' for ~a" url)
#t))]))))
#t))]))
(define r
(with-handlers ([exn:fail? exn-message])
(call/input-url (string->url url) head-impure-port check-contents)))
(if (boolean? r)
r
(begin (eprintf "WARNING: failure getting http info for ~a (~a)\n" url r)
#f)))
(define (verify-ftp url)
(define-values [host port? path]