qcobjects-cli 2.5.139-beta → 2.5.141-beta

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.
@@ -247,9 +247,20 @@ class HTTPServerResponse extends InheritClass {
247
247
  stream
248
248
  });
249
249
  var self = this;
250
+ self.request = request || {};
250
251
  self.stream = stream;
251
- self._generateResponse();
252
+ self.headers = headers;
253
+ self.body = body;
254
+ self.fileDispatcher = fileDispatcher;
255
+
256
+ // Initialize request properties if not set
257
+ if (!self.request.scriptname || !self.request.pathname) {
258
+ const defaultPath = "/";
259
+ self.request.pathname = self.request.pathname || defaultPath;
260
+ self.request.scriptname = self.request.scriptname || CONFIG.get("documentRootFileIndex", "index.html");
261
+ }
252
262
 
263
+ self._generateResponse();
253
264
  }
254
265
 
255
266
  sendFile(stream: any, fileName: string) {
@@ -64,7 +64,7 @@ const ImportMicroservice = function (microservicePackage: string) {
64
64
  class HTTP2ServerResponse extends InheritClass {
65
65
  fileDispatcher: any;
66
66
  request: any;
67
- headers!: { [x: string]: number; };
67
+ headers!: { [x: string]: string | number };
68
68
  stream: any;
69
69
  body: any;
70
70
  constructor({
@@ -80,8 +80,20 @@ class HTTP2ServerResponse extends InheritClass {
80
80
  }) {
81
81
  super();
82
82
  var self = this;
83
+ self.request = request || {};
84
+ self.stream = stream;
85
+ self.headers = headers;
86
+ self.body = body;
87
+ self.fileDispatcher = fileDispatcher;
88
+
89
+ // Initialize request properties if not set
90
+ if (!self.request.scriptname || !self.request.pathname) {
91
+ const defaultPath = "/";
92
+ self.request.pathname = self.request.pathname || defaultPath;
93
+ self.request.scriptname = self.request.scriptname || CONFIG.get("documentRootFileIndex", "index.html");
94
+ }
95
+
83
96
  self._generateResponse();
84
-
85
97
  }
86
98
 
87
99
  sendFile(stream: { respondWithFD: (arg0: any, arg1: { "content-length": any; "last-modified": any; "content-type": any; "cache-control": any; }) => void; on: (arg0: string, arg1: { (): void; (): void; }) => void; end: () => void; respond: (arg0: { ":status": number; "content-type": any; }) => void; write: (arg0: string) => void; }, fileName: string) {
@@ -305,13 +317,20 @@ export class HTTP2Server extends InheritClass {
305
317
  http2ServerInstance.request.method = headers[":method"];
306
318
  http2ServerInstance.request.path = headers[":path"];
307
319
 
308
-
309
- if (http2ServerInstance.request.pathname.indexOf(".") < 0) {
310
- http2ServerInstance.request.scriptname = CONFIG.get("documentRootFileIndex");
320
+ // Fix pathname and scriptname initialization
321
+ const pathParts = http2ServerInstance.request.pathname.split("/");
322
+ if (pathParts.length > 0) {
323
+ if (http2ServerInstance.request.pathname.indexOf(".") < 0) {
324
+ http2ServerInstance.request.scriptname = CONFIG.get("documentRootFileIndex", "index.html");
325
+ // Keep the original pathname as is, no need to reassign
326
+ } else {
327
+ http2ServerInstance.request.scriptname = pathParts[pathParts.length - 1];
328
+ http2ServerInstance.request.pathname = http2ServerInstance.request.pathname.substr(0, http2ServerInstance.request.pathname.lastIndexOf("/"));
329
+ }
311
330
  } else {
312
- http2ServerInstance.request.scriptname = http2ServerInstance.request.pathname.split("/").reverse()[0];
331
+ http2ServerInstance.request.scriptname = CONFIG.get("documentRootFileIndex", "index.html");
332
+ http2ServerInstance.request.pathname = "/";
313
333
  }
314
- http2ServerInstance.request.pathname = this.request.pathname.substr(0, http2ServerInstance.request.pathname.lastIndexOf("/"));
315
334
 
316
335
  logger.debug(PipeLog.pipe(this.request));
317
336