pixl-server-web 1.3.2 → 1.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -6
- package/lib/request.js +20 -5
- package/lib/static.js +8 -8
- package/package.json +2 -2
- package/test/test.js +14 -0
package/README.md
CHANGED
|
@@ -222,7 +222,13 @@ This param allows you to send back any additional custom HTTP headers with each
|
|
|
222
222
|
|
|
223
223
|
## http_timeout
|
|
224
224
|
|
|
225
|
-
This sets the idle socket timeout for all incoming HTTP requests. If omitted, the Node.js default is
|
|
225
|
+
This sets the idle socket timeout for all incoming HTTP requests, in seconds. If omitted, the Node.js default is 120 seconds. Example:
|
|
226
|
+
|
|
227
|
+
```js
|
|
228
|
+
{
|
|
229
|
+
"http_timeout": 120
|
|
230
|
+
}
|
|
231
|
+
```
|
|
226
232
|
|
|
227
233
|
This only applies to reading from sockets when data is expected. It is an *idle read timeout* on the socket itself, and doesn't apply to request handlers.
|
|
228
234
|
|
|
@@ -274,19 +280,17 @@ This completely disables Keep-Alives for all connections. All requests result i
|
|
|
274
280
|
|
|
275
281
|
## http_keep_alive_timeout
|
|
276
282
|
|
|
277
|
-
This sets the HTTP Keep-Alive idle timeout for all sockets. If omitted, the Node.js default is 5 seconds. See [server.keepAliveTimeout](https://nodejs.org/api/http.html#http_server_keepalivetimeout) for details. Example:
|
|
283
|
+
This sets the HTTP Keep-Alive idle timeout for all sockets, measured in seconds. If omitted, the Node.js default is 5 seconds. See [server.keepAliveTimeout](https://nodejs.org/api/http.html#http_server_keepalivetimeout) for details. Example:
|
|
278
284
|
|
|
279
285
|
```js
|
|
280
286
|
{
|
|
281
|
-
"http_keep_alive_timeout":
|
|
287
|
+
"http_keep_alive_timeout": 5
|
|
282
288
|
}
|
|
283
289
|
```
|
|
284
290
|
|
|
285
|
-
This feature was introduced in Node.js version 8. Prior to that, the [http_timeout](#http_timeout) was used as the Keep-Alive timeout.
|
|
286
|
-
|
|
287
291
|
## http_socket_prelim_timeout
|
|
288
292
|
|
|
289
|
-
This sets a special preliminary timeout for brand new sockets when they are first connected. If an HTTP request doesn't come over the socket within this timeout (specified in seconds), then the socket is hard closed. This timeout should always be set lower than the [http_timeout](#http_timeout) if used. This defaults to `0` (disabled). Example use:
|
|
293
|
+
This sets a special preliminary timeout for brand new sockets when they are first connected, measured in seconds. If an HTTP request doesn't come over the socket within this timeout (specified in seconds), then the socket is hard closed. This timeout should always be set lower than the [http_timeout](#http_timeout) if used. This defaults to `0` (disabled). Example use:
|
|
290
294
|
|
|
291
295
|
```js
|
|
292
296
|
{
|
package/lib/request.js
CHANGED
|
@@ -219,12 +219,12 @@ module.exports = class Request {
|
|
|
219
219
|
|
|
220
220
|
if (content_type.match(/(multipart|urlencoded)/i) && !content_encoding) {
|
|
221
221
|
// use formidable for the heavy lifting
|
|
222
|
-
var form =
|
|
222
|
+
var form = Formidable({
|
|
223
223
|
keepExtensions: true,
|
|
224
224
|
maxFieldsSize: self.config.get('http_max_upload_size'),
|
|
225
225
|
maxFileSize: self.config.get('http_max_upload_size'),
|
|
226
|
-
|
|
227
|
-
|
|
226
|
+
uploadDir: self.config.get('http_temp_dir'),
|
|
227
|
+
allowEmptyFiles: self.config.get('http_allow_empty_files') || false
|
|
228
228
|
});
|
|
229
229
|
|
|
230
230
|
form.on('progress', function(bytesReceived, bytesExpected) {
|
|
@@ -237,7 +237,7 @@ module.exports = class Request {
|
|
|
237
237
|
form.parse(request, function(err, _fields, _files) {
|
|
238
238
|
args.perf.end('read');
|
|
239
239
|
if (err) {
|
|
240
|
-
self.logError(400, "Error processing data from: " + ip + ": " + request.url + ": " + err,
|
|
240
|
+
self.logError(400, "Error processing data from: " + ip + ": " + request.url + ": " + (err.message || err),
|
|
241
241
|
{ id: args.id, ips: ips, uri: request.url, headers: request.headers }
|
|
242
242
|
);
|
|
243
243
|
self.sendHTTPResponse( args, "400 Bad Request", {}, "400 Bad Request" );
|
|
@@ -245,7 +245,22 @@ module.exports = class Request {
|
|
|
245
245
|
}
|
|
246
246
|
else {
|
|
247
247
|
args.params = _fields || {};
|
|
248
|
-
|
|
248
|
+
|
|
249
|
+
// restore original formidable v1 API for our files
|
|
250
|
+
args.files = {};
|
|
251
|
+
if (_files) {
|
|
252
|
+
for (var key in _files) {
|
|
253
|
+
var file = _files[key];
|
|
254
|
+
args.files[key] = {
|
|
255
|
+
path: file.filepath,
|
|
256
|
+
type: file.mimetype,
|
|
257
|
+
name: file.originalFilename,
|
|
258
|
+
size: file.size,
|
|
259
|
+
mtime: file.mtime || file.lastModifiedDate
|
|
260
|
+
};
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
|
|
249
264
|
self.filterHTTPRequest(args);
|
|
250
265
|
}
|
|
251
266
|
} );
|
package/lib/static.js
CHANGED
|
@@ -164,13 +164,13 @@ module.exports = class Static {
|
|
|
164
164
|
parseByteRange(req, stat) {
|
|
165
165
|
// parse byte range header from request
|
|
166
166
|
// Example header: Range: bytes=31-49
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
167
|
+
const byteRange = {
|
|
168
|
+
from: 0,
|
|
169
|
+
to: 0
|
|
170
|
+
}
|
|
171
171
|
|
|
172
|
-
|
|
173
|
-
|
|
172
|
+
let rangeHeader = req.headers['range'];
|
|
173
|
+
const flavor = 'bytes=';
|
|
174
174
|
|
|
175
175
|
if (rangeHeader && rangeHeader.startsWith(flavor) && !rangeHeader.includes(',')) {
|
|
176
176
|
// Parse
|
|
@@ -193,7 +193,7 @@ module.exports = class Static {
|
|
|
193
193
|
}
|
|
194
194
|
}
|
|
195
195
|
|
|
196
|
-
|
|
197
|
-
|
|
196
|
+
return null;
|
|
197
|
+
}
|
|
198
198
|
|
|
199
199
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pixl-server-web",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.3",
|
|
4
4
|
"description": "A web server component for the pixl-server framework.",
|
|
5
5
|
"author": "Joseph Huckaby <jhuckaby@gmail.com>",
|
|
6
6
|
"homepage": "https://github.com/jhuckaby/pixl-server-web",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"pixl-perf": "^1.0.0",
|
|
25
25
|
"pixl-acl": "^1.0.1",
|
|
26
26
|
"class-plus": "^1.0.0",
|
|
27
|
-
"formidable": "
|
|
27
|
+
"formidable": "2.0.1",
|
|
28
28
|
"errno": "0.1.7",
|
|
29
29
|
"stream-meter": "1.0.4",
|
|
30
30
|
"async": "3.2.0",
|
package/test/test.js
CHANGED
|
@@ -186,6 +186,20 @@ module.exports = {
|
|
|
186
186
|
);
|
|
187
187
|
},
|
|
188
188
|
|
|
189
|
+
function testBadRequest(test) {
|
|
190
|
+
// test bad HTTP GET request to webserver backend
|
|
191
|
+
// this still resolves to the root dir index due to the ../
|
|
192
|
+
request.get( 'http://127.0.0.1:3020/%0ASet-Cookie%3Acrlfinjection/../',
|
|
193
|
+
function(err, resp, data, perf) {
|
|
194
|
+
test.ok( !err, "No error from PixlRequest: " + err );
|
|
195
|
+
test.ok( !!resp, "Got resp from PixlRequest" );
|
|
196
|
+
test.ok( resp.statusCode == 200, "Got 200 response: " + resp.statusCode );
|
|
197
|
+
test.ok( resp.headers['via'] == "WebServerTest 1.0", "Correct Via header: " + resp.headers['via'] );
|
|
198
|
+
test.done();
|
|
199
|
+
}
|
|
200
|
+
);
|
|
201
|
+
},
|
|
202
|
+
|
|
189
203
|
// query string
|
|
190
204
|
function testQueryString(test) {
|
|
191
205
|
// test simple HTTP GET request with query string
|