@vandenberghinc/volt 1.2.21 → 1.2.23

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.
@@ -108,8 +108,8 @@ class Stream {
108
108
  }
109
109
  return (Array.isArray(value) ? value[0] : value) || void 0;
110
110
  };
111
- this._ip = unpack_ip_header(this.headers["x-forwarded-for"]) || unpack_ip_header(this.headers["x-real-ip"]) || this.http2 ? this.s.session.socket.remoteAddress : this.req.socket.remoteAddress;
112
- this._port = this.http2 ? this.s.session.socket.remotePort : this.req.socket.remotePort;
111
+ this._ip = unpack_ip_header(this.headers["x-forwarded-for"]) || unpack_ip_header(this.headers["x-real-ip"]) || (this.http2 ? this.s.session?.socket?.remoteAddress : this.req?.socket?.remoteAddress) || "unknown";
112
+ this._port = (this.http2 ? this.s.session?.socket?.remotePort : this.req?.socket?.remotePort) || -1;
113
113
  this.body = "";
114
114
  this.raw_body = Buffer.alloc(0);
115
115
  this.wire_body = Buffer.alloc(0);
@@ -771,6 +771,9 @@ class Stream {
771
771
  this.res?.setHeader(key.toLowerCase(), typeof v === "boolean" ? v.toString() : v);
772
772
  }
773
773
  });
774
+ if (this.res_cookies.length > 0) {
775
+ this.res.setHeader("Set-Cookie", this.res_cookies);
776
+ }
774
777
  }
775
778
  /**
776
779
  * Send a response.
@@ -99,8 +99,9 @@ export class Stream {
99
99
  };
100
100
  this._ip = (unpack_ip_header(this.headers['x-forwarded-for'])
101
101
  || unpack_ip_header(this.headers['x-real-ip'])
102
- || this.http2 ? this.s.session.socket.remoteAddress : this.req.socket.remoteAddress);
103
- this._port = this.http2 ? this.s.session.socket.remotePort : this.req.socket.remotePort;
102
+ || (this.http2 ? this.s.session?.socket?.remoteAddress : this.req?.socket?.remoteAddress)
103
+ || "unknown");
104
+ this._port = (this.http2 ? this.s.session?.socket?.remotePort : this.req?.socket?.remotePort) || -1;
104
105
  // Read body.
105
106
  this.body = "";
106
107
  this.raw_body = Buffer.alloc(0);
@@ -866,6 +867,10 @@ export class Stream {
866
867
  this.res?.setHeader(key.toLowerCase(), typeof v === "boolean" ? v.toString() : v);
867
868
  }
868
869
  });
870
+ // Attach any cookies staged via set_cookie/set_cookies (HTTP/1)
871
+ if (this.res_cookies.length > 0) {
872
+ this.res.setHeader("Set-Cookie", this.res_cookies);
873
+ }
869
874
  }
870
875
  /**
871
876
  * Send a response.
@@ -99,8 +99,9 @@ export class Stream {
99
99
  };
100
100
  this._ip = (unpack_ip_header(this.headers['x-forwarded-for'])
101
101
  || unpack_ip_header(this.headers['x-real-ip'])
102
- || this.http2 ? this.s.session.socket.remoteAddress : this.req.socket.remoteAddress);
103
- this._port = this.http2 ? this.s.session.socket.remotePort : this.req.socket.remotePort;
102
+ || (this.http2 ? this.s.session?.socket?.remoteAddress : this.req?.socket?.remoteAddress)
103
+ || "unknown");
104
+ this._port = (this.http2 ? this.s.session?.socket?.remotePort : this.req?.socket?.remotePort) || -1;
104
105
  // Read body.
105
106
  this.body = "";
106
107
  this.raw_body = Buffer.alloc(0);
@@ -866,6 +867,10 @@ export class Stream {
866
867
  this.res?.setHeader(key.toLowerCase(), typeof v === "boolean" ? v.toString() : v);
867
868
  }
868
869
  });
870
+ // Attach any cookies staged via set_cookie/set_cookies (HTTP/1)
871
+ if (this.res_cookies.length > 0) {
872
+ this.res.setHeader("Set-Cookie", this.res_cookies);
873
+ }
869
874
  }
870
875
  /**
871
876
  * Send a response.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "author": "Daan van den Bergh",
3
3
  "name": "@vandenberghinc/volt",
4
- "version": "1.2.21",
4
+ "version": "1.2.23",
5
5
  "description": "",
6
6
  "type": "module",
7
7
  "types": "./backend/dist/esm/index.d.ts",