1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-23 20:05:32 +02:00

Web client+server: Add Content-Length header for empty bodies.

* module/web/client.scm (sanitize-request): Add a Content-Length
  header if a body if given, even if the body is empty.

* module/web/server.scm (sanitize-response): Add a Content-Length
  header if a body if given, even if the body is empty.
This commit is contained in:
Mark H Weaver 2013-09-12 18:34:39 -04:00
parent 361553b49d
commit 3b2226ec91
2 changed files with 4 additions and 2 deletions

View file

@ -232,6 +232,7 @@ on the procedure being called at any particular time."
(error "unexpected body type"))
((and (response-must-not-include-body? response)
body
;; FIXME make this stricter: even an empty body should be prohibited.
(not (zero? (bytevector-length body))))
(error "response with this status code must not include body" response))
(else
@ -242,7 +243,6 @@ on the procedure being called at any particular time."
(rlen (if (= rlen blen)
response
(error "bad content-length" rlen blen)))
((zero? blen) response)
(else (extend-response response 'content-length blen))))
(if (eq? (request-method request) 'HEAD)
;; Responses to HEAD requests must not include bodies.