ultimate-express 1.2.9 → 1.2.10

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/response.js +6 -10
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ultimate-express",
3
- "version": "1.2.9",
3
+ "version": "1.2.10",
4
4
  "description": "The Ultimate Express. Fastest http server with full Express compatibility, based on uWebSockets.",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
package/src/response.js CHANGED
@@ -197,26 +197,22 @@ module.exports = class Response extends Writable {
197
197
  this.set('etag', etagFn(data));
198
198
  }
199
199
  const fresh = this.req.fresh;
200
- if(fresh) {
201
- this._res.writeStatus('304');
202
- } else {
203
- this._res.writeStatus(this.statusCode.toString());
204
- }
200
+ this._res.writeStatus(fresh ? '304' : this.statusCode.toString());
205
201
  for(const header in this.headers) {
206
202
  if(header === 'content-length') {
207
203
  continue;
208
204
  }
209
205
  this._res.writeHeader(header, this.headers[header]);
210
206
  }
211
- if(fresh) {
212
- this.headersSent = true;
213
- this.socket.emit('close');
214
- return this._res.end();
215
- }
216
207
  if(!this.headers['content-type']) {
217
208
  this._res.writeHeader('content-type', 'text/html' + (typeof data === 'string' ? `; charset=utf-8` : ''));
218
209
  }
219
210
  this.headersSent = true;
211
+ if(fresh) {
212
+ this._res.end();
213
+ this.socket.emit('close');
214
+ return;
215
+ }
220
216
  }
221
217
  if(!data && this.headers['content-length']) {
222
218
  this._res.endWithoutBody(this.headers['content-length'].toString());