Cope with network error when considering redirection

This commit is contained in:
Tony Garnock-Jones 2016-10-31 22:29:32 -04:00
parent 98b62a5bc8
commit a445c6860a
1 changed files with 3 additions and 2 deletions

View File

@ -71,8 +71,9 @@
(stop-when (message (web-response-complete req-id $resp $response-body))
(printf "~a <-- ~v ~v\n" req-id resp response-body)
(k resp response-body))))
(define location (dict-ref (web-response-header-headers resp) 'location #f))
(if (and (eq? (web-response-header-code-type resp) 'redirection)
(define location (and resp (dict-ref (web-response-header-headers resp) 'location #f)))
(if (and resp
(eq? (web-response-header-code-type resp) 'redirection)
(positive? redirect-budget)
location)
(web-request! verb location