As discussed in the original issue, here is a quick fix, I hope it's what you had in mind.
this doesn't covering streaming.
Fix #296 - Only set Content-Type if body exists
Sorry for the rushed PR, this time it should be ok hopefully.
It works on streams, I'm just wondering if it's the behavior we should expect or if json should override content-type.
+1 to being able to set json: true but only have it set a content-type if there's a body.
I was about to send a pull request then saw this one. My approach was pretty similar: HenrikJoreteg@1421be7
The reason I noticed this at all is that the body parser in Connect 2.5 tries to parse the body as JSON any time it sees a content-type of application/json so it blows up even when doing a GET with the json: true flag set in request unless you also send JSON in the body, which is silly. Although it's weird and not semantic to send a body on a GET, apparently it's not technically invalid.
I'm not sure it's completely practical to for connect to try to parse empty bodies on GET requests. But arguably TJ's right that it's invalid to set a JSON content type when there's no body (senchalabs/connect#415 (comment)).
There's obviously other workarounds, in that I could configure request different depending on if there's a body or not. Or not use the connect body parser... but it's kinda nice to just be able to set defaults to json: true and be stupid and happy.
@mikeal Is it good now ?