braid-http 0.3.18 → 0.3.19

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.
@@ -229,8 +229,8 @@ async function braid_fetch (url, params = {}) {
229
229
 
230
230
  // Now we define the subscription function we just used:
231
231
  function start_subscription (cb, error) {
232
- if (!res.ok)
233
- throw new Error('Request returned not ok', res)
232
+ if (!res.ok) {
233
+ throw new Error('Request returned not ok status:', res.status)
234
234
 
235
235
  if (res.bodyUsed)
236
236
  // TODO: check if this needs a return
@@ -236,10 +236,22 @@ function braidify (req, res, next) {
236
236
  res.statusCode = 209
237
237
  res.setHeader("subscribe", req.headers.subscribe)
238
238
  res.setHeader('cache-control', 'no-cache, no-transform')
239
- if (req.httpVersionMajor == 1) {
240
- // Explicitly disable transfer-encoding chunked for http 1
241
- res.setHeader('transfer-encoding', '')
242
- }
239
+
240
+
241
+ // Note: I used to explicitly disable transfer-encoding chunked
242
+ // here by setting the header to empty string. This is the only
243
+ // way I know to disable it in nodejs. We don't need chunked
244
+ // encoding in subscriptions, because chunked encoding is used to
245
+ // signal the end of a response, and subscriptions don't end. I
246
+ // disabled them to make responses cleaner. However, it turns out
247
+ // the Caddy proxy throws an error if it receives a response with
248
+ // transfer-encoding: set to the empty string. So I'm disabling
249
+ // it now.
250
+
251
+ // if (req.httpVersionMajor == 1) {
252
+ // // Explicitly disable transfer-encoding chunked for http 1
253
+ // res.setHeader('transfer-encoding', '')
254
+ // }
243
255
 
244
256
  // Tell nginx not to buffer the subscription
245
257
  res.setHeader('X-Accel-Buffering', 'no')
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "braid-http",
3
- "version": "0.3.18",
3
+ "version": "0.3.19",
4
4
  "description": "An implementation of Braid-HTTP for Node.js and Browsers",
5
5
  "scripts": {
6
6
  "test": "node test/server.js"