Repository navigation
request: provide read-headers and parse-bindings #81
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -26,6 +26,9 @@ | |
| ;; Happy hacking! | ||
| ;; | ||
|
|
||
| (define nonnegative-length/c | ||
| (or/c exact-nonnegative-integer? +inf.0)) | ||
|
|
||
| (define read-request/c | ||
| (connection? | ||
| listen-port-number? | ||
|
|
@@ -34,6 +37,12 @@ | |
| (values request? boolean?))) | ||
|
|
||
| (provide/contract | ||
| [parse-bindings (-> bytes? (listof binding?))] | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
| (->* () | ||
|
|
@@ -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]) | ||
|
|
@@ -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) | ||
|
|
@@ -511,9 +517,6 @@ | |
| [#f | ||
| (reverse bindings)]))))) | ||
|
|
||
| (module+ internal-test | ||
| (provide parse-bindings)) | ||
|
|
||
|
|
||
| ;; ************************************************** | ||
| ;; read-mime-multipart | ||
|
|
||
There was a problem hiding this comment.
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 likenonnegative-limit/c?