Just so this doesn't break people's code, you should leave the default content type of: application/x-www-form-urlencoded.
it seems like the contentTypeSet variable should be killed or leveraged. It looks like @csquared wanted to implement a way of setting content type, but didn't wrap it up. Nesting the code for writing the content type under a statement that says !contenttypeSet is kind of confusing.
Cool, useful addition. Thoughts: