braid-text 0.2.90 → 0.2.92
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/index.js +24 -2
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -52,6 +52,26 @@ function create_braid_text() {
|
|
|
52
52
|
// make a=local and b=remote (swap if not)
|
|
53
53
|
if (a instanceof URL) { let swap = a; a = b; b = swap }
|
|
54
54
|
|
|
55
|
+
// Extract content type for proper Accept (GET) vs Content-Type (PUT) usage
|
|
56
|
+
var content_type
|
|
57
|
+
var get_headers = {}
|
|
58
|
+
var put_headers = {}
|
|
59
|
+
if (options.headers) {
|
|
60
|
+
for (var [k, v] of Object.entries(options.headers)) {
|
|
61
|
+
var lk = k.toLowerCase()
|
|
62
|
+
if (lk === 'accept' || lk === 'content-type') {
|
|
63
|
+
content_type = v
|
|
64
|
+
} else {
|
|
65
|
+
get_headers[k] = v
|
|
66
|
+
put_headers[k] = v
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
if (content_type) {
|
|
71
|
+
get_headers['Accept'] = content_type
|
|
72
|
+
put_headers['Content-Type'] = content_type
|
|
73
|
+
}
|
|
74
|
+
|
|
55
75
|
var resource = (typeof a == 'string') ? await get_resource(a) : a
|
|
56
76
|
|
|
57
77
|
function extend_frontier(frontier, version, parents) {
|
|
@@ -124,7 +144,8 @@ function create_braid_text() {
|
|
|
124
144
|
var r = await braid_fetch(b.href, {
|
|
125
145
|
signal: ac.signal,
|
|
126
146
|
method: "HEAD",
|
|
127
|
-
version
|
|
147
|
+
version,
|
|
148
|
+
headers: get_headers
|
|
128
149
|
})
|
|
129
150
|
if (!r.ok && r.status !== 309 && r.status !== 500)
|
|
130
151
|
throw new Error(`unexpected HEAD status: ${r.status}`)
|
|
@@ -177,6 +198,7 @@ function create_braid_text() {
|
|
|
177
198
|
update.signal = ac.signal
|
|
178
199
|
update.dont_retry = true
|
|
179
200
|
if (options.peer) update.peer = options.peer
|
|
201
|
+
update.headers = put_headers
|
|
180
202
|
var x = await braid_text.put(b, update)
|
|
181
203
|
if (x.ok) {
|
|
182
204
|
local_first_put()
|
|
@@ -260,7 +282,7 @@ function create_braid_text() {
|
|
|
260
282
|
var b_ops = {
|
|
261
283
|
signal: ac.signal,
|
|
262
284
|
dont_retry: true,
|
|
263
|
-
headers: { 'Merge-Type': 'dt', 'accept-encoding': 'updates(dt)' },
|
|
285
|
+
headers: { ...get_headers, 'Merge-Type': 'dt', 'accept-encoding': 'updates(dt)' },
|
|
264
286
|
parents: resource.meta.fork_point,
|
|
265
287
|
peer: options.peer,
|
|
266
288
|
heartbeats: 120,
|