Skip to content

Commit

Permalink
style
Browse files Browse the repository at this point in the history
  • Loading branch information
feross committed Apr 24, 2018
1 parent 6c0f950 commit 44a7e43
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,11 @@ function simpleGet (opts, cb) {
if (opts.method) opts.method = opts.method.toUpperCase()

var body
if (opts.json) opts.headers.accept = 'application/json'
if (opts.form) opts.headers['content-type'] = 'application/x-www-form-urlencoded'
if (opts.body) {
body = opts.json && !isStream(opts.body) ? JSON.stringify(opts.body) : opts.body
} else if (opts.form) {
body = typeof opts.form === 'string' ? opts.form : querystring.stringify(opts.form)
opts.headers['content-type'] = 'application/x-www-form-urlencoded'
}
delete opts.body; delete opts.form

Expand All @@ -39,6 +38,7 @@ function simpleGet (opts, cb) {
return h.toLowerCase() === 'accept-encoding'
})
if (!customAcceptEncoding) opts.headers['accept-encoding'] = 'gzip, deflate'
if (opts.json) opts.headers.accept = 'application/json'

var protocol = opts.protocol === 'https:' ? https : http // Support http/https urls
var req = protocol.request(opts, function (res) {
Expand Down

0 comments on commit 44a7e43

Please sign in to comment.