owebjs 1.5.3-dev → 1.5.4-dev

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.
@@ -4,6 +4,7 @@ import {
4
4
  import { Writable } from "stream";
5
5
  import { toLowerCase } from "./utils/string.js";
6
6
  import HttpResponseSocket from './responseSocket.js';
7
+ import http from "node:http";
7
8
  class HttpResponse extends Writable {
8
9
  static {
9
10
  __name(this, "HttpResponse");
@@ -22,7 +23,7 @@ class HttpResponse extends Writable {
22
23
  this.res = uResponse;
23
24
  this.server = uServer;
24
25
  this.statusCode = 200;
25
- this.statusMessage = "OK";
26
+ this.statusMessage = null;
26
27
  this.__headers = {};
27
28
  this.headersSent = false;
28
29
  this.socket = new HttpResponseSocket(uResponse);
@@ -50,7 +51,8 @@ class HttpResponse extends Writable {
50
51
  }
51
52
  _flushHeaders() {
52
53
  if (this.headersSent) return;
53
- this.res.writeStatus(`${this.statusCode} ${this.statusMessage}`);
54
+ const message = this.statusMessage || http.STATUS_CODES[this.statusCode] || "Unknown";
55
+ this.res.writeStatus(`${this.statusCode} ${message}`);
54
56
  const keys = Object.keys(this.__headers);
55
57
  for (let i = 0; i < keys.length; i++) {
56
58
  const key = keys[i];
@@ -5,6 +5,7 @@ import { EventEmitter } from "node:events";
5
5
  const REQUEST_EVENT = "request";
6
6
  import HttpRequest from './request.js';
7
7
  import HttpResponse from './response.js';
8
+ import http from "node:http";
8
9
  async function server_default({ cert_file_name, key_file_name }) {
9
10
  let uWS;
10
11
  uWS = (await import("uWebSockets.js")).default;
@@ -195,7 +196,8 @@ async function server_default({ cert_file_name, key_file_name }) {
195
196
  send(payload) {
196
197
  if (aborted || this.finished) return;
197
198
  this.finished = true;
198
- res.writeStatus(`${this.statusCode} Response`);
199
+ const message = http.STATUS_CODES[this.statusCode] || "Response";
200
+ res.writeStatus(`${this.statusCode} ${message}`);
199
201
  for (const [k, v] of Object.entries(this._headers)) {
200
202
  res.writeHeader(k, String(v));
201
203
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "owebjs",
3
- "version": "1.5.3-dev",
3
+ "version": "1.5.4-dev",
4
4
  "description": "A flexible and modern web framework built on top of Fastify",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",