braid-http 1.3.79 → 1.3.81
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/README.md +23 -0
- package/braid-http-server.js +12 -6
- package/index.js +2 -1
- package/index.mjs +4 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -360,3 +360,26 @@ Configure mutliplexing with:
|
|
|
360
360
|
var braidify = require('braid-http').http-server
|
|
361
361
|
nbraidify.enable_multiplex = true // or false
|
|
362
362
|
```
|
|
363
|
+
|
|
364
|
+
## Test Procedure
|
|
365
|
+
|
|
366
|
+
Using 3 terminals, in first terminal start the demo chat server:
|
|
367
|
+
|
|
368
|
+
```
|
|
369
|
+
cd demos/chat
|
|
370
|
+
node server.js
|
|
371
|
+
```
|
|
372
|
+
|
|
373
|
+
in second terminal start the demo blog server:
|
|
374
|
+
```
|
|
375
|
+
cd demos/blog
|
|
376
|
+
node server.js
|
|
377
|
+
```
|
|
378
|
+
|
|
379
|
+
and in third and final terminal, start the test server:
|
|
380
|
+
```
|
|
381
|
+
node test/server.js
|
|
382
|
+
```
|
|
383
|
+
|
|
384
|
+
now open https://localhost:9000, and make sure all the boxes turn green, and try out the demo chat and blog, sending a message in each.
|
|
385
|
+
|
package/braid-http-server.js
CHANGED
|
@@ -253,11 +253,7 @@ function braidify (req, res, next) {
|
|
|
253
253
|
if ((braidify.enable_multiplex ?? true) &&
|
|
254
254
|
(req.method === 'MULTIPLEX' || req.url.startsWith('/.well-known/multiplexer/'))) {
|
|
255
255
|
|
|
256
|
-
|
|
257
|
-
res.setHeader("Access-Control-Allow-Origin", "*")
|
|
258
|
-
res.setHeader("Access-Control-Allow-Methods", "*")
|
|
259
|
-
res.setHeader("Access-Control-Allow-Headers", "*")
|
|
260
|
-
res.setHeader("Access-Control-Expose-Headers", "*")
|
|
256
|
+
free_cors(res)
|
|
261
257
|
if (req.method === 'OPTIONS') return res.end()
|
|
262
258
|
|
|
263
259
|
// check the multiplexing protocol version
|
|
@@ -733,4 +729,14 @@ function ascii_ify(s) {
|
|
|
733
729
|
return s.replace(/[^\x20-\x7E]/g, c => '\\u' + c.charCodeAt(0).toString(16).padStart(4, '0'))
|
|
734
730
|
}
|
|
735
731
|
|
|
736
|
-
|
|
732
|
+
function free_cors(res) {
|
|
733
|
+
res.setHeader("Access-Control-Allow-Origin", "*")
|
|
734
|
+
res.setHeader("Access-Control-Allow-Methods", "*")
|
|
735
|
+
res.setHeader("Access-Control-Allow-Headers", "*")
|
|
736
|
+
res.setHeader("Access-Control-Expose-Headers", "*")
|
|
737
|
+
}
|
|
738
|
+
|
|
739
|
+
module.exports = {
|
|
740
|
+
braidify,
|
|
741
|
+
free_cors
|
|
742
|
+
}
|
package/index.js
CHANGED
package/index.mjs
CHANGED
|
@@ -9,7 +9,8 @@ import braid_server from './braid-http-server.js'
|
|
|
9
9
|
|
|
10
10
|
var fetch = braid_client.fetch,
|
|
11
11
|
http_client = braid_client.http,
|
|
12
|
-
http_server = braid_server
|
|
12
|
+
http_server = braid_server.braidify,
|
|
13
|
+
free_cors = braid_server.free_cors
|
|
13
14
|
|
|
14
|
-
export { fetch, http_client, http_server }
|
|
15
|
-
export default { fetch, http_client, http_server }
|
|
15
|
+
export { fetch, http_client, http_server, free_cors }
|
|
16
|
+
export default { fetch, http_client, http_server, free_cors }
|