Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possible `content-type` header duplication #188

Closed
delaguilaluis opened this issue Aug 9, 2017 · 1 comment
Closed

Possible `content-type` header duplication #188

delaguilaluis opened this issue Aug 9, 2017 · 1 comment
Assignees
Labels
bug
Milestone

Comments

@delaguilaluis
Copy link
Contributor

@delaguilaluis delaguilaluis commented Aug 9, 2017

If a wreck request has an existing options.payload, a content-type header with the value "application/json" is added to the headers even if a Content-Type header (that is not lower cased) exists under options.headers.

Example snippet:

'use strict'

const wreck = require('wreck')
const http = require('http')
const assert = require('assert')

const server = http.createServer(requestListener)

const options = {
  payload: [{ op: 'remove', path: '/test' }],
  headers: {
    'Content-Type': 'application/json-patch+json'
  }
}

server.listen(0, () => {
  wreck.request('post', 'http://localhost:' + server.address().port, options, (err, res) => {
    if (err) throw err
    server.close()
  })
})

function requestListener (req, res) {
  assert.equal(req.headers['content-type'], 'application/json-patch+json')
  res.writeHead(200, { 'Content-Type': 'text/plain' })
  req.pipe(res)
}

// => AssertionError [ERR_ASSERTION]: 'application/json' == 'application/json-patch+json'
@geek geek added the bug label Aug 9, 2017
@geek geek added this to the 12.2.3 milestone Aug 10, 2017
@geek geek self-assigned this Aug 10, 2017
@geek

This comment has been minimized.

Copy link
Member

@geek geek commented Aug 10, 2017

Fixed by #189

@geek geek closed this Aug 10, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.