mirror of https://github.com/vitalif/phantomjs
Make sure POST works.
With Qt 4.8, POST request with an empty content type will make the content type set to "application/octet-stream". Somehow this breaks POST. The fix is to set the content type to "application/x-www-form-urlencoded", like the case with Qt 4.7. Based on the suggestion by Leo Franchi. http://code.google.com/p/phantomjs/issues/detail?id=3371.4
parent
b31a43559f
commit
5322ee9681
|
@ -99,12 +99,22 @@ void NetworkAccessManager::setPassword(const QString &password)
|
|||
}
|
||||
|
||||
// protected:
|
||||
QNetworkReply *NetworkAccessManager::createRequest(Operation op, const QNetworkRequest & req, QIODevice * outgoingData)
|
||||
QNetworkReply *NetworkAccessManager::createRequest(Operation op, const QNetworkRequest & request, QIODevice * outgoingData)
|
||||
{
|
||||
QNetworkRequest req(request);
|
||||
|
||||
// Get the URL string before calling the superclass. Seems to work around
|
||||
// segfaults in Qt 4.8: https://gist.github.com/1430393
|
||||
QByteArray url = req.url().toEncoded();
|
||||
|
||||
// http://code.google.com/p/phantomjs/issues/detail?id=337
|
||||
if (op == QNetworkAccessManager::PostOperation) {
|
||||
QString contentType = req.header(QNetworkRequest::ContentTypeHeader).toString();
|
||||
if (contentType.isEmpty()) {
|
||||
req.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded");
|
||||
}
|
||||
}
|
||||
|
||||
// Pass duty to the superclass - Nothing special to do here (yet?)
|
||||
QNetworkReply *reply = QNetworkAccessManager::createRequest(op, req, outgoingData);
|
||||
if(m_ignoreSslErrors) {
|
||||
|
|
Loading…
Reference in New Issue