braid-http 1.3.30 → 1.3.32

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.
@@ -861,7 +861,7 @@ async function multiplex_fetch(url, params) {
861
861
  // so let's try with a custom header
862
862
  try {
863
863
  using_multiplex_header = true
864
- r = await braid_fetch(`${origin}/${multiplexer}`, {headers: {Multiplex: true, 'Multiplex-Version': '0.0.1'}, retry: true})
864
+ r = await braid_fetch(`${origin}/.well-known/multiplex/${multiplexer}`, {headers: {'Multiplex-Version': '0.0.1'}, retry: true})
865
865
 
866
866
  if (!r.ok) throw new Error('status not ok: ' + r.status)
867
867
  if (r.headers.get('Multiplex-Version') !== '0.0.1') throw new Error('wrong multiplex version: ' + r.headers.get('Multiplex-Version') + ', expected 0.0.1')
@@ -937,12 +937,10 @@ async function multiplex_fetch(url, params) {
937
937
  stream_error = e
938
938
  bytes_available()
939
939
  try {
940
- var r = await braid_fetch(`${origin}${params.headers.get('multiplexer')}`, {
940
+ var r = await braid_fetch(!using_multiplex_header ? `${origin}${params.headers.get('multiplexer')}` : `${origin}/.well-known/multiplex${params.headers.get('multiplexer')}`, {
941
941
  ...!using_multiplex_header && {method: 'MULTIPLEX'},
942
- headers: {
943
- ...using_multiplex_header && {Multiplex: true},
944
- 'Multiplex-Version': '0.0.1'
945
- }, retry: true})
942
+ headers: { 'Multiplex-Version': '0.0.1' }, retry: true
943
+ })
946
944
 
947
945
  if (!r.ok) throw new Error('status not ok: ' + r.status)
948
946
  if (r.headers.get('Multiplex-Version') !== '0.0.1') throw new Error('wrong multiplex version: ' + r.headers.get('Multiplex-Version') + ', expected 0.0.1')
@@ -244,11 +244,11 @@ function braidify (req, res, next) {
244
244
 
245
245
  // Multiplexer stuff
246
246
  if (braidify.use_multiplexing &&
247
- (req.method === 'MULTIPLEX' || req.headers.multiplex) &&
247
+ (req.method === 'MULTIPLEX' || req.url.startsWith('/.well-known/multiplex/')) &&
248
248
  req.headers['multiplex-version'] === '0.0.1') {
249
249
 
250
250
  // parse the multiplexer id and stream id from the url
251
- var [multiplexer, stream] = req.url.slice(1).split('/')
251
+ var [multiplexer, stream] = req.url.split('/').slice(req.method === 'MULTIPLEX' ? 1 : 3)
252
252
 
253
253
  // if there's just a multiplexer, then we're creating a multiplexer..
254
254
  if (!stream) {
@@ -267,6 +267,7 @@ function braidify (req, res, next) {
267
267
  // so people can send multiplexed data to it
268
268
  res.writeHead(200, {
269
269
  'Multiplex-Version': '0.0.1',
270
+ 'Incremental': '?1',
270
271
  'Cache-Control': 'no-cache',
271
272
  'X-Accel-Buffering': 'no',
272
273
  ...req.httpVersion !== '2.0' && {'Connection': 'keep-alive'}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "braid-http",
3
- "version": "1.3.30",
3
+ "version": "1.3.32",
4
4
  "description": "An implementation of Braid-HTTP for Node.js and Browsers",
5
5
  "scripts": {
6
6
  "test": "node test/server.js"