qcobjects-cli 2.5.140-beta → 2.5.143-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.
@@ -406,10 +406,23 @@ class HTTPServerResponse extends InheritClass {
406
406
  super(o);
407
407
  var self = this;
408
408
  self.body = "";
409
- self.request = o.request;
409
+ self.request = o.request || {};
410
410
  self.stream = o.stream;
411
411
  self.headers = o.headers;
412
412
  self.fileDispatcher = o.fileDispatcher;
413
+
414
+ // Initialize request properties if not set
415
+ if (!self.request.scriptname || !self.request.pathname) {
416
+ const defaultPath = "/";
417
+ self.request.pathname = self.request.pathname || defaultPath;
418
+ self.request.scriptname = self.request.scriptname || CONFIG.get("documentRootFileIndex", "index.html");
419
+ }
420
+
421
+ // Ensure documentRoot is set
422
+ if (!CONFIG.get("documentRoot")) {
423
+ CONFIG.set("documentRoot", path.join(process.cwd(), "public"));
424
+ }
425
+
413
426
  self._generateResponse();
414
427
  this.headers = {
415
428
  ":status": 200,
@@ -247,13 +247,25 @@ class HTTPServerResponse extends InheritClass {
247
247
  stream
248
248
  });
249
249
  var self = this;
250
- self.request = request;
250
+ self.request = request || {};
251
251
  self.stream = stream;
252
252
  self.headers = headers;
253
253
  self.body = body;
254
254
  self.fileDispatcher = fileDispatcher;
255
- self._generateResponse();
256
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
+ }
262
+
263
+ // Ensure documentRoot is set
264
+ if (!CONFIG.get("documentRoot")) {
265
+ CONFIG.set("documentRoot", path.join(process.cwd(), "public"));
266
+ }
267
+
268
+ self._generateResponse();
257
269
  }
258
270
 
259
271
  sendFile(stream: any, fileName: string) {
@@ -80,11 +80,24 @@ class HTTP2ServerResponse extends InheritClass {
80
80
  }) {
81
81
  super();
82
82
  var self = this;
83
- self.request = request;
83
+ self.request = request || {};
84
84
  self.stream = stream;
85
85
  self.headers = headers;
86
86
  self.body = body;
87
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
+
96
+ // Ensure documentRoot is set
97
+ if (!CONFIG.get("documentRoot")) {
98
+ CONFIG.set("documentRoot", path.join(process.cwd(), "public"));
99
+ }
100
+
88
101
  self._generateResponse();
89
102
  }
90
103
 
@@ -309,13 +322,20 @@ export class HTTP2Server extends InheritClass {
309
322
  http2ServerInstance.request.method = headers[":method"];
310
323
  http2ServerInstance.request.path = headers[":path"];
311
324
 
312
-
313
- if (http2ServerInstance.request.pathname.indexOf(".") < 0) {
314
- http2ServerInstance.request.scriptname = CONFIG.get("documentRootFileIndex");
325
+ // Fix pathname and scriptname initialization
326
+ const pathParts = http2ServerInstance.request.pathname.split("/");
327
+ if (pathParts.length > 0) {
328
+ if (http2ServerInstance.request.pathname.indexOf(".") < 0) {
329
+ http2ServerInstance.request.scriptname = CONFIG.get("documentRootFileIndex", "index.html");
330
+ // Keep the original pathname as is, no need to reassign
331
+ } else {
332
+ http2ServerInstance.request.scriptname = pathParts[pathParts.length - 1];
333
+ http2ServerInstance.request.pathname = http2ServerInstance.request.pathname.substr(0, http2ServerInstance.request.pathname.lastIndexOf("/"));
334
+ }
315
335
  } else {
316
- http2ServerInstance.request.scriptname = http2ServerInstance.request.pathname.split("/").reverse()[0];
336
+ http2ServerInstance.request.scriptname = CONFIG.get("documentRootFileIndex", "index.html");
337
+ http2ServerInstance.request.pathname = "/";
317
338
  }
318
- http2ServerInstance.request.pathname = this.request.pathname.substr(0, http2ServerInstance.request.pathname.lastIndexOf("/"));
319
339
 
320
340
  logger.debug(PipeLog.pipe(this.request));
321
341