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.
@@ -859,7 +859,10 @@ async function multiplex_fetch(url, params) {
859
859
 
860
860
  // attempt to establish a multiplexed connection
861
861
  try {
862
- var r = await braid_fetch(`${origin}/${multiplexer}`, {method: 'MULTIPLEX', retry: true})
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
- await braid_fetch(`${origin}${params.headers.get('multiplexer')}`, {method: 'MULTIPLEX', retry: true})
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
@@ -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) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "braid-http",
3
- "version": "1.3.17",
3
+ "version": "1.3.18",
4
4
  "description": "An implementation of Braid-HTTP for Node.js and Browsers",
5
5
  "scripts": {
6
6
  "test": "node test/server.js"