Skip to content
This repository has been archived by the owner on Apr 3, 2024. It is now read-only.

Commit

Permalink
Merge 5b3b6f6 into 29c9f2f
Browse files Browse the repository at this point in the history
  • Loading branch information
bcoe committed Jul 3, 2017
2 parents 29c9f2f + 5b3b6f6 commit aab7c61
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,17 +47,19 @@ function CouchUrlRewriteProxy (opts) {
rewrite = false
}

var r = request(payload, function (err, response, body) {
var status = 500
if (response && response.statusCode) status = response.statusCode
if (err) res.status(status).send(body)
else if (rewrite) {
rewriteUrls(res, status, body, opts.frontDoorHost)
}
})

// only pipe if we're not performing rewrite.
if (!rewrite) r.pipe(res)
// see: https://github.com/request/request/issues/2478
if (!rewrite) {
request(payload).pipe(res)
} else {
request(payload, function (err, response, body) {
var status = 500
if (response && response.statusCode) status = response.statusCode
if (err) res.status(status).send(body)
else if (rewrite) {
rewriteUrls(res, status, body, opts.frontDoorHost)
}
})
}
}

['put', 'post', 'delete', 'get', 'head'].forEach(function (method) {
Expand Down

0 comments on commit aab7c61

Please sign in to comment.