Supporting PUT in request handling

svn: r16008
This commit is contained in:
Jay McCarthy 2009-09-14 18:43:51 +00:00
parent b2b557ab0b
commit b3ed0130fc

View File

@ -196,6 +196,21 @@
[#f
(let ([raw-bytes (apply bytes-append (read-to-eof in))])
(values (parse-bindings raw-bytes) raw-bytes))])]))]
[(bytes-ci=? #"PUT" meth)
(local
[(define content-type (headers-assq* #"Content-Type" headers))
(define in (connection-i-port conn))]
(match (headers-assq* #"Content-Length" headers)
[(struct header (_ value))
(cond [(string->number (bytes->string/utf-8 value))
=> (lambda (len)
(let ([raw-bytes (read-bytes len in)])
(values empty raw-bytes)))]
[else
(network-error 'read-bindings "Put request contained a non-numeric content-length")])]
[#f
(let ([raw-bytes (apply bytes-append (read-to-eof in))])
(values empty raw-bytes))]))]
[meth
(values empty #f)]))