44 #include "private/qnoncontiguousbytedevice_p.h" 52 # include <QtNetwork/qsslkey.h> 53 # include <QtNetwork/qsslcipher.h> 54 # include <QtNetwork/qsslconfiguration.h> 57 #ifndef QT_NO_BEARERMANAGEMENT 58 #include "private/qnetworksession_p.h" 100 #ifndef QT_NO_BEARERMANAGEMENT 105 #ifndef QT_NO_NETWORKPROXY 126 qRegisterMetaType<QAbstractSocket::SocketError>(
"QAbstractSocket::SocketError");
135 #ifndef QT_NO_NETWORKPROXY 141 #ifndef QT_NO_OPENSSL 174 qWarning() <<
"QHttpNetworkConnectionChannel::sendRequest() called without QHttpNetworkReply";
191 replyPrivate->
clear();
217 #ifndef QT_NO_NETWORKPROXY 227 if (uploadByteDevice) {
247 if (uploadByteDevice)
255 const qint64 socketBufferFill = 32*1024;
256 const qint64 socketWriteMaxSize = 16*1024;
259 #ifndef QT_NO_OPENSSL 270 qint64 currentReadSize = 0;
272 const char *readPointer = uploadByteDevice->
readPointer(desiredReadSize, currentReadSize);
274 if (currentReadSize == -1) {
279 }
else if (readPointer == 0 || currentReadSize == 0) {
284 if (currentWriteSize == -1 || currentWriteSize != currentReadSize) {
309 if (uploadByteDevice) {
340 qWarning() <<
"QHttpNetworkConnectionChannel::_q_receiveReply() called without QHttpNetworkReply," 350 if (!qobject_cast<QHttpNetworkConnection*>(
connection)) {
387 if (statusBytes == -1) {
392 bytes += statusBytes;
399 if (headerBytes == -1) {
404 bytes += headerBytes;
492 #ifndef QT_NO_COMPRESS 493 else if (!
expand(
false)) {
512 }
while (bytes != lastBytes &&
reply);
528 reply->d_func()->clear();
530 reply->d_func()->connectionChannel =
this;
586 #ifndef QT_NO_NETWORKPROXY 597 value =
connection->d_func()->predictNextRequest().headerField(
"user-agent");
605 #ifndef QT_NO_OPENSSL 621 #ifndef QT_NO_NETWORKPROXY 629 #ifndef QT_NO_NETWORKPROXY 646 #ifndef QT_NO_COMPRESS 652 qint64 total =
reply->d_func()->compressedData.size();
653 if (total >=
CHUNK || dataComplete) {
656 content =
reply->d_func()->compressedData;
657 reply->d_func()->compressedData.clear();
661 ret =
reply->d_func()->gunzipBodyPartially(content, inflated);
663 if (dataComplete && ret == Z_OK && !
reply->d_func()->streamEnd) {
664 reply->d_func()->gunzipBodyPartiallyEnd();
665 reply->d_func()->streamEnd =
true;
667 if (inflated.
size()) {
668 reply->d_func()->totalProgress += inflated.
size();
669 reply->d_func()->appendUncompressedReplyData(inflated);
670 if (
reply->d_func()->shouldEmitSignals()) {
690 #ifndef QT_NO_COMPRESS 692 if (
reply->d_func()->expectContent() &&
reply->d_func()->autoDecompress && !
reply->d_func()->streamEnd) {
693 bool expandResult =
expand(
true);
701 qWarning() <<
"QHttpNetworkConnectionChannel::allDone() called without reply. Please report at http://bugreports.qt-project.org/";
706 bool emitFinished =
reply->d_func()->shouldEmitSignals();
707 bool connectionCloseEnabled =
reply->d_func()->isConnectionCloseEnabled();
716 if (
reply && emitFinished)
769 if (connectionCloseEnabled)
772 if (qobject_cast<QHttpNetworkConnection*>(
connection))
786 && (!
reply->d_func()->isConnectionCloseEnabled())
792 && (!serverHeaderField.
contains(
"Microsoft-IIS/5."))
793 && (!serverHeaderField.
contains(
"Netscape-Enterprise/3."))
795 && (!serverHeaderField.
contains(
"WebLogic"))
814 if (qobject_cast<QHttpNetworkConnection*>(
connection))
826 switch (statusCode) {
834 reply->d_func()->eraseData();
860 if (qobject_cast<QHttpNetworkConnection*>(
connection))
872 if (!uploadByteDevice)
875 if (uploadByteDevice->
reset()) {
891 reply->d_func()->clear();
893 reply->d_func()->connectionChannel =
this;
895 reply->d_func()->pipeliningUsed =
true;
897 #ifndef QT_NO_NETWORKPROXY 930 if (qobject_cast<QHttpNetworkConnection*>(
connection))
1048 switch (socketError) {
1069 if (!
reply->d_func()->expectContent()) {
1086 #ifndef QT_NO_OPENSSL 1097 if (afterFlush == beforeFlush)
1099 beforeFlush = afterFlush;
1147 #ifndef QT_NO_NETWORKPROXY 1154 connection->d_func()->emitProxyAuthenticationRequired(
this, proxy, auth);
1163 #ifndef QT_NO_OPENSSL 1211 #include "moc_qhttpnetworkconnectionchannel_p.cpp" 1213 #endif // QT_NO_HTTP QNetworkProxy::ProxyType type() const
Returns the proxy type for this instance.
QSharedDataPointer< QHttpNetworkRequestPrivate > d
QList< HttpMessagePair > alreadyPipelinedRequests
void setUserInfo(const QString &userInfo)
Sets the user info of the URL to userInfo.
virtual bool reset()=0
Moves the internal read pointer back to the beginning.
Q_DECL_CONSTEXPR const T & qMin(const T &a, const T &b)
#define QT_END_NAMESPACE
This macro expands to.
void _q_encryptedBytesWritten(qint64 bytes)
PipeliningSupport pipeliningSupported
qint64 bytesAvailable() const
Returns the number of incoming bytes that are waiting to be read.
QAuthenticatorPrivate::Method authMethod
void detectPipeliningSupport()
QByteArray & append(char c)
Appends the character ch to this byte array.
qint64 readHeader(QAbstractSocket *socket)
qint64 encryptedBytesToWrite() const
Returns the number of encrypted bytes that are waiting to be written to the network.
QByteArray headerField(const QByteArray &name, const QByteArray &defaultValue=QByteArray()) const
bool authenticationCredentialsSent
QNetworkProxy transparentProxy() const
void connectToHost(const QString &hostName, quint16 port, OpenMode mode=ReadWrite)
Attempts to make a connection to hostName on the given port.
The QByteArray class provides an array of bytes.
void _q_sslErrors(const QList< QSslError > &errors)
QNetworkProxy proxy() const
Returns the network proxy for this socket.
bool isEmpty() const
Returns true if the URL has no data; otherwise returns false.
QString errorString() const
Returns a human-readable description of the last device error that occurred.
bool isSocketBusy() const
The QSslSocket class provides an SSL encrypted socket for both clients and servers.
void _q_uploadDataReadyRead()
bool setProperty(const char *name, const QVariant &value)
Sets the value of the object's name property to value.
NetworkError
Indicates all possible error conditions found during the processing of the request.
QNetworkProxy cacheProxy() const
void dataSendProgress(qint64 done, qint64 total)
bool proxyCredentialsSent
QString errorString() const
void ignoreSslErrors(const QList< QSslError > &errors)
This method tells QSslSocket to ignore only the errors given in errors.
The QUrl class provides a convenient interface for working with URLs.
The QString class provides a Unicode character string.
void removeAutoDecompressHeader()
T * qobject_cast(QObject *object)
void setUser(const QString &user)
Sets the user used for authentication.
bool startsWith(const QByteArray &a) const
Returns true if this byte array starts with byte array ba; otherwise returns false.
qint64 encryptedBytesAvailable() const
Returns the number of encrypted bytes that are awaiting decryption.
void setSocketOption(QAbstractSocket::SocketOption option, const QVariant &value)
Sets the given option to the value described by value.
virtual const char * readPointer(qint64 maximumLength, qint64 &len)=0
Return a byte pointer for at most maximumLength bytes of that device.
static QAuthenticatorPrivate * getPrivate(QAuthenticator &auth)
void finishedWithError(QNetworkReply::NetworkError errorCode, const QString &detail=QString())
void _q_error(QAbstractSocket::SocketError)
Q_GUI_EXPORT QString errorString(EGLint code=eglGetError())
SocketState
This enum describes the different states in which a socket can be.
QNonContiguousByteDevice * uploadByteDevice() const
The QNetworkProxy class provides a network layer proxy.
void requeueCurrentlyPipelinedRequests()
#define QT_BEGIN_NAMESPACE
This macro expands to.
static QIntfbScreen * connected
QByteArray headerField(const QByteArray &name, const QByteArray &defaultValue=QByteArray()) const
QSharedPointer< QNetworkSession > networkSession
void setUrl(const QUrl &url)
QPointer< QHttpNetworkConnection > connection
void closeAndResendCurrentRequest()
static bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
Creates a connection of the given type from the signal in the sender object to the method in the rece...
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
SocketError
This enum describes the socket errors that can occur.
void connectToHostEncrypted(const QString &hostName, quint16 port, OpenMode mode=ReadWrite)
Starts an encrypted connection to the device hostName on port, using mode as the OpenMode ...
qint64 peek(char *data, qint64 maxlen)
Reads at most maxSize bytes from the device into data, without side effects (i.
void sslErrors(const QList< QSslError > &errors)
QString userInfo() const
Returns the user info of the URL, or an empty string if the user info is undefined.
Q_CORE_EXPORT void qWarning(const char *,...)
void handleUnexpectedEOF()
The QTcpSocket class provides a TCP socket.
QHttpNetworkConnectionChannel()
void setReadBufferSize(qint64 size)
Sets the size of QAbstractSocket's internal read buffer to be size bytes.
void setReadBufferSize(qint64 size)
static QVariant fromValue(const T &value)
Returns a QVariant containing a copy of value.
void appendUncompressedReplyData(QByteArray &qba)
void close()
Closes the I/O device for the socket, disconnects the socket's connection with the host...
The QAuthenticator class provides an authentication object.
QHttpNetworkConnection * connection()
qint64 contentLength() const
static bool disconnect(const QObject *sender, const char *signal, const QObject *receiver, const char *member)
Disconnects signal in object sender from method in object receiver.
void _q_proxyAuthenticationRequired(const QNetworkProxy &proxy, QAuthenticator *auth)
QString userName() const
Returns the user name of the URL if it is defined; otherwise an empty string is returned.
enum QHttpNetworkReplyPrivate::ReplyState state
void setProxy(const QNetworkProxy &networkProxy)
Sets the explicit network proxy for this socket to networkProxy.
qint64 readBody(QAbstractSocket *socket, QByteDataBuffer *out)
QPointer< QHttpNetworkConnectionChannel > connectionChannel
bool flush()
This function writes as much as possible from the internal write buffer to the underlying network soc...
static QByteArray header(const QHttpNetworkRequest &request, bool throughProxy)
bool withCredentials() const
bool isSocketWriting() const
virtual bool advanceReadPointer(qint64 amount)=0
The old readPointer is invalid after this call.
QHttpNetworkReply * reply
QString user() const
returns the user used for authentication.
bool expand(bool dataComplete)
qint64 contentLength() const
QList< QSslError > ignoreSslErrorsList
bool isSocketReading() const
qint64 bytesToWrite() const
Returns the number of bytes that are waiting to be written.
void pipelineInto(HttpMessagePair &pair)
int size() const
Returns the number of bytes in this byte array.
char * userProvidedDownloadBuffer
bool isEmpty() const
Returns true if the byte array has size 0; otherwise returns false.
void clearHttpLayerInformation()
A QNonContiguousByteDevice is a representation of a file, array or buffer that allows access with a r...
QPointer< QHttpNetworkConnection > connection
void setPassword(const QString &password)
Sets the password used for authentication.
QAuthenticator authenticator
qint64 readBodyVeryFast(QAbstractSocket *socket, char *b)
qint64 write(const char *data, qint64 len)
Writes at most maxSize bytes of data from data to the device.
QString password() const
returns the password used for authentication.
QAuthenticator proxyAuthenticator
SocketError error() const
Returns the type of error that last occurred.
void dataReadProgress(int done, int total)
bool isSocketWaiting() const
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
QString password() const
Returns the password of the URL if it is defined; otherwise an empty string is returned.
qint64 readBodyFast(QAbstractSocket *socket, QByteDataBuffer *rb)
void setConnection(QHttpNetworkConnection *c)
void clear()
Clears the contents of the byte array and makes it empty.
void _q_bytesWritten(qint64 bytes)
void appendCompressedReplyData(QByteDataBuffer &data)
SocketState state() const
Returns the state of the socket.
QBool contains(char c) const
Returns true if the byte array contains the character ch; otherwise returns false.
QHttpNetworkRequest request
QAuthenticatorPrivate::Method proxyAuthMethod
QByteDataBuffer responseData