Browse Source

Hopeful fix for connect-restreamer

dev/git-series/gccdum
Matt Godbolt 7 years ago
parent
commit
9b9e1874c7
  1. 2
      app.js
  2. 3
      etc/config/c++.lud-ldnmg01.properties
  3. 23
      lib/restreamer.js
  4. 1
      package.json

2
app.js

@ -324,7 +324,7 @@ findCompilers().then(function (compilers) {
bodyParser = require('body-parser'),
logger = require('morgan'),
compression = require('compression'),
restreamer = require('connect-restreamer');
restreamer = require('./lib/restreamer');
webServer
.use(logger('combined'))

3
etc/config/c++.lud-ldnmg01.properties

@ -1,6 +1,7 @@
# Default settings for GCC Explorer.
defaultCompiler=g52
compilers=g44:g45:g46:clang35:g51:g52
#compilers=g44:g45:g46:clang35:g51:g52
compilers=localhost@20480
compiler.g44.exe=/usr/bin/g++-4.4
compiler.g44.name=g++ 4.4
compiler.g44.alias=/usr/bin/g++-4.4

23
lib/restreamer.js

@ -0,0 +1,23 @@
// Adapted from connect-restreamer, with bugfix to move "next" after the process.nextTick()
module.exports = function (options) {
options = options || {};
options.property = options.property || 'body';
options.stringify = options.stringify || JSON.stringify;
return function (req, res, next) {
req.removeAllListeners('data');
req.removeAllListeners('end');
if (req.headers['content-length'] !== undefined) {
req.headers['content-length'] = Buffer.byteLength(options.stringify(req[options.property]), 'utf8');
}
process.nextTick(function () {
if (req[options.property]) {
if ('function' === typeof options.modify)
req[options.property] = options.modify(req[options.property]);
req.emit('data', options.stringify(req[options.property]));
}
req.emit('end');
});
next();
}
};

1
package.json

@ -18,7 +18,6 @@
"dependencies": {
"body-parser": "1.14.x",
"compression": "1.6.x",
"connect-restreamer": "1.0.x",
"express": "4.13.x",
"fs-extra": "0.26.x",
"http-proxy": "1.12.x",

Loading…
Cancel
Save