diff options
author | Christian Franke <nobody@nowhere.ws> | 2014-02-18 03:45:31 +0100 |
---|---|---|
committer | Christian Franke <nobody@nowhere.ws> | 2014-02-18 03:45:31 +0100 |
commit | 08feea56c82a658d0953b86d29c5d2ec5a9d5b80 (patch) | |
tree | c7b793280e70e57e2bdc2659267ad430bac6919b | |
parent | 23919093c31cdfc7673ba3df149e555ca5867406 (diff) |
Don't use keepalive.
-rw-r--r-- | server.js | 15 |
1 files changed, 12 insertions, 3 deletions
@@ -3,6 +3,8 @@ var express = require('express'); var fs = require('fs'); var http = require('http'); +var url_module = require('url'); + var MjpegProxy = require('mjpeg-proxy').MjpegProxy; var app = express(); @@ -32,7 +34,9 @@ function SimpleProxy(url) { self.url = url; self.handle_request = function(req, res) { - var proxy = http.request(self.url, function(proxy_res) { + var request_options = url_module.parse(self.url); + request_options.agent = false; + var proxy = http.request(request_options, function(proxy_res) { proxy_res.on('data', function(chunk) { res.write(chunk, 'binary'); }); @@ -47,7 +51,12 @@ function SimpleProxy(url) { console.log(err); res.end(); }); - proxy.end(); + req.on('data', function(chunk) { + proxy.write(chunk, 'binary'); + }); + req.on('end', function() { + proxy.end(); + }); }; } @@ -72,7 +81,7 @@ for (var camera_idx in cameras) { urls.up = camera.baseurl + '/control/up'; urls.right = camera.baseurl + '/control/right'; urls.left = camera.baseurl + '/control/left'; - urls.snapshow = camera.baseurl + '/snapshot.jpg'; + urls.snapshot = camera.baseurl + '/snapshot.jpg'; }; camera.proxy = new MjpegProxy(urls.mjpeg, still_frames); |