trapping http-client redirects pasted by andyjpb on Wed Feb 6 17:00:01 2013
(handle-exceptions
x
(begin
(display "went wrong")
(newline)
(pp (request-uri (car ((condition-property-accessor 'exn 'arguments) x))))
(newline)
(newline)
(pp (condition->list x))
(newline))
(nth-value 2
(call-with-response
(make-request uri: (uri-reference "http://knodium.co"))
(lambda (p) (display "writing") (newline) #f)
(lambda (p) (display "reading")(newline)#f)))
)
no title added by anonymous on Wed Feb 6 17:03:40 2013
#;27> (load "/tmp/test.scm") ; loading /tmp/test.scm ... writing went wrong #<URI-common: scheme=http port=#f host="knodium.co" path=() query=() fragment=#f> ((exn (arguments (#<request>)) (message "Maximum number of redirects exceeded") (location send-request)) (http) (redirect-depth-exceeded (uri #<URI-common: scheme=http port=#f host="www.knodium.com" path=(/ "") query=() fragment=#f>))) ----- http-client.scm: (let ((new-uri (header-value 'location (response-headers response)))) (if (or (not (max-redirect-depth)) ; unlimited? (< redirects (max-redirect-depth))) (loop attempts (add1 redirects) (update-request req uri: (uri-relative-to new-uri (request-uri req)))) (http-client-error 'send-request "Maximum number of redirects exceeded" (list req) 'redirect-depth-exceeded 'uri new-uri))))