exception handling
svn: r2140
This commit is contained in:
parent
a6f8344c09
commit
647fc4e58a
|
@ -114,10 +114,15 @@
|
||||||
;; **************************************************
|
;; **************************************************
|
||||||
;; output-response: connection response -> void
|
;; output-response: connection response -> void
|
||||||
(define (ext:output-response conn resp)
|
(define (ext:output-response conn resp)
|
||||||
|
(if (connection-close? conn)
|
||||||
|
(raise 'output-response "Attempt to output on closed connection.")
|
||||||
|
(with-handlers ([exn? (lambda (exn)
|
||||||
|
(kill-connection! conn)
|
||||||
|
(raise exn))])
|
||||||
(call-with-semaphore (connection-mutex conn)
|
(call-with-semaphore (connection-mutex conn)
|
||||||
(lambda ()
|
(lambda ()
|
||||||
(output-response conn resp)
|
(output-response conn resp)
|
||||||
(flush-output (connection-o-port conn)))))
|
(flush-output (connection-o-port conn)))))))
|
||||||
|
|
||||||
(define (output-response conn resp)
|
(define (output-response conn resp)
|
||||||
(cond
|
(cond
|
||||||
|
@ -181,10 +186,15 @@
|
||||||
;; **************************************************
|
;; **************************************************
|
||||||
;; output-file: connection path symbol bytes -> void
|
;; output-file: connection path symbol bytes -> void
|
||||||
(define (ext:output-file conn file-path method mime-type)
|
(define (ext:output-file conn file-path method mime-type)
|
||||||
|
(if (connection-close? conn)
|
||||||
|
(raise 'output-response "Attempt to output on closed connection.")
|
||||||
|
(with-handlers ([exn? (lambda (exn)
|
||||||
|
(kill-connection! conn)
|
||||||
|
(raise exn))])
|
||||||
(call-with-semaphore (connection-mutex conn)
|
(call-with-semaphore (connection-mutex conn)
|
||||||
(lambda ()
|
(lambda ()
|
||||||
(output-file conn file-path method mime-type)
|
(output-file conn file-path method mime-type)
|
||||||
(flush-output (connection-o-port conn)))))
|
(flush-output (connection-o-port conn)))))))
|
||||||
|
|
||||||
(define (output-file conn file-path method mime-type)
|
(define (output-file conn file-path method mime-type)
|
||||||
(output-headers conn 200 "Okay"
|
(output-headers conn 200 "Okay"
|
||||||
|
@ -202,10 +212,15 @@
|
||||||
;; output-response/method: connection response/full symbol -> void
|
;; output-response/method: connection response/full symbol -> void
|
||||||
;; If it is a head request output headers only, otherwise output as usual
|
;; If it is a head request output headers only, otherwise output as usual
|
||||||
(define (ext:output-response/method conn resp meth)
|
(define (ext:output-response/method conn resp meth)
|
||||||
|
(if (connection-close? conn)
|
||||||
|
(raise 'output-response "Attempt to output on closed connection.")
|
||||||
|
(with-handlers ([exn? (lambda (exn)
|
||||||
|
(kill-connection! conn)
|
||||||
|
(raise exn))])
|
||||||
(call-with-semaphore (connection-mutex conn)
|
(call-with-semaphore (connection-mutex conn)
|
||||||
(lambda ()
|
(lambda ()
|
||||||
(output-response/method conn resp meth)
|
(output-response/method conn resp meth)
|
||||||
(flush-output (connection-o-port conn)))))
|
(flush-output (connection-o-port conn)))))))
|
||||||
|
|
||||||
(define (output-response/method conn resp meth)
|
(define (output-response/method conn resp meth)
|
||||||
(cond
|
(cond
|
||||||
|
|
Loading…
Reference in New Issue
Block a user