forked from cadence/breezewiki
Close response after error in proxy
This commit is contained in:
parent
2a56107e97
commit
10cdd260e0
1 changed files with 10 additions and 7 deletions
|
@ -18,13 +18,16 @@
|
||||||
(match (dict-ref (url-query (request-uri req)) 'dest #f)
|
(match (dict-ref (url-query (request-uri req)) 'dest #f)
|
||||||
[(? string? dest)
|
[(? string? dest)
|
||||||
(if (is-fandom-url? dest)
|
(if (is-fandom-url? dest)
|
||||||
(response-handler
|
(response-handler ; catches and reports errors
|
||||||
(let ([dest-r (easy:get dest #:stream? #t)])
|
(let ([dest-r (easy:get dest #:stream? #t)])
|
||||||
(response/output
|
(with-handlers ([exn:fail? (λ (e) ; cleans up and re-throws
|
||||||
#:code (easy:response-status-code dest-r)
|
(easy:response-close! dest-r)
|
||||||
#:mime-type (easy:response-headers-ref dest-r 'content-type)
|
(raise e))])
|
||||||
(λ (out)
|
(response/output
|
||||||
(copy-port (easy:response-output dest-r) out)
|
#:code (easy:response-status-code dest-r)
|
||||||
(easy:response-close! dest-r)))))
|
#:mime-type (easy:response-headers-ref dest-r 'content-type)
|
||||||
|
(λ (out)
|
||||||
|
(copy-port (easy:response-output dest-r) out)
|
||||||
|
(easy:response-close! dest-r))))))
|
||||||
(next-dispatcher))]
|
(next-dispatcher))]
|
||||||
[#f (next-dispatcher)]))
|
[#f (next-dispatcher)]))
|
||||||
|
|
Loading…
Reference in a new issue