From 8615a6fd883b3ce1d4b306251e74859f5cf7b6e5 Mon Sep 17 00:00:00 2001 From: Dominik Sigmund <dominik.sigmund@br.de> Date: Tue, 3 Nov 2020 19:44:13 +0100 Subject: [PATCH] Change http to string --- examples/http-server.js | 6 ++---- index.js | 2 +- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/examples/http-server.js b/examples/http-server.js index 9616f5e..4fe5802 100644 --- a/examples/http-server.js +++ b/examples/http-server.js @@ -1,5 +1,3 @@ -const { RSA_NO_PADDING } = require('constants'); -const { readdirSync } = require('fs'); var http = require('http'); http.createServer(function (req, res) { console.log(req.method, req.url) @@ -9,8 +7,8 @@ http.createServer(function (req, res) { body += data }) req.on('end', function() { - console.log(JSON.parse(body)) - res.writeHead(200, {'Content-Type': 'text/html'}) + console.log(body) + res.writeHead(202, {'Content-Type': 'text/html'}) res.end('post received') }) diff --git a/index.js b/index.js index 778cf8b..9050ab6 100644 --- a/index.js +++ b/index.js @@ -132,7 +132,7 @@ function Log (options) { level: this.levels[tag] }) if (this.options.graylog.mode && this.options.graylog.mode === 'http') { - this.request.post(this.options.graylog.server + ':' + this.options.graylog.port + '/gelf', {json: JSON.parse(data)}, (error, res, body) => { + this.request.post(this.options.graylog.server + ':' + this.options.graylog.port + '/gelf', {body: data}, (error, res, body) => { if (error) { console.error(error) } -- GitLab