Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions web-server-lib/web-server/http/request.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
;; Happy hacking!
;;

(define nonnegative-length/c
(or/c exact-nonnegative-integer? +inf.0))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bikeshedding about names: if we use this for more things as we were discussing in #77, it would apply to timeouts and counts (e.g. #:max-request-files) as well as "length"s per se. I don't have a great idea for a name, but maybe something like nonnegative-limit/c?


(define read-request/c
(connection?
listen-port-number?
Expand All @@ -34,6 +37,12 @@
(values request? boolean?)))

(provide/contract
[parse-bindings (-> bytes? (listof binding?))]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be worth adding a comment here so that others don't make the same reasonable assumption you did in the future.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or maybe even document these bindings.

[read-headers (->* (input-port?)
(nonnegative-length/c
nonnegative-length/c)
(listof header?))]

[rename make-ext:read-request
make-read-request
(->* ()
Expand Down Expand Up @@ -322,7 +331,7 @@
(lambda (a) (regexp-match rx a))))

; read-headers : iport number number -> (listof header?)
(define (read-headers in max-heads max-head-length)
(define (read-headers in [max-heads +inf.0] [max-head-length +inf.0])
(parameterize ([current-http-line-limit max-head-length])
(reverse
(let loop ([heads null])
Expand All @@ -340,9 +349,6 @@
(loop (cons head heads))])]
[else (network-error 'read-headers "malformed header: ~e" l)])))))

(module+ internal-test
(provide read-headers))

; read-folded-head : iport bytes number -> bytes
; reads the next line of input for headers that are line-folded
(define (read-folded-head in rhs max-length)
Expand Down Expand Up @@ -511,9 +517,6 @@
[#f
(reverse bindings)])))))

(module+ internal-test
(provide parse-bindings))


;; **************************************************
;; read-mime-multipart
Expand Down