Commit 2c15b603 authored by Kenton Varda's avatar Kenton Varda

Lack of Content-Length or Transfer-Encoding on a request always means no body.

parent aaa95a40
......@@ -618,21 +618,6 @@ static const HttpRequestTestCase REQUEST_TEST_CASES[] {
nullptr, { "0123456789abcdef0123456789abc" },
},
{
"POST /foo/bar HTTP/1.1\r\n"
"Host: example.com\r\n"
"Connection: close\r\n"
"\r\n"
"baz qux corge grault",
HttpMethod::POST,
"/foo/bar",
{{HttpHeaderId::HOST, "example.com"}},
nullptr, { "baz qux corge grault" },
SERVER_ONLY, // Client never sends connection: close
},
{
HUGE_REQUEST,
......
......@@ -1183,9 +1183,8 @@ static_assert(!fastCaseCmp<'f','O','o','B','1','a'>("FooB1"), "");
kj::Own<kj::AsyncInputStream> HttpInputStream::getEntityBody(
RequestOrResponse type, HttpMethod method, uint statusCode,
HttpHeaders::ConnectionHeaders& connectionHeaders) {
if (method == HttpMethod::HEAD ||
(type == REQUEST && method == HttpMethod::GET) ||
(type == RESPONSE && (statusCode == 204 || statusCode == 205 || statusCode == 304))) {
if (type == RESPONSE && (method == HttpMethod::HEAD ||
statusCode == 204 || statusCode == 205 || statusCode == 304)) {
// No body.
return kj::heap<HttpNullEntityReader>(*this);
}
......@@ -1205,6 +1204,11 @@ kj::Own<kj::AsyncInputStream> HttpInputStream::getEntityBody(
strtoull(connectionHeaders.contentLength.cStr(), nullptr, 10));
}
if (type == REQUEST) {
// Lack of a Content-Length or Transfer-Encoding means no body for requests.
return kj::heap<HttpNullEntityReader>(*this);
}
if (connectionHeaders.connection != nullptr) {
// TODO(soon): Connection header can actually have multiple tokens... but no one ever uses
// that feature?
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment