Fixing trac bug number 188
svn: r15092
This commit is contained in:
parent
bbc24b5e68
commit
3b2557805d
|
@ -110,10 +110,13 @@
|
||||||
(begin
|
(begin
|
||||||
((response/incremental-generator bresp)
|
((response/incremental-generator bresp)
|
||||||
(lambda chunks
|
(lambda chunks
|
||||||
(fprintf o-port "~x\r\n"
|
(define length (apply + 0 (map bytes-length chunks)))
|
||||||
(apply + 0 (map bytes-length chunks)))
|
(if (zero? length)
|
||||||
(for-each (lambda (chunk) (display chunk o-port)) chunks)
|
(flush-output o-port)
|
||||||
(fprintf o-port "\r\n")))
|
(begin
|
||||||
|
(fprintf o-port "~x\r\n" length)
|
||||||
|
(for-each (lambda (chunk) (display chunk o-port)) chunks)
|
||||||
|
(fprintf o-port "\r\n")))))
|
||||||
; one \r\n ends the last (empty) chunk and the second \r\n ends the (non-existant) trailers
|
; one \r\n ends the last (empty) chunk and the second \r\n ends the (non-existant) trailers
|
||||||
(fprintf o-port "0\r\n\r\n")))]))
|
(fprintf o-port "0\r\n\r\n")))]))
|
||||||
|
|
||||||
|
|
|
@ -199,7 +199,9 @@ Here is an example typical of what you will find in many applications:
|
||||||
([generator ((() () #:rest (listof bytes?) . ->* . any) . -> . any)])]{
|
([generator ((() () #:rest (listof bytes?) . ->* . any) . -> . any)])]{
|
||||||
As with @scheme[response/basic], except with @scheme[generator] as a function that is
|
As with @scheme[response/basic], except with @scheme[generator] as a function that is
|
||||||
called to generate the response body, by being given an @scheme[output-response] function
|
called to generate the response body, by being given an @scheme[output-response] function
|
||||||
that outputs the content it is called with.
|
that outputs the content it is called with. If the @scheme[output-response] function is called
|
||||||
|
with arguments of zero length (when concatenated), then the output port is flushed with
|
||||||
|
@scheme[flush-output].
|
||||||
|
|
||||||
Here is a short example:
|
Here is a short example:
|
||||||
@schemeblock[
|
@schemeblock[
|
||||||
|
@ -208,11 +210,11 @@ Here is an example typical of what you will find in many applications:
|
||||||
#"application/octet-stream"
|
#"application/octet-stream"
|
||||||
(list (make-header #"Content-Disposition"
|
(list (make-header #"Content-Disposition"
|
||||||
#"attachment; filename=\"file\""))
|
#"attachment; filename=\"file\""))
|
||||||
(lambda (send/bytes)
|
(lambda (output-response)
|
||||||
(send/bytes #"Some content")
|
(output-response #"Some content")
|
||||||
(send/bytes)
|
(output-response)
|
||||||
(send/bytes #"Even" #"more" #"content!")
|
(output-response #"Even" #"more" #"content!")
|
||||||
(send/bytes #"Now we're done")))
|
(output-response #"Now we're done")))
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user