MugunthKumar/MKNetworkKit — Issue #29: Should POST Content-Type application/x-www-form-urlencoded include charset?
Author: Llessur
Created: 2012-01-06 04:52:59+00:00
State: open

For method POST, MKNetworkOperation initStringWithUrlString sets the Content-Type header to "application/x-www-form-urlencoded; charset=utf-8." The server I am testing blows up with "HTTP 501 Not Implemented. Incorrect Type." If I modify that method to remove the charset parameter, it works fine.

I have not encountered this before so searched the net. I found a few discussions that charset should not be included in the Content-Type header for application/x-www-form-urlencoded. [Example](http://stackoverflow.com/questions/2418944/how-to-force-browser-to-set-charset-in-content-type-http-header) which includes "no browser has ever supplied a charset parameter with the application/x-www-form-urlencoded media type. What's more, the HTML spec which defines that type, does not propose a charset parameter, so the server can't reasonably expect to get one."

I can't vouch for the accuracy of this information, and am certainly not an http/html expert, but eliminating the charset solved my problem. The W3C XForms spec describes charset for each element of multipart/form-data, but not for application/x-www-form-urlencoded.
http://www.w3.org/TR/2003/REC-xforms-20031014/slice11.html#serialize-urlencode

Is this a special case, or should MKNetworkOperation initStringWithUrlString be revised to eliminate charset for Content-Type application/x-www-form-urlencoded?