CRLF terminate get-pure-port/headers; fixes #1901

Supply a final CRLF just like purify-port.
This commit is contained in:
Greg Hendershott 2017-12-02 11:44:02 -05:00 committed by Jay McCarthy
parent 0de27b6ce9
commit 1f4b989e48
2 changed files with 11 additions and 10 deletions

View File

@ -102,25 +102,25 @@
"HTTP/1.1 200 OK\r\nContent-Type: text/plain\r\nTransfer-Encoding: chunked\r\n\r\n24\r\nThis is the data in the first chunk \r\n1A\r\nand this is the second one\r\n0\r\n") "HTTP/1.1 200 OK\r\nContent-Type: text/plain\r\nTransfer-Encoding: chunked\r\n\r\n24\r\nThis is the data in the first chunk \r\n1A\r\nand this is the second one\r\n0\r\n")
=> =>
(values "This is the data in the first chunk and this is the second one" (values "This is the data in the first chunk and this is the second one"
"Content-Type: text/plain\r\nTransfer-Encoding: chunked\r\n") "Content-Type: text/plain\r\nTransfer-Encoding: chunked\r\n\r\n")
(get-pure/headers (get-pure/headers
"HTTP/1.0 200 OK\r\nContent-Type: text/plain\r\n\r\nThis is the data in the first chunk and this is the second one") "HTTP/1.0 200 OK\r\nContent-Type: text/plain\r\n\r\nThis is the data in the first chunk and this is the second one")
=> =>
(values "This is the data in the first chunk and this is the second one" (values "This is the data in the first chunk and this is the second one"
"Content-Type: text/plain\r\n") "Content-Type: text/plain\r\n\r\n")
(get-pure/headers (get-pure/headers
"HTTP/1.1 200 OK\r\nContent-Type: text/plain\r\nTransfer-Encoding: chunked\r\n\r\n20\r\nThis is the data in the first ch\r\n21\r\nand this is the second oneXXXXXXX\r\n0\r\n") "HTTP/1.1 200 OK\r\nContent-Type: text/plain\r\nTransfer-Encoding: chunked\r\n\r\n20\r\nThis is the data in the first ch\r\n21\r\nand this is the second oneXXXXXXX\r\n0\r\n")
=> =>
(values "This is the data in the first chand this is the second oneXXXXXXX" (values "This is the data in the first chand this is the second oneXXXXXXX"
"Content-Type: text/plain\r\nTransfer-Encoding: chunked\r\n") "Content-Type: text/plain\r\nTransfer-Encoding: chunked\r\n\r\n")
(get-pure/headers (get-pure/headers
"HTTP/1.1 200 OK\r\nContent-Type: text/plain\r\nTransfer-Encoding: chunked\r\nAnother-Header: ta-daa\r\n\r\n20\r\nThis is the data in the first ch\r\n21\r\nand this is the second oneXXXXXXX\r\n0\r\n") "HTTP/1.1 200 OK\r\nContent-Type: text/plain\r\nTransfer-Encoding: chunked\r\nAnother-Header: ta-daa\r\n\r\n20\r\nThis is the data in the first ch\r\n21\r\nand this is the second oneXXXXXXX\r\n0\r\n")
=> =>
(values "This is the data in the first chand this is the second oneXXXXXXX" (values "This is the data in the first chand this is the second oneXXXXXXX"
"Content-Type: text/plain\r\nTransfer-Encoding: chunked\r\nAnother-Header: ta-daa\r\n") "Content-Type: text/plain\r\nTransfer-Encoding: chunked\r\nAnother-Header: ta-daa\r\n\r\n")
) )
(unless skip-actual-redirect? (unless skip-actual-redirect?
@ -135,7 +135,7 @@
"HTTP/1.1 200 OK\r\nContent-Type: text/plain\r\nTransfer-Encoding: chunked\r\nAnother-Header: ta-daa\r\n\r\n20\r\nThis is the data in the first ch\r\n21\r\nand this is the second oneXXXXXXX\r\n0\r\n") "HTTP/1.1 200 OK\r\nContent-Type: text/plain\r\nTransfer-Encoding: chunked\r\nAnother-Header: ta-daa\r\n\r\n20\r\nThis is the data in the first ch\r\n21\r\nand this is the second oneXXXXXXX\r\n0\r\n")
=> =>
(values "This is the data in the first chand this is the second oneXXXXXXX" (values "This is the data in the first chand this is the second oneXXXXXXX"
"Content-Type: text/plain\r\nTransfer-Encoding: chunked\r\nAnother-Header: ta-daa\r\n"))) "Content-Type: text/plain\r\nTransfer-Encoding: chunked\r\nAnother-Header: ta-daa\r\n\r\n")))
(test (test
(put-pure (put-pure

View File

@ -338,11 +338,12 @@
(redirection-loop (- redirections 1) new-url #f)] (redirection-loop (- redirections 1) new-url #f)]
[else [else
(values response-port (values response-port
(apply string-append (string-append (apply string-append
(map (λ (x) (format "~a\r\n" x)) (map (λ (x) (format "~a\r\n" x))
(if status? (if status?
(cons status headers) (cons status headers)
headers))))]))) headers)))
"\r\n"))])))
;; get-pure-port : url [x list (str)] -> in-port ;; get-pure-port : url [x list (str)] -> in-port
(define (get-pure-port url [strings '()] #:redirections [redirections 0]) (define (get-pure-port url [strings '()] #:redirections [redirections 0])