braid-http 0.1.9 → 0.1.11
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 -5
- package/braid-http-server.js +3 -4
- package/package.json +1 -1
package/braid-http-client.js
CHANGED
|
@@ -357,7 +357,7 @@ var subscription_parser = (cb) => ({
|
|
|
357
357
|
this.state.input += input
|
|
358
358
|
|
|
359
359
|
// Now loop through the input and parse until we hit a dead end
|
|
360
|
-
|
|
360
|
+
while (this.state.input.trim() !== '') {
|
|
361
361
|
this.state = parse_version (this.state)
|
|
362
362
|
|
|
363
363
|
// Maybe we parsed a version! That's cool!
|
|
@@ -366,7 +366,8 @@ var subscription_parser = (cb) => ({
|
|
|
366
366
|
version: this.state.version,
|
|
367
367
|
parents: this.state.parents,
|
|
368
368
|
body: this.state.body,
|
|
369
|
-
patches: this.state.patches
|
|
369
|
+
patches: this.state.patches,
|
|
370
|
+
headers: this.state.headers
|
|
370
371
|
})
|
|
371
372
|
|
|
372
373
|
// Reset the parser for the next version!
|
|
@@ -380,7 +381,8 @@ var subscription_parser = (cb) => ({
|
|
|
380
381
|
}
|
|
381
382
|
|
|
382
383
|
// We stop once we've run out of parseable input.
|
|
383
|
-
|
|
384
|
+
if (this.state.result == 'waiting') break
|
|
385
|
+
}
|
|
384
386
|
}
|
|
385
387
|
})
|
|
386
388
|
|
|
@@ -552,14 +554,14 @@ function parse_body (state) {
|
|
|
552
554
|
|
|
553
555
|
// Parse Patches
|
|
554
556
|
|
|
555
|
-
else if (state.headers.patches) {
|
|
557
|
+
else if (state.headers.patches != null) {
|
|
556
558
|
state.patches = state.patches || []
|
|
557
559
|
|
|
558
560
|
var last_patch = state.patches[state.patches.length-1]
|
|
559
561
|
|
|
560
562
|
// Parse patches until the final patch has its content filled
|
|
561
563
|
while (!(state.patches.length === state.headers.patches
|
|
562
|
-
&& 'content' in last_patch)) {
|
|
564
|
+
&& (state.patches.length === 0 || 'content' in last_patch))) {
|
|
563
565
|
|
|
564
566
|
state.input = state.input.trimStart()
|
|
565
567
|
|
package/braid-http-server.js
CHANGED
|
@@ -43,9 +43,8 @@ function generate_patches(res, patches) {
|
|
|
43
43
|
// Build up the string as a result
|
|
44
44
|
var result = ''
|
|
45
45
|
|
|
46
|
-
// Add `Patches: N` header
|
|
47
|
-
|
|
48
|
-
result += `Patches: ${patches.length}\r\n\r\n`
|
|
46
|
+
// Add `Patches: N` header
|
|
47
|
+
result += `Patches: ${patches.length}\r\n\r\n`
|
|
49
48
|
|
|
50
49
|
// Generate each patch
|
|
51
50
|
patches.forEach((patch, i) => {
|
|
@@ -238,7 +237,7 @@ function braidify (req, res, next) {
|
|
|
238
237
|
res.statusCode = 209
|
|
239
238
|
res.setHeader("subscribe", req.headers.subscribe)
|
|
240
239
|
res.setHeader('cache-control', 'no-cache, no-transform')
|
|
241
|
-
res.setHeader('transfer-encoding', '')
|
|
240
|
+
if (req.httpVersionMajor == 1) res.setHeader('transfer-encoding', '')
|
|
242
241
|
|
|
243
242
|
// Tell nginx not to buffer the subscription
|
|
244
243
|
res.setHeader('X-Accel-Buffering', 'no')
|