MugunthKumar/MKNetworkKit — Issue #48: JSON Encoding yields application/x-www-form-urlencoded Content-Type
Author: bounca
Created: 2012-02-07 11:03:56+00:00
State: open

Hello,

When I set the operation.postDataEncoding to MKNKPostDataEncodingTypeJSON I would expect the Content-Type header to be text/plain instead it is application/x-www-form-urlencoded. This is a problem for server scripts looking into the raw data of the request body.

The problem is that the setting of the Content-Type happens in the init method of the operation, so before we get a chance to set the encoding type of the operation, hence it always defaults to the same setting: application/x-www-form-urlencoded.

Workaround : I extended the init method to take the encoding as a parameter which allows me to set it before the Content-Type is set.

Regards,
A.