diff --git a/private/util.rkt b/private/util.rkt index adb77fa..b196d62 100644 --- a/private/util.rkt +++ b/private/util.rkt @@ -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 diff --git a/smol-http/http-msg.rkt b/smol-http/http-msg.rkt index 3b5677f..e197a7e 100644 --- a/smol-http/http-msg.rkt +++ b/smol-http/http-msg.rkt @@ -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))