bench: make http_simple send chunked encoding if requested
This commit is contained in:
parent
4cf931db17
commit
d72c6940f8
@ -39,6 +39,7 @@ var server = http.createServer(function (req, res) {
|
|||||||
var command = commands[1];
|
var command = commands[1];
|
||||||
var body = "";
|
var body = "";
|
||||||
var arg = commands[2];
|
var arg = commands[2];
|
||||||
|
var chunked = (commands[3] === "chunked");
|
||||||
var status = 200;
|
var status = 200;
|
||||||
|
|
||||||
if (command == "bytes") {
|
if (command == "bytes") {
|
||||||
@ -81,10 +82,16 @@ var server = http.createServer(function (req, res) {
|
|||||||
body = "not found\n";
|
body = "not found\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (chunked) {
|
||||||
|
res.writeHead(status, { "Content-Type": "text/plain",
|
||||||
|
"Transfer-Encoding": "chunked" });
|
||||||
|
} else {
|
||||||
var content_length = body.length.toString();
|
var content_length = body.length.toString();
|
||||||
|
|
||||||
res.writeHead(status, { "Content-Type": "text/plain",
|
res.writeHead(status, { "Content-Type": "text/plain",
|
||||||
"Content-Length": content_length });
|
"Content-Length": content_length });
|
||||||
|
}
|
||||||
|
|
||||||
res.end(body);
|
res.end(body);
|
||||||
|
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user