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();