braid-http 0.1.7 → 0.1.9

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.
@@ -66,8 +66,17 @@ ${patch.content}`
66
66
  function parse_patches (req, cb) {
67
67
  var num_patches = req.headers.patches
68
68
 
69
- // Parse a single patch from the request body
70
- if (num_patches === undefined) {
69
+ // Parse a request body as an "everything" patch
70
+ if (!num_patches && !req.headers['content-range']) {
71
+ var body = ''
72
+ req.on('data', chunk => {body += chunk.toString()})
73
+ req.on('end', () => {
74
+ cb([{unit: 'everything', range: '', content: body}])
75
+ })
76
+ }
77
+
78
+ // Parse a single patch, lacking Patches: N
79
+ else if (num_patches === undefined && req.headers['content-range']) {
71
80
 
72
81
  // We only support range patches right now, so there must be a
73
82
  // Content-Range header.
@@ -231,6 +240,9 @@ function braidify (req, res, next) {
231
240
  res.setHeader('cache-control', 'no-cache, no-transform')
232
241
  res.setHeader('transfer-encoding', '')
233
242
 
243
+ // Tell nginx not to buffer the subscription
244
+ res.setHeader('X-Accel-Buffering', 'no')
245
+
234
246
  var connected = true
235
247
  function disconnected (x) {
236
248
  if (!connected) return
@@ -285,8 +297,9 @@ function send_version(res, data, url, peer) {
285
297
  if (Array.isArray(patches))
286
298
  patches.forEach(p => assert(typeof p.content === 'string'))
287
299
  }
288
- assert(body || patches, 'Missing body or patches')
289
- assert(!(body && patches), 'Cannot send both body and patches')
300
+ var body_exists = body || body === ''
301
+ assert(body_exists || patches, 'Missing body or patches')
302
+ assert(!(body_exists && patches), 'Cannot send both body and patches')
290
303
 
291
304
  // Write the headers or virtual headers
292
305
  for (var [header, value] of Object.entries(data)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "braid-http",
3
- "version": "0.1.7",
3
+ "version": "0.1.9",
4
4
  "description": "An implementation of Braid-HTTP for Node.js and Browsers",
5
5
  "scripts": {
6
6
  "test": "node test/server.js"