pixl-server-web 1.3.3 → 1.3.4

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/lib/http.js CHANGED
@@ -168,7 +168,7 @@ module.exports = class HTTP {
168
168
  this.http.on('clientError', function(err, socket) {
169
169
  // https://nodejs.org/api/http.html#http_event_clienterror
170
170
  if (!socket._pixl_data) socket._pixl_data = {};
171
- var args = socket._pixl_data.current || { request: {} };
171
+ var args = socket._pixl_data.current || { request: {}, id: 'n/a' };
172
172
  var msg = err.message;
173
173
 
174
174
  if (err.errno && ErrNo.code[err.errno]) {
@@ -193,8 +193,11 @@ module.exports = class HTTP {
193
193
  self.logDebug(5, "Client error: " + socket._pixl_data.id + ": " + msg, err_args);
194
194
  }
195
195
 
196
+ // do not try to write to socket if already closed
197
+ if ((err.code != 'ECONNRESET') && socket.writable) {
198
+ socket.end('HTTP/1.1 400 Bad Request\r\n\r\n');
199
+ }
196
200
  socket._pixl_data.aborted = true;
197
- socket.end('HTTP/1.1 400 Bad Request\r\n\r\n');
198
201
 
199
202
  if (args.callback) {
200
203
  args.callback();
package/lib/https.js CHANGED
@@ -166,7 +166,7 @@ module.exports = class HTTP2 {
166
166
  this.https.on('clientError', function(err, socket) {
167
167
  // https://nodejs.org/api/http.html#http_event_clienterror
168
168
  if (!socket._pixl_data) socket._pixl_data = {};
169
- var args = socket._pixl_data.current || { request: {} };
169
+ var args = socket._pixl_data.current || { request: {}, id: 'n/a' };
170
170
  var msg = err.message;
171
171
 
172
172
  if (err.errno && ErrNo.code[err.errno]) {
@@ -191,8 +191,11 @@ module.exports = class HTTP2 {
191
191
  self.logDebug(5, "Client error: " + socket._pixl_data.id + ": " + msg, err_args);
192
192
  }
193
193
 
194
+ // do not try to write to socket if already closed
195
+ if ((err.code != 'ECONNRESET') && socket.writable) {
196
+ socket.end('HTTP/1.1 400 Bad Request\r\n\r\n');
197
+ }
194
198
  socket._pixl_data.aborted = true;
195
- socket.end('HTTP/1.1 400 Bad Request\r\n\r\n');
196
199
 
197
200
  if (args.callback) {
198
201
  args.callback();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pixl-server-web",
3
- "version": "1.3.3",
3
+ "version": "1.3.4",
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",