braid-http 0.3.3 → 0.3.4
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 +7 -6
- package/package.json +1 -1
package/braid-http-client.js
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
var peer = Math.random().toString(36).substr(2)
|
|
1
|
+
// var peer = Math.random().toString(36).substr(2)
|
|
2
2
|
|
|
3
3
|
// ***************************
|
|
4
4
|
// http
|
|
5
5
|
// ***************************
|
|
6
6
|
|
|
7
7
|
function braidify_http (http) {
|
|
8
|
-
// Todo: Wrap .put to add `peer` header
|
|
9
8
|
http.normal_get = http.get
|
|
10
9
|
http.get = function braid_req (arg1, arg2, arg3) {
|
|
11
10
|
var url, options, cb
|
|
@@ -45,8 +44,8 @@ function braidify_http (http) {
|
|
|
45
44
|
if (options.subscribe)
|
|
46
45
|
options.headers.subscribe = 'true'
|
|
47
46
|
|
|
48
|
-
// Always add the `peer` header
|
|
49
|
-
options.headers.peer = options.headers.peer || peer
|
|
47
|
+
// // Always add the `peer` header
|
|
48
|
+
// options.headers.peer = options.headers.peer || peer
|
|
50
49
|
|
|
51
50
|
// Wrap the callback to provide our new .on('update', ...) feature
|
|
52
51
|
// on nodejs servers
|
|
@@ -158,8 +157,8 @@ async function braid_fetch (url, params = {}) {
|
|
|
158
157
|
console.assert(Array.isArray(params.parents),
|
|
159
158
|
'fetch(): `parents` must be an array')
|
|
160
159
|
|
|
161
|
-
// Always set the peer
|
|
162
|
-
params.headers.set('peer', peer)
|
|
160
|
+
// // Always set the peer
|
|
161
|
+
// params.headers.set('peer', peer)
|
|
163
162
|
|
|
164
163
|
// We provide some shortcuts for Braid params
|
|
165
164
|
if (params.version)
|
|
@@ -168,6 +167,8 @@ async function braid_fetch (url, params = {}) {
|
|
|
168
167
|
params.headers.set('parents', params.parents.map(JSON.stringify).join(', '))
|
|
169
168
|
if (params.subscribe)
|
|
170
169
|
params.headers.set('subscribe', 'true')
|
|
170
|
+
if (params.peer)
|
|
171
|
+
params.header.set('peer', params.peer)
|
|
171
172
|
|
|
172
173
|
// Prevent browsers from going to disk cache
|
|
173
174
|
params.cache = 'no-cache'
|