braid-http 1.3.33 → 1.3.35

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.
@@ -848,7 +848,6 @@ async function multiplex_fetch(url, params) {
848
848
 
849
849
  var streams = new Map()
850
850
  var mux_error = null
851
- var using_multiplex_well_known_url = false
852
851
 
853
852
  var mux_promise = (async () => {
854
853
  // attempt to establish a multiplexed connection
@@ -860,7 +859,6 @@ async function multiplex_fetch(url, params) {
860
859
  // some servers don't like custom methods,
861
860
  // so let's try with a custom header
862
861
  try {
863
- using_multiplex_well_known_url = true
864
862
  r = await braid_fetch(`${origin}/.well-known/multiplex/${multiplexer}`, {headers: {'Multiplex-Version': '0.0.1'}, retry: true})
865
863
 
866
864
  if (!r.ok) throw new Error('status not ok: ' + r.status)
@@ -937,8 +935,8 @@ async function multiplex_fetch(url, params) {
937
935
  stream_error = e
938
936
  bytes_available()
939
937
  try {
940
- var r = await braid_fetch(!using_multiplex_well_known_url ? `${origin}${params.headers.get('multiplexer')}` : `${origin}/.well-known/multiplex${params.headers.get('multiplexer')}`, {
941
- ...!using_multiplex_well_known_url && {method: 'MULTIPLEX'},
938
+ var r = await braid_fetch(`${origin}/.well-known/multiplex${params.headers.get('multiplexer')}`, {
939
+ method: 'DELETE',
942
940
  headers: { 'Multiplex-Version': '0.0.1' }, retry: true
943
941
  })
944
942
 
@@ -313,20 +313,12 @@ function braidify (req, res, next) {
313
313
  // parse the multiplexer id and stream id from the url
314
314
  var [multiplexer, stream] = req.headers.multiplexer.slice(1).split('/')
315
315
 
316
- var end_things = (msg) => {
317
- // 422 = Unprocessable Entity (but good syntax!)
318
- res.writeHead(422, {Multiplexer: req.headers.multiplexer})
319
- res.end(msg)
320
- }
321
-
322
316
  // find the multiplexer object (contains a response object)
323
317
  var m = braidify.multiplexers?.get(multiplexer)
324
- if (!m) return end_things(`multiplexer ${multiplexer} does not exist`)
325
-
326
- // special case: check that this stream isn't already aborted
327
- if (m.streams.get(stream) === 'abort') {
328
- m.streams.delete(stream)
329
- return end_things(`multiplexer stream ${req.headers.multiplexer} already aborted`)
318
+ if (!m) {
319
+ // 422 = Unprocessable Entity (but good syntax!)
320
+ res.writeHead(422, {Multiplexer: `/${multiplexer}`})
321
+ res.end(`multiplexer ${multiplexer} does not exist`)
330
322
  }
331
323
 
332
324
  // let the requester know we've multiplexed their response
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "braid-http",
3
- "version": "1.3.33",
3
+ "version": "1.3.35",
4
4
  "description": "An implementation of Braid-HTTP for Node.js and Browsers",
5
5
  "scripts": {
6
6
  "test": "node test/server.js"