Skip to content

Commit 83c57e1

Browse files
committed
style
1 parent 56c10dc commit 83c57e1

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

index.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,15 @@ function simpleGet (opts, cb) {
2323
if (opts.body) body = opts.json && !isStream(opts.body) ? JSON.stringify(opts.body) : opts.body
2424

2525
if (opts.json) opts.headers.accept = 'application/json'
26-
if (opts.json && body) opts.headers['content-type'] = 'application/json'
2726
if (opts.form) opts.headers['content-type'] = 'application/x-www-form-urlencoded'
28-
if (body && !isStream(body)) opts.headers['content-length'] = Buffer.byteLength(body)
2927
delete opts.body
3028
delete opts.form
3129

32-
if (body && !opts.method) opts.method = 'POST'
30+
if (body) {
31+
if (!opts.method) opts.method = 'POST'
32+
if (!isStream(body)) opts.headers['content-length'] = Buffer.byteLength(body)
33+
if (opts.json) opts.headers['content-type'] = 'application/json'
34+
}
3335

3436
// Request gzip/deflate
3537
var customAcceptEncoding = Object.keys(opts.headers).some(function (h) {

0 commit comments

Comments
 (0)