diff options
author | Shane Kearns <ext-shane.2.kearns@nokia.com> | 2012-06-13 17:27:31 +0100 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-06-21 00:58:05 +0200 |
commit | 4f578d15fe2ef176f0533c7ff4aea99b17636f85 (patch) | |
tree | 3d38f920d8e0805066ad6dcd4f6a262c79fc02a1 /src/network/access/qhttpnetworkrequest.cpp | |
parent | 3401e91be078b54c8a385757c42da437c24bfc90 (diff) |
Change default Content-Type for http POST to match 4.7.4
Qt 4.7.3 sent no Content-Type header by default.
This was fixed independently on 4.8.0 and 4.7.4 branches, with
different defaults.
Since this is often used for web service logins, the 4.7.4
default of x-www-form-urlencoded seems more likely to work.
The warning message is left in place, since not specifying the
content type is still an application bug.
Task-number: QTBUG-23350
Change-Id: I30bf50fd216ee9894d0168e904cea1ed4251ec68
Reviewed-by: Martin Petersson <Martin.Petersson@nokia.com>
Diffstat (limited to 'src/network/access/qhttpnetworkrequest.cpp')
-rw-r--r-- | src/network/access/qhttpnetworkrequest.cpp | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/network/access/qhttpnetworkrequest.cpp b/src/network/access/qhttpnetworkrequest.cpp index 1325f105cf..cd6acc82cd 100644 --- a/src/network/access/qhttpnetworkrequest.cpp +++ b/src/network/access/qhttpnetworkrequest.cpp @@ -158,8 +158,11 @@ QByteArray QHttpNetworkRequestPrivate::header(const QHttpNetworkRequest &request if (request.d->operation == QHttpNetworkRequest::Post) { // add content type, if not set in the request if (request.headerField("content-type").isEmpty()) { - qWarning("content-type missing in HTTP POST, defaulting to application/octet-stream"); - ba += "Content-Type: application/octet-stream\r\n"; + //Content-Type is mandatory. We can't say anything about the encoding, but x-www-form-urlencoded is the most likely to work. + //This warning indicates a bug in application code not setting a required header. + //Note that if using QHttpMultipart, the content-type is set in QNetworkAccessManagerPrivate::prepareMultipart already + qWarning("content-type missing in HTTP POST, defaulting to application/x-www-form-urlencoded. Use QNetworkRequest::setHeader() to fix this problem."); + ba += "Content-Type: application/x-www-form-urlencoded\r\n"; } if (!request.d->uploadByteDevice && request.d->url.hasQuery()) { QByteArray query = request.d->url.query(QUrl::FullyEncoded).toLatin1(); |