velocious 1.0.81 → 1.0.82
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.
package/package.json
CHANGED
package/src/controller.js
CHANGED
|
@@ -86,7 +86,7 @@ export default class VelociousController {
|
|
|
86
86
|
renderJsonArg(json) {
|
|
87
87
|
const body = JSON.stringify(json)
|
|
88
88
|
|
|
89
|
-
this._response.
|
|
89
|
+
this._response.setHeader("Content-Type", "application/json; charset=UTF-8")
|
|
90
90
|
this._response.setBody(body)
|
|
91
91
|
}
|
|
92
92
|
|
|
@@ -100,7 +100,7 @@ export default class VelociousController {
|
|
|
100
100
|
if (err) {
|
|
101
101
|
reject(err)
|
|
102
102
|
} else {
|
|
103
|
-
this._response.
|
|
103
|
+
this._response.setHeader("Content-Type", "text/html; charset=UTF-8")
|
|
104
104
|
this._response.setBody(str)
|
|
105
105
|
|
|
106
106
|
resolve()
|
|
@@ -87,16 +87,16 @@ export default class VeoliciousHttpServerClient {
|
|
|
87
87
|
this.logger.debug("sendResponse", {clientCount: this.clientCount, connectionHeader, httpVersion})
|
|
88
88
|
|
|
89
89
|
if (httpVersion == "1.0" && connectionHeader == "keep-alive") {
|
|
90
|
-
response.
|
|
90
|
+
response.setHeader("Connection", "Keep-Alive")
|
|
91
91
|
} else {
|
|
92
|
-
response.
|
|
92
|
+
response.setHeader("Connection", "Close")
|
|
93
93
|
}
|
|
94
94
|
|
|
95
|
-
const
|
|
95
|
+
const contentLength = new TextEncoder().encode(body).length
|
|
96
96
|
|
|
97
|
-
response.
|
|
98
|
-
response.
|
|
99
|
-
response.
|
|
97
|
+
response.setHeader("Content-Length", contentLength)
|
|
98
|
+
response.setHeader("Date", date.toUTCString())
|
|
99
|
+
response.setHeader("Server", "Velocious")
|
|
100
100
|
|
|
101
101
|
let headers = ""
|
|
102
102
|
|
|
@@ -14,6 +14,10 @@ export default class VelociousHttpServerClientResponse {
|
|
|
14
14
|
this.headers[key].push(value)
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
+
setHeader(key, value) {
|
|
18
|
+
this.headers[key] = [value]
|
|
19
|
+
}
|
|
20
|
+
|
|
17
21
|
getBody() {
|
|
18
22
|
if (this.body !== undefined) {
|
|
19
23
|
return this.body
|
|
@@ -35,8 +39,8 @@ export default class VelociousHttpServerClientResponse {
|
|
|
35
39
|
}
|
|
36
40
|
|
|
37
41
|
setErrorBody(error) {
|
|
38
|
-
this.
|
|
39
|
-
this.
|
|
42
|
+
this.setHeader("Content-Type", "text/plain; charset=UTF-8")
|
|
43
|
+
this.setBody(`${error.message}\n\n${error.stack}`)
|
|
40
44
|
}
|
|
41
45
|
|
|
42
46
|
setStatus(status) {
|