braid-http 0.3.6 → 0.3.8
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-server.js +5 -1
- package/package.json +1 -1
package/braid-http-server.js
CHANGED
|
@@ -332,6 +332,10 @@ function send_update(res, data, url, peer) {
|
|
|
332
332
|
for (var [header, value] of Object.entries(data)) {
|
|
333
333
|
header = header.toLowerCase()
|
|
334
334
|
|
|
335
|
+
// A header set to undefined acts like it wasn't set
|
|
336
|
+
if (value === undefined)
|
|
337
|
+
continue
|
|
338
|
+
|
|
335
339
|
// Version and Parents get output in the Structured Headers format,
|
|
336
340
|
// so we convert `value` from array to comma-separated strings.
|
|
337
341
|
if (header === 'version') {
|
|
@@ -351,7 +355,7 @@ function send_update(res, data, url, peer) {
|
|
|
351
355
|
|
|
352
356
|
// Write the patches or body
|
|
353
357
|
if (typeof body === 'string') {
|
|
354
|
-
set_header('Content-Length', body.length)
|
|
358
|
+
set_header('Content-Length', (new TextEncoder().encode(body)).length)
|
|
355
359
|
write_body(body)
|
|
356
360
|
} else
|
|
357
361
|
res.write(generate_patches(res, patches))
|