From e02b44768693a02d2bbcbdb12f0d86c4b08573bf Mon Sep 17 00:00:00 2001 From: Ian Williamson Date: Sun, 11 Apr 2021 18:59:15 -0600 Subject: [PATCH] Fixed proxy bug where content-size was set to zero and content-type was unset. This seemed to confuse Jetty in the OpenHab instance. Signed-off-by: Ian Williamson --- routes/index.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/routes/index.js b/routes/index.js index 4312982..bedfb27 100644 --- a/routes/index.js +++ b/routes/index.js @@ -346,6 +346,12 @@ Routes.prototype.proxyRouteOpenhab = function (req, res) { var self = this; this.logger.auditRequest(req); + + for(var i in req.headers) + { + this.logger.debug("In: " + i + " -> " + req.headers[i]); + } + req.connection.setTimeout(600000); if (req.openhab.status === 'offline') { @@ -381,6 +387,16 @@ Routes.prototype.proxyRouteOpenhab = function (req, res) { requestHeaders['host'] = 'home.' + system.getHost() + ':' + system.getPort(); } + if( (requestHeaders['content-length'] === '0') && (requestHeaders['content-type'] === undefined) ) + { + requestHeaders['content-type'] = 'text/plain'; + } + + for(var i in req.headers) + { + this.logger.debug("Out: " + i + " -> " + req.headers[i]); + } + // Send a message with request to openhab agent module this.io.sockets.in(req.openhab.uuid).emit('request', { id: requestId,