summaryrefslogtreecommitdiffstats
path: root/src/network
diff options
context:
space:
mode:
Diffstat (limited to 'src/network')
-rw-r--r--src/network/access/qhttpnetworkconnectionchannel.cpp17
-rw-r--r--src/network/access/qhttpnetworkconnectionchannel_p.h1
-rw-r--r--src/network/access/qnetworkaccessmanager.cpp3
-rw-r--r--src/network/access/qnetworkreply.cpp3
-rw-r--r--src/network/access/qnetworkrequest.cpp32
-rw-r--r--src/network/access/qnetworkrequest.h3
-rw-r--r--src/network/access/qnetworkrequest_p.h2
-rw-r--r--src/network/kernel/qhostinfo_unix.cpp40
-rw-r--r--src/network/kernel/qhostinfo_win.cpp40
-rw-r--r--src/network/kernel/qnetworkproxy_win.cpp7
-rw-r--r--src/network/ssl/qsslsocket.cpp7
11 files changed, 101 insertions, 54 deletions
diff --git a/src/network/access/qhttpnetworkconnectionchannel.cpp b/src/network/access/qhttpnetworkconnectionchannel.cpp
index beab9af..6962ab3 100644
--- a/src/network/access/qhttpnetworkconnectionchannel.cpp
+++ b/src/network/access/qhttpnetworkconnectionchannel.cpp
@@ -69,6 +69,11 @@ void QHttpNetworkConnectionChannel::init()
socket = new QTcpSocket;
#endif
+ // limit the socket read buffer size. we will read everything into
+ // the QHttpNetworkReply anyway, so let's grow only that and not
+ // here and there.
+ socket->setReadBufferSize(64*1024);
+
QObject::connect(socket, SIGNAL(bytesWritten(qint64)),
this, SLOT(_q_bytesWritten(qint64)),
Qt::DirectConnection);
@@ -100,6 +105,9 @@ void QHttpNetworkConnectionChannel::init()
QObject::connect(sslSocket, SIGNAL(sslErrors(const QList<QSslError>&)),
this, SLOT(_q_sslErrors(const QList<QSslError>&)),
Qt::DirectConnection);
+ QObject::connect(sslSocket, SIGNAL(encryptedBytesWritten(qint64)),
+ this, SLOT(_q_encryptedBytesWritten(qint64)),
+ Qt::DirectConnection);
}
#endif
}
@@ -876,6 +884,15 @@ void QHttpNetworkConnectionChannel::_q_sslErrors(const QList<QSslError> &errors)
//QNetworkReply::NetworkError errorCode = QNetworkReply::ProtocolFailure;
emit connection->sslErrors(errors);
}
+
+void QHttpNetworkConnectionChannel::_q_encryptedBytesWritten(qint64 bytes)
+{
+ Q_UNUSED(bytes);
+ // bytes have been written to the socket. write even more of them :)
+ if (isSocketWriting())
+ sendRequest();
+ // otherwise we do nothing
+}
#endif
QT_END_NAMESPACE
diff --git a/src/network/access/qhttpnetworkconnectionchannel_p.h b/src/network/access/qhttpnetworkconnectionchannel_p.h
index 1d1153e..127a431 100644
--- a/src/network/access/qhttpnetworkconnectionchannel_p.h
+++ b/src/network/access/qhttpnetworkconnectionchannel_p.h
@@ -180,6 +180,7 @@ public:
#ifndef QT_NO_OPENSSL
void _q_encrypted(); // start sending request (https)
void _q_sslErrors(const QList<QSslError> &errors); // ssl errors from the socket
+ void _q_encryptedBytesWritten(qint64 bytes); // proceed sending
#endif
};
diff --git a/src/network/access/qnetworkaccessmanager.cpp b/src/network/access/qnetworkaccessmanager.cpp
index 439d564..b1160aa 100644
--- a/src/network/access/qnetworkaccessmanager.cpp
+++ b/src/network/access/qnetworkaccessmanager.cpp
@@ -95,9 +95,10 @@ static void ensureInitialized()
/*!
\class QNetworkAccessManager
\brief The QNetworkAccessManager class allows the application to
- post network requests and receive replies
+ send network requests and receive replies
\since 4.4
+ \ingroup network
\inmodule QtNetwork
\reentrant
diff --git a/src/network/access/qnetworkreply.cpp b/src/network/access/qnetworkreply.cpp
index 4eb53bf..9ab4057 100644
--- a/src/network/access/qnetworkreply.cpp
+++ b/src/network/access/qnetworkreply.cpp
@@ -59,9 +59,10 @@ QNetworkReplyPrivate::QNetworkReplyPrivate()
\class QNetworkReply
\since 4.4
\brief The QNetworkReply class contains the data and headers for a request
- posted with QNetworkAccessManager
+ sent with QNetworkAccessManager
\reentrant
+ \ingroup network
\inmodule QtNetwork
The QNetworkReply class contains the data and meta data related to
diff --git a/src/network/access/qnetworkrequest.cpp b/src/network/access/qnetworkrequest.cpp
index cde9858..86195c6 100644
--- a/src/network/access/qnetworkrequest.cpp
+++ b/src/network/access/qnetworkrequest.cpp
@@ -52,7 +52,7 @@ QT_BEGIN_NAMESPACE
/*!
\class QNetworkRequest
- \brief The QNetworkRequest class holds one request to be sent with the Network Access API.
+ \brief The QNetworkRequest class holds a request to be sent with QNetworkAccessManager.
\since 4.4
\ingroup network
@@ -481,6 +481,36 @@ void QNetworkRequest::setSslConfiguration(const QSslConfiguration &config)
}
#endif
+/*!
+ \since 4.6
+
+ Allows setting a reference to the \a object initiating
+ the request.
+
+ For example QtWebKit sets the originating object to the
+ QWebFrame that initiated the request.
+
+ \sa originatingObject()
+*/
+void QNetworkRequest::setOriginatingObject(QObject *object)
+{
+ d->originatingObject = object;
+}
+
+/*!
+ \since 4.6
+
+ Returns a reference to the object that initiated this
+ network request; returns 0 if not set or the object has
+ been destroyed.
+
+ \sa setOriginatingObject()
+*/
+QObject *QNetworkRequest::originatingObject() const
+{
+ return d->originatingObject.data();
+}
+
static QByteArray headerName(QNetworkRequest::KnownHeaders header)
{
switch (header) {
diff --git a/src/network/access/qnetworkrequest.h b/src/network/access/qnetworkrequest.h
index 7b15237..62c6dda 100644
--- a/src/network/access/qnetworkrequest.h
+++ b/src/network/access/qnetworkrequest.h
@@ -120,6 +120,9 @@ public:
void setSslConfiguration(const QSslConfiguration &configuration);
#endif
+ void setOriginatingObject(QObject *object);
+ QObject *originatingObject() const;
+
private:
QSharedDataPointer<QNetworkRequestPrivate> d;
friend class QNetworkRequestPrivate;
diff --git a/src/network/access/qnetworkrequest_p.h b/src/network/access/qnetworkrequest_p.h
index 22b239f..9b3632f 100644
--- a/src/network/access/qnetworkrequest_p.h
+++ b/src/network/access/qnetworkrequest_p.h
@@ -58,6 +58,7 @@
#include "QtCore/qlist.h"
#include "QtCore/qhash.h"
#include "QtCore/qshareddata.h"
+#include "QtCore/qsharedpointer.h"
QT_BEGIN_NAMESPACE
@@ -73,6 +74,7 @@ public:
RawHeadersList rawHeaders;
CookedHeadersMap cookedHeaders;
AttributesMap attributes;
+ QWeakPointer<QObject> originatingObject;
RawHeadersList::ConstIterator findRawHeader(const QByteArray &key) const;
QList<QByteArray> rawHeadersKeys() const;
diff --git a/src/network/kernel/qhostinfo_unix.cpp b/src/network/kernel/qhostinfo_unix.cpp
index b4ac3d2..7e6e522 100644
--- a/src/network/kernel/qhostinfo_unix.cpp
+++ b/src/network/kernel/qhostinfo_unix.cpp
@@ -173,38 +173,28 @@ QHostInfo QHostInfoAgent::fromName(const QString &hostName)
#endif
char hbuf[NI_MAXHOST];
- if (!sa || getnameinfo(sa, saSize, hbuf, sizeof(hbuf), 0, 0, 0) != 0) {
- results.setError(QHostInfo::HostNotFound);
- results.setErrorString(tr("Host not found"));
- return results;
- }
- results.setHostName(QString::fromLatin1(hbuf));
+ if (sa && getnameinfo(sa, saSize, hbuf, sizeof(hbuf), 0, 0, 0) == 0)
+ results.setHostName(QString::fromLatin1(hbuf));
#else
in_addr_t inetaddr = qt_safe_inet_addr(hostName.toLatin1().constData());
struct hostent *ent = gethostbyaddr((const char *)&inetaddr, sizeof(inetaddr), AF_INET);
- if (!ent) {
- results.setError(QHostInfo::HostNotFound);
- results.setErrorString(tr("Host not found"));
- return results;
- }
- results.setHostName(QString::fromLatin1(ent->h_name));
+ if (ent)
+ results.setHostName(QString::fromLatin1(ent->h_name));
#endif
+
+ if (results.hostName().isEmpty())
+ results.setHostName(address.toString());
+ results.setAddresses(QList<QHostAddress>() << address);
+ return results;
}
// IDN support
- QByteArray aceHostname;
- if (results.hostName().isEmpty()) {
- // it's a hostname resolution
- aceHostname = QUrl::toAce(hostName);
- results.setHostName(hostName);
- if (aceHostname.isEmpty()) {
- results.setError(QHostInfo::HostNotFound);
- results.setErrorString(hostName.isEmpty() ? QObject::tr("No host name given") : QObject::tr("Invalid hostname"));
- return results;
- }
- } else {
- // it's an IP reverse resolution
- aceHostname = results.hostName().toLatin1();
+ QByteArray aceHostname = QUrl::toAce(hostName);
+ results.setHostName(hostName);
+ if (aceHostname.isEmpty()) {
+ results.setError(QHostInfo::HostNotFound);
+ results.setErrorString(hostName.isEmpty() ? QObject::tr("No host name given") : QObject::tr("Invalid hostname"));
+ return results;
}
#if !defined (QT_NO_GETADDRINFO)
diff --git a/src/network/kernel/qhostinfo_win.cpp b/src/network/kernel/qhostinfo_win.cpp
index d9d7234..720aaa5 100644
--- a/src/network/kernel/qhostinfo_win.cpp
+++ b/src/network/kernel/qhostinfo_win.cpp
@@ -160,38 +160,28 @@ QHostInfo QHostInfoAgent::fromName(const QString &hostName)
}
char hbuf[NI_MAXHOST];
- if (local_getnameinfo(sa, saSize, hbuf, sizeof(hbuf), 0, 0, 0) != 0) {
- results.setError(QHostInfo::HostNotFound);
- results.setErrorString(tr("Host not found"));
- return results;
- }
- results.setHostName(QString::fromLatin1(hbuf));
+ if (local_getnameinfo(sa, saSize, hbuf, sizeof(hbuf), 0, 0, 0) == 0)
+ results.setHostName(QString::fromLatin1(hbuf));
} else {
unsigned long addr = inet_addr(hostName.toLatin1().constData());
struct hostent *ent = gethostbyaddr((const char*)&addr, sizeof(addr), AF_INET);
- if (!ent) {
- results.setError(QHostInfo::HostNotFound);
- results.setErrorString(tr("Host not found"));
- return results;
- }
- results.setHostName(QString::fromLatin1(ent->h_name));
+ if (ent)
+ results.setHostName(QString::fromLatin1(ent->h_name));
}
+
+ if (results.hostName().isEmpty())
+ results.setHostName(address.toString());
+ results.setAddresses(QList<QHostAddress>() << address);
+ return results;
}
// IDN support
- QByteArray aceHostname;
- if (results.hostName().isEmpty()) {
- // it's a hostname resolution
- aceHostname = QUrl::toAce(hostName);
- results.setHostName(hostName);
- if (aceHostname.isEmpty()) {
- results.setError(QHostInfo::HostNotFound);
- results.setErrorString(hostName.isEmpty() ? tr("No host name given") : tr("Invalid hostname"));
- return results;
- }
- } else {
- // it's an IP reverse resolution
- aceHostname = results.hostName().toLatin1();
+ QByteArray aceHostname = QUrl::toAce(hostName);
+ results.setHostName(hostName);
+ if (aceHostname.isEmpty()) {
+ results.setError(QHostInfo::HostNotFound);
+ results.setErrorString(hostName.isEmpty() ? tr("No host name given") : tr("Invalid hostname"));
+ return results;
}
if (local_getaddrinfo && local_freeaddrinfo) {
diff --git a/src/network/kernel/qnetworkproxy_win.cpp b/src/network/kernel/qnetworkproxy_win.cpp
index c3b89ed..6f92424 100644
--- a/src/network/kernel/qnetworkproxy_win.cpp
+++ b/src/network/kernel/qnetworkproxy_win.cpp
@@ -399,7 +399,12 @@ QList<QNetworkProxy> QNetworkProxyFactory::systemProxyForQuery(const QNetworkPro
if (isBypassed(query.peerHostName(), sp->proxyBypass))
return sp->defaultResult;
- return parseServerList(query, sp->proxyServerList);
+ QList<QNetworkProxy> result = parseServerList(query, sp->proxyServerList);
+ // In some cases, this was empty. See SF task 00062670
+ if (result.isEmpty())
+ return sp->defaultResult;
+
+ return result;
}
QT_END_NAMESPACE
diff --git a/src/network/ssl/qsslsocket.cpp b/src/network/ssl/qsslsocket.cpp
index 0e9cb4f..a5732fb 100644
--- a/src/network/ssl/qsslsocket.cpp
+++ b/src/network/ssl/qsslsocket.cpp
@@ -149,6 +149,13 @@
This product includes software developed by the OpenSSL Project
for use in the OpenSSL Toolkit (\l{http://www.openssl.org/}).
+ \note Be aware of the difference between the bytesWritten() signal and
+ the encryptedBytesWritten() signal. For a QTcpSocket, bytesWritten()
+ will get emitted as soon as data has been written to the TCP socket.
+ For a QSslSocket, bytesWritten() will get emitted when the data
+ is being encrypted and encryptedBytesWritten()
+ will get emitted as soon as data has been written to the TCP socket.
+
\sa QSslCertificate, QSslCipher, QSslError
*/