braid-http 1.3.78 → 1.3.80
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 +4 -4
- package/package.json +1 -1
package/braid-http-server.js
CHANGED
|
@@ -597,7 +597,7 @@ function braidify (req, res, next) {
|
|
|
597
597
|
}
|
|
598
598
|
|
|
599
599
|
async function send_update(res, data, url, peer) {
|
|
600
|
-
var {version, parents, patches, patch, body, status} = data
|
|
600
|
+
var {version, parents, patches, patch, body, status, encoding} = data
|
|
601
601
|
|
|
602
602
|
if (status) {
|
|
603
603
|
assert(typeof status === 'number', 'sendUpdate: status must be a number')
|
|
@@ -613,7 +613,7 @@ async function send_update(res, data, url, peer) {
|
|
|
613
613
|
res.setHeader(key, val)
|
|
614
614
|
}
|
|
615
615
|
function write_body (body) {
|
|
616
|
-
if (res.isSubscription) res.write('\r\n')
|
|
616
|
+
if (res.isSubscription && !encoding) res.write('\r\n')
|
|
617
617
|
write_binary(res, body)
|
|
618
618
|
}
|
|
619
619
|
|
|
@@ -662,7 +662,7 @@ async function send_update(res, data, url, peer) {
|
|
|
662
662
|
status === 200 ? 'OK'
|
|
663
663
|
: 404 ? 'Not Found'
|
|
664
664
|
: 'Unknown'
|
|
665
|
-
if (res.isSubscription) res.write(`HTTP ${status} ${reason}\r\n`)
|
|
665
|
+
if (res.isSubscription && !encoding) res.write(`HTTP ${status} ${reason}\r\n`)
|
|
666
666
|
|
|
667
667
|
// Write the headers or virtual headers
|
|
668
668
|
for (var [header, value] of Object.entries(data)) {
|
|
@@ -698,7 +698,7 @@ async function send_update(res, data, url, peer) {
|
|
|
698
698
|
let binary = typeof body === 'string' ? new TextEncoder().encode(body) : body,
|
|
699
699
|
length = get_binary_length(binary)
|
|
700
700
|
assert(length !== undefined && length !== 'undefined')
|
|
701
|
-
set_header('Content-Length', length)
|
|
701
|
+
set_header(encoding ? 'Length' : 'Content-Length', length)
|
|
702
702
|
write_body(binary)
|
|
703
703
|
} else
|
|
704
704
|
write_patches(res, patches)
|