braid-http 1.3.17 → 1.3.18
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/braid-http-client.js +8 -2
- package/braid-http-server.js +3 -2
- package/package.json +1 -1
package/braid-http-client.js
CHANGED
|
@@ -859,7 +859,10 @@ async function multiplex_fetch(url, params) {
|
|
|
859
859
|
|
|
860
860
|
// attempt to establish a multiplexed connection
|
|
861
861
|
try {
|
|
862
|
-
|
|
862
|
+
if (braid_fetch.use_multiplexing === 'USE GET')
|
|
863
|
+
var r = await braid_fetch(`${origin}/MULTIPLEX/${multiplexer}`, {retry: true})
|
|
864
|
+
else
|
|
865
|
+
var r = await braid_fetch(`${origin}/${multiplexer}`, {method: 'MULTIPLEX', retry: true})
|
|
863
866
|
} catch (e) {
|
|
864
867
|
// fallback to normal fetch if multiplexed connection fails
|
|
865
868
|
console.error(`Could not establish multiplexed connection.\nGot error: ${e}.\nFalling back to normal connection.`)
|
|
@@ -922,7 +925,10 @@ async function multiplex_fetch(url, params) {
|
|
|
922
925
|
stream_error = e
|
|
923
926
|
bytes_available()
|
|
924
927
|
try {
|
|
925
|
-
|
|
928
|
+
if (braid_fetch.use_multiplexing === 'USE GET')
|
|
929
|
+
await braid_fetch(`${origin}/MULTIPLEX${params.headers.get('multiplexer')}`, {retry: true})
|
|
930
|
+
else
|
|
931
|
+
await braid_fetch(`${origin}${params.headers.get('multiplexer')}`, {method: 'MULTIPLEX', retry: true})
|
|
926
932
|
} catch (e) {
|
|
927
933
|
console.error(`Could not cancel multiplexed connection:`, e)
|
|
928
934
|
throw e
|
package/braid-http-server.js
CHANGED
|
@@ -243,9 +243,10 @@ function braidify (req, res, next) {
|
|
|
243
243
|
req.subscribe = subscribe
|
|
244
244
|
|
|
245
245
|
// Multiplexer stuff
|
|
246
|
-
if (braidify.use_multiplexing && req.method === 'MULTIPLEX')
|
|
246
|
+
if ((braidify.use_multiplexing && req.method === 'MULTIPLEX') ||
|
|
247
|
+
(braidify.use_multiplexing === 'USE GET' && req.url.startsWith('/MULTIPLEX/'))) {
|
|
247
248
|
// parse the multiplexer id and stream id from the url
|
|
248
|
-
var [multiplexer, stream] = req.url.slice(1).split('/')
|
|
249
|
+
var [multiplexer, stream] = req.url.slice(1).replace(/^MULTIPLEX\//, '').split('/')
|
|
249
250
|
|
|
250
251
|
// if there's just a multiplexer, then we're creating a multiplexer..
|
|
251
252
|
if (!stream) {
|