braid-http 1.3.31 → 1.3.33
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 -10
- package/braid-http-server.js +2 -2
- package/package.json +1 -1
package/braid-http-client.js
CHANGED
|
@@ -848,20 +848,20 @@ async function multiplex_fetch(url, params) {
|
|
|
848
848
|
|
|
849
849
|
var streams = new Map()
|
|
850
850
|
var mux_error = null
|
|
851
|
-
var
|
|
851
|
+
var using_multiplex_well_known_url = false
|
|
852
852
|
|
|
853
853
|
var mux_promise = (async () => {
|
|
854
854
|
// attempt to establish a multiplexed connection
|
|
855
855
|
try {
|
|
856
|
-
if (params.
|
|
856
|
+
if (params.use_multiplex_well_known_url) throw 'skip to trying header'
|
|
857
857
|
var r = await braid_fetch(`${origin}/${multiplexer}`, {method: 'MULTIPLEX', headers: {'Multiplex-Version': '0.0.1'}, retry: true})
|
|
858
858
|
if (!r.ok || r.headers.get('Multiplex-Version') !== '0.0.1') throw 'bad'
|
|
859
859
|
} catch (e) {
|
|
860
860
|
// some servers don't like custom methods,
|
|
861
861
|
// so let's try with a custom header
|
|
862
862
|
try {
|
|
863
|
-
|
|
864
|
-
r = await braid_fetch(`${origin}/${multiplexer}`, {headers: {
|
|
863
|
+
using_multiplex_well_known_url = 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')}`, {
|
|
941
|
-
...!
|
|
942
|
-
headers: {
|
|
943
|
-
|
|
944
|
-
'Multiplex-Version': '0.0.1'
|
|
945
|
-
}, retry: true})
|
|
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'},
|
|
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')
|
package/braid-http-server.js
CHANGED
|
@@ -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.
|
|
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.
|
|
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) {
|