Skip to content

Commit

Permalink
Enforce HTTP server response body size if "Content-Length" is present.
Browse files Browse the repository at this point in the history
  • Loading branch information
s-ludwig committed Feb 2, 2016
1 parent e0fae09 commit 3d85140
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions source/vibe/http/server.d
Expand Up @@ -944,9 +944,10 @@ final class HTTPServerResponse : HTTPResponse {
headers.remove("Content-Length");
}

if ("Content-Length" in headers) {
if (auto pcl = "Content-Length" in headers) {
writeHeader();
m_bodyWriter = m_countingWriter; // TODO: LimitedOutputStream(m_conn, content_length)
m_countingWriter.writeLimit = (*pcl).to!ulong;
m_bodyWriter = m_countingWriter;
} else {
headers["Transfer-Encoding"] = "chunked";
writeHeader();
Expand Down Expand Up @@ -979,8 +980,7 @@ final class HTTPServerResponse : HTTPResponse {
{
statusCode = status;
headers["Location"] = url;
headers["Content-Length"] = "14";
bodyWriter.write("redirecting...");
writeBody("redirecting...");
}
/// ditto
void redirect(URL url, int status = HTTPStatus.Found)
Expand Down

0 comments on commit 3d85140

Please sign in to comment.