Closed tiagolpadua closed 9 years ago
when header 'content-type' is specified as 3rd argument to post(url, body, options) then the current implementation will over ride and default it to 'application/json'
So the below wont work.
var frisby=require('frisby');
frisby.create('test')
.post('http://httpbin.org/post',
{
"input": "data",
"url": "http://httpbin.org/get"
},
{
json:true,
headers : {'content-type':'user-specific'}
//when specified here, current implementation will over ride
// and default it to 'application/json'
}
)
.inspectRequest()
.toss();
Workaround
var frisby=require('frisby');
frisby.create('test')
.post('http://httpbin.org/post',
{
"input": "data",
"url": "http://httpbin.org/get"
},
{
json:true
}
)
.addHeader('content-type', 'user-specific') //this will work.
.inspectRequest()
.toss();
Hope that helps..
~ Sasi
@vlucas
created PR #266. build passed https://travis-ci.org/vlucas/frisby/builds/81152914
please have a look and merge.
Thanks, Sasi
@sasikanthnimmagadda, thanks a lot for the fix & PR.
@tiagolpadua, fix is on master, please reopen if if doesn't fix the issue.
when we set json:true it overrides the content-type to application/json, in my case I need it to be application/json;charset=UTF-8
For example: frisby.create("POST client") .post( URL, { "name" : "Foo" } , {json: true, headers : {"content-type": "application/json;charset=UTF-8"}}) .expectStatus(201) .toss();
content-type will be overrided to application/json