[SOLVED] content-type missing in HTTP POST, defaulting to application/octet-stream
-
Just upgraded QT to latest version 4.8.1 libraries on Linux Ubuntu box 10.04 from version 4.7.X.
With the new version I am receiving an error from our server.
QT provides the following warning message:
@content-type missing in HTTP POST, defaulting to application/octet-stream@Our server wont accept the posted data. This ran fine with previous release.
I am aware that the default ContentTypeHeader type needs to be explicitly set under version 4.8.
However even when adding in the setHeader code shown below, I still receive the same error.Any ideas? Do I also need to set the contentHeader length field too or is this handled automatically.
@ QNetworkRequest request;
QUrl params;
params.addQueryItem("version","1.0");
params.addQueryItem("siteid","12345");
params.addQueryItem("recordid","12345");request.setUrl(serverUrl); request.setHeader(QNetworkRequest::ContentTypeHeader,QVariant("application/x-www-form-urlencoded")); //request.setHeader(QNetworkRequest::ContentLengthHeader,params.encodedQuery().length()); nam->post(QNetworkRequest(serverUrl),params.encodedQuery()); @
-
contentHeader length is set automatically.
Sure it wouldn't work. You set headers for request instance but don't use this instance in post request!?
This:
@nam->post(QNetworkRequest(serverUrl),params.encodedQuery());@
should look like this:
@nam->post(request,params.encodedQuery());@
-
Glad I could help you. Please add "[SOLVED]" to the left of the topic subject.