{"action":"created","issue":{"url":"https://api.github.com/repos/tulios/mappersmith/issues/32","repository_url":"https://api.github.com/repos/tulios/mappersmith","labels_url":"https://api.github.com/repos/tulios/mappersmith/issues/32/labels{/name}","comments_url":"https://api.github.com/repos/tulios/mappersmith/issues/32/comments","events_url":"https://api.github.com/repos/tulios/mappersmith/issues/32/events","html_url":"https://github.com/tulios/mappersmith/issues/32","id":182366467,"number":32,"title":"Duplicated content-type on vanilla gateway","user":{"login":"ericholiveira","id":1219172,"avatar_url":"https://avatars.githubusercontent.com/u/1219172?v=3","gravatar_id":"","url":"https://api.github.com/users/ericholiveira","html_url":"https://github.com/ericholiveira","followers_url":"https://api.github.com/users/ericholiveira/followers","following_url":"https://api.github.com/users/ericholiveira/following{/other_user}","gists_url":"https://api.github.com/users/ericholiveira/gists{/gist_id}","starred_url":"https://api.github.com/users/ericholiveira/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ericholiveira/subscriptions","organizations_url":"https://api.github.com/users/ericholiveira/orgs","repos_url":"https://api.github.com/users/ericholiveira/repos","events_url":"https://api.github.com/users/ericholiveira/events{/privacy}","received_events_url":"https://api.github.com/users/ericholiveira/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/tulios/mappersmith/labels/bug","name":"bug","color":"fc2929"}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2016-10-11T20:31:26Z","updated_at":"2016-10-12T11:38:41Z","closed_at":null,"body":"Im trying to do a POST to my server i configured my gateway as follows:\r\n\r\n```js \r\nimport Mappersmith from 'mappersmith';\r\nMappersmith.Env.USE_PROMISES = true;\r\nvar manifest = {\r\n host: 'http://localhost:3000',\r\n rules: [\r\n    {\r\n        values: {\r\n            gateway: {\r\n                headers: {\r\n                    'Content-Type': 'application/json'\r\n                }\r\n            }\r\n        }\r\n    }\r\n ],\r\n resources: {\r\n   CreateMixData: {\r\n     search: 'post:/search',\r\n     data: '/data'\r\n   }\r\n }\r\n};\r\nexport default Mappersmith.forge(manifest);```\r\n\r\nand im calling it as:\r\n```js\r\nAPI.CreateMixData.search({body:JSON.stringify({category:21})})\r\n```\r\nThe problem is, when i look at the call on chrome the content-type is \"Content-Type:application/json, application/json\" instead of \"Content-Type:application/json\" , and for this reason my server dont know how to parse it.\r\n\r\nThe problem happens on any verb except for GET , and i tracked down the problem to the following method on vanilla-gateway:\r\n\r\n```js\r\n_performRequest: function(method) {\r\n    var emulateHTTP = this.shouldEmulateHTTP(method);\r\n    var requestMethod = method;\r\n    var request = new XMLHttpRequest();\r\n\r\n    this._configureCallbacks(request);\r\n\r\n    if (emulateHTTP) {\r\n      this.body = this.body || {};\r\n      if (typeof this.body === 'object') this.body._method = method;\r\n      requestMethod = 'POST';\r\n    }\r\n\r\n    request.open(requestMethod, this.url, true);\r\n    if (emulateHTTP) request.setRequestHeader('X-HTTP-Method-Override', method);\r\n\r\n    this._setContentTypeHeader(request); // HERE THE CONTENT-TYPE IS SET\r\n    this._setUserDefinedHeaders(request); // HERE THE CONTENT-TYPE IS SET AGAIN (DUPLICATION)\r\n\r\n    var args = [];\r\n    if (this.body !== undefined) {\r\n      args.push(Utils.params(this.body));\r\n    }\r\n\r\n    request.send.apply(request, args);\r\n  },\r\n```\r\n\r\nThanks :)"},"comment":{"url":"https://api.github.com/repos/tulios/mappersmith/issues/comments/253190222","html_url":"https://github.com/tulios/mappersmith/issues/32#issuecomment-253190222","issue_url":"https://api.github.com/repos/tulios/mappersmith/issues/32","id":253190222,"user":{"login":"tulios","id":33231,"avatar_url":"https://avatars.githubusercontent.com/u/33231?v=3","gravatar_id":"","url":"https://api.github.com/users/tulios","html_url":"https://github.com/tulios","followers_url":"https://api.github.com/users/tulios/followers","following_url":"https://api.github.com/users/tulios/following{/other_user}","gists_url":"https://api.github.com/users/tulios/gists{/gist_id}","starred_url":"https://api.github.com/users/tulios/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tulios/subscriptions","organizations_url":"https://api.github.com/users/tulios/orgs","repos_url":"https://api.github.com/users/tulios/repos","events_url":"https://api.github.com/users/tulios/events{/privacy}","received_events_url":"https://api.github.com/users/tulios/received_events","type":"User","site_admin":false},"created_at":"2016-10-12T11:38:41Z","updated_at":"2016-10-12T11:38:41Z","body":"Hi @ericholiveira, thanks for the report. Can you try to set your header to `content-type`, all in lowercase?\r\n\r\nMaybe this (https://github.com/tulios/mappersmith/blob/master/src/gateway/vanilla-gateway.js#L124) is failing, this is definitely I'll take a look.\r\n\r\nThanks again. "}}
{"actor":{"display_login":"tulios"}}