Do not force a content-type on POST request with no content
While a POST request with no body may be a pointless thing it does happen on many websites. Currently this causes QtNetwork to print a warning to the console and set an invalid content-type. This patch allows the content-type to be absent when content is. Task-number: QTBUG-42479 Change-Id: Ia84c89147d2469a9421b9694d062c797987b3194 Reviewed-by: Jocelyn Turcotte <jocelyn.turcotte@digia.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>bb10
parent
9990e47f04
commit
ccd4da392c
|
|
@ -151,7 +151,7 @@ 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()) {
|
||||
if (request.headerField("content-type").isEmpty() && ((request.d->uploadByteDevice && request.d->uploadByteDevice->size() > 0) || request.d->url.hasQuery())) {
|
||||
//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
|
||||
|
|
|
|||
Loading…
Reference in New Issue