svn: r13378
This commit is contained in:
Jay McCarthy 2009-02-03 16:39:18 +00:00
parent 7f13cb3da8
commit dce1ab92b5

View File

@ -1,4 +1,4 @@
#lang scheme/base #lang scheme
(require mzlib/contract (require mzlib/contract
mzlib/plt-match mzlib/plt-match
net/url net/url
@ -147,17 +147,18 @@
;; read-bindings&post-data/raw: connection symbol url (listof header?) -> (values (or/c (listof binding?) string?) (or/c bytes? false/c?)) ;; read-bindings&post-data/raw: connection symbol url (listof header?) -> (values (or/c (listof binding?) string?) (or/c bytes? false/c?))
(define (read-bindings&post-data/raw conn meth uri headers) (define (read-bindings&post-data/raw conn meth uri headers)
(match meth (cond
['get [(bytes-ci=? #"GET" meth)
(values (map (match-lambda (values (map (match-lambda
[(list-rest k v) [(list-rest k v)
(make-binding:form (string->bytes/utf-8 (symbol->string k)) (make-binding:form (string->bytes/utf-8 (symbol->string k))
(string->bytes/utf-8 v))]) (string->bytes/utf-8 v))])
(url-query uri)) (url-query uri))
#f)] #f)]
['post [(bytes-ci=? #"POST" meth)
(define content-type (headers-assq* #"Content-Type" headers)) (local
(define in (connection-i-port conn)) [(define content-type (headers-assq* #"Content-Type" headers))
(define in (connection-i-port conn))]
(cond (cond
[(and content-type (regexp-match FILE-FORM-REGEXP (header-value content-type))) [(and content-type (regexp-match FILE-FORM-REGEXP (header-value content-type)))
=> (match-lambda => (match-lambda
@ -188,7 +189,7 @@
(network-error 'read-bindings "Post request contained a non-numeric content-length")])] (network-error 'read-bindings "Post request contained a non-numeric content-length")])]
[#f [#f
(let ([raw-bytes (apply bytes-append (read-to-eof in))]) (let ([raw-bytes (apply bytes-append (read-to-eof in))])
(values (parse-bindings raw-bytes) raw-bytes))])])] (values (parse-bindings raw-bytes) raw-bytes))])]))]
[meth [meth
(values empty #f)])) (values empty #f)]))