Fix bugs in cookiejar and transfer-encoding
This commit is contained in:
parent
e3fefc7af4
commit
66ca83ded6
|
@ -3,8 +3,8 @@
|
|||
(require xml)
|
||||
|
||||
(provide debug-mode? printf-debug print-progress print-complete
|
||||
current-cookie-jar update-cookie-jar! cookie-jar->header
|
||||
find-flags find-hrefs)
|
||||
current-cookie-jar update-cookie-jar! cookie-jar->header cookie-jar-ref
|
||||
string->xexpr find-flags find-hrefs)
|
||||
|
||||
;; scheme is bad and it should feel bad
|
||||
(define member? member)
|
||||
|
@ -45,6 +45,13 @@
|
|||
;; Parameter for current cookie jar
|
||||
(define current-cookie-jar (make-parameter (make-cookie-jar)))
|
||||
|
||||
;; CookieJar -> String
|
||||
;; Gets a value from a cookie jar
|
||||
(define (cookie-jar-ref jar key)
|
||||
(call-with-semaphore
|
||||
(cj-sema jar)
|
||||
(lambda () (hash-ref (cj-jar jar) key))))
|
||||
|
||||
;; CookieJar [List-of (cons Symbol String)] ->
|
||||
;; For a response with the given headers, finds any set-cookie headers and updates the jar
|
||||
(define (update-cookie-jar! jar hdrs)
|
||||
|
@ -66,7 +73,7 @@
|
|||
;; CookieJar -> (cons Symbol String)
|
||||
;; Converts this cookie jar into a cookie header for requests
|
||||
(define (cookie-jar->header jar)
|
||||
(call-with-semaphore (cj-sema jar) (curry unbox (cj-cache jar))))
|
||||
(call-with-semaphore (cj-sema jar) (lambda () (unbox (cj-cache jar)))))
|
||||
|
||||
;; HTML (XML) handling
|
||||
;; String -> xexpr
|
||||
|
|
|
@ -236,7 +236,7 @@
|
|||
|
||||
;; input-port? -> [streamof bytes?]
|
||||
(define (read-chunked-stream port)
|
||||
(define len (string->number (read-crlf-line port)))
|
||||
(define len (string->number (read-crlf-line port) 16))
|
||||
(unless (integer? len)
|
||||
(raise-read-http-error "read-chunked-stream: invalid chunked encoding detected"))
|
||||
(define data (read-bytes len port))
|
||||
|
|
Loading…
Reference in New Issue