braid-http
Advanced tools
Comparing version
@@ -254,8 +254,4 @@ var assert = require('assert') | ||
if ((braidify.enable_multiplex ?? true) && | ||
(req.method === 'MULTIPLEX' || req.url.startsWith('/.well-known/multiplexer/')) && | ||
req.headers['multiplex-version'] === multiplex_version) { | ||
(req.method === 'MULTIPLEX' || req.url.startsWith('/.well-known/multiplexer/'))) { | ||
// let the caller know we're handling things | ||
req.is_multiplexer = res.is_multiplexer = true | ||
// free the cors | ||
@@ -265,3 +261,14 @@ res.setHeader("Access-Control-Allow-Origin", "*") | ||
res.setHeader("Access-Control-Allow-Headers", "*") | ||
res.setHeader("Access-Control-Expose-Headers", "*") | ||
if (req.method === 'OPTIONS') return res.end() | ||
// check the multiplexing protocol version | ||
if (req.headers['multiplex-version'] !== multiplex_version) { | ||
res.writeHead(400, 'Bad Multiplexer Version') | ||
return res.end() | ||
} | ||
// let the caller know we're handling things | ||
req.is_multiplexer = res.is_multiplexer = true | ||
// parse the multiplexer id and request id from the url | ||
@@ -298,3 +305,3 @@ var [multiplexer, request] = req.url.split('/').slice(req.method === 'MULTIPLEX' ? 1 : 3) | ||
'Incremental': '?1', | ||
'Cache-Control': 'no-cache', | ||
'Cache-Control': 'no-store', | ||
'X-Accel-Buffering': 'no', | ||
@@ -379,3 +386,3 @@ ...req.httpVersion !== '2.0' && {'Connection': 'keep-alive'} | ||
var cors_headers = Object.entries(res2.getHeaders()). | ||
filter(x => braidify.cors_headers.has(x.key)) | ||
filter(x => braidify.cors_headers.has(x[0])) | ||
@@ -447,2 +454,6 @@ if (og_stream) { | ||
// copy over any headers which have already been set on res to res2 | ||
for (let x of Object.entries(res.getHeaders())) | ||
res2.setHeader(...x) | ||
// we want access to "res" to be forwarded to our fake "res2", | ||
@@ -449,0 +460,0 @@ // so that it goes into the multiplexer |
{ | ||
"name": "braid-http", | ||
"version": "1.3.57", | ||
"version": "1.3.58", | ||
"description": "An implementation of Braid-HTTP for Node.js and Browsers", | ||
@@ -5,0 +5,0 @@ "scripts": { |
88418
0.49%1731
0.52%