glynnbird commented on code in PR #314:
URL: https://github.com/apache/couchdb-nano/pull/314#discussion_r2333533325
##########
lib/nano.js:
##########
@@ -251,128 +238,119 @@ module.exports = exports = function dbScope (cfg) {
log({ err: 'couch', body: message, headers: responseHeaders })
- stream.emit('error', error)
+ setTimeout(() => {
+ stream.emit('error', error)
+ }, 10)
}
- function relax (opts, callback) {
+ function relax (opts) {
if (typeof opts === 'function') {
- callback = opts
opts = { path: '' }
}
-
if (typeof opts === 'string') {
opts = { path: opts }
}
-
if (!opts) {
opts = { path: '' }
- callback = null
}
- const qs = Object.assign({}, opts.qs)
+ // the building blocks of the request
+ let body, uri
+ // construct headers object to be passed in the request
const headers = {
- 'content-type': 'application/json',
+ // 'content-type': 'application/json',
Review Comment:
fixed in d8b5d67c2713eda6b0dfcb7b6c0fc96f5fff167f
##########
lib/nano.js:
##########
@@ -251,128 +238,119 @@ module.exports = exports = function dbScope (cfg) {
log({ err: 'couch', body: message, headers: responseHeaders })
- stream.emit('error', error)
+ setTimeout(() => {
+ stream.emit('error', error)
+ }, 10)
}
- function relax (opts, callback) {
+ function relax (opts) {
if (typeof opts === 'function') {
- callback = opts
opts = { path: '' }
}
-
if (typeof opts === 'string') {
opts = { path: opts }
}
-
if (!opts) {
opts = { path: '' }
- callback = null
}
- const qs = Object.assign({}, opts.qs)
+ // the building blocks of the request
+ let body, uri
+ // construct headers object to be passed in the request
const headers = {
- 'content-type': 'application/json',
+ // 'content-type': 'application/json',
accept: 'application/json',
'user-agent': `${pkg.name}/${pkg.version} (Node.js ${process.version})`,
'Accept-Encoding': 'deflate, gzip'
}
+ Object.assign(headers, cfg.headers ? cfg.headers : {})
+ if (!headers['content-type']) {
+ headers['content-type'] = 'application/json'
+ }
- const req = Object.assign({
- method: (opts.method || 'GET'),
- headers,
- uri: cfg.url
- }, {
- ...cfg.requestDefaults,
- headers: Object.assign(headers, cfg.requestDefaults &&
cfg.requestDefaults.headers ? cfg.requestDefaults.headers : {})
- })
+ // prevent bugs where people set encoding when piping
+ if (opts.encoding !== undefined) {
+ // req.encoding = opts.encoding
Review Comment:
Fixed in d8b5d67c2713eda6b0dfcb7b6c0fc96f5fff167f
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]