Skip to content
This repository has been archived by the owner. It is now read-only.

Gather all chunks of POST body before splitting #6

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

@@ -58,8 +58,17 @@ graphite_connection.on("error", function() {

var request_handler = function(request, response) {
var putval_re = /^PUTVAL ([^ ]+)(?: ([^ ]+=[^ ]+)?) ([0-9.]+)(:.*)/;
var chunks = [];
request.addListener("data", function(chunk) {
metrics = chunk.toString().split("\n");
chunks.push(chunk.toString());
});
request.addListener("end", function(chunk) {
var body = chunks.join("");
if (parseInt(request.headers["content-length"]) != body.length) {
console.log("Content-Length: %d != body.length: %d\n",
request.headers["content-length"], body.length);
}
var metrics = body.split("\n");
for (var i in metrics) {
var m = putval_re.exec(metrics[i]);
if (!m) {
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.