9#include <QAuthenticator>
11#include <QCryptographicHash>
13#include "private/qhttpnetworkreply_p.h"
14#include "private/qnetworkaccesscache_p.h"
15#include "private/qnoncontiguousbytedevice_p.h"
25 switch (httpStatusCode) {
75 if (httpStatusCode > 500) {
78 }
else if (httpStatusCode >= 400) {
82 qWarning(
"QNetworkAccess: got HTTP status code %d which is not expected from url: \"%s\"",
97 bool isEncrypted = scheme ==
"https"_L1 || scheme ==
"preconnect-https"_L1;
99 if (scheme ==
"preconnect-http"_L1)
100 copy.setScheme(
"http"_L1);
101 else if (scheme ==
"preconnect-https"_L1)
102 copy.setScheme(
"https"_L1);
106#ifndef QT_NO_NETWORKPROXY
112 key.setScheme(
"proxy-socks5"_L1);
117 key.setScheme(
"proxy-http"_L1);
124 if (!
key.scheme().isEmpty()) {
139 result += u
':' + peerVerifyName;
187 , downloadBufferMaximumSize(0)
188 , readBufferMaxSize(0)
190 , pendingDownloadData()
191 , pendingDownloadProgress()
193 , connectionCacheExpiryTimeoutSeconds(-1)
194 , incomingStatusCode(0)
195 , isPipeliningUsed(
false)
197 , incomingContentLength(-1)
198 , removedContentLength(-1)
203 , synchronousRequestLoop(
nullptr)
210#ifdef QHTTPTHREADDELEGATE_DEBUG
227#ifdef QHTTPTHREADDELEGATE_DEBUG
236#ifdef QHTTPTHREADDELEGATE_DEBUG
286#ifndef QT_NO_NETWORKPROXY
312#ifndef QT_NO_NETWORKPROXY
344#ifndef QT_NO_NETWORKPROXY
371#ifndef QT_NO_NETWORKPROXY
390#ifdef QHTTPTHREADDELEGATE_DEBUG
411#ifdef QHTTPTHREADDELEGATE_DEBUG
412 qDebug() <<
"QHttpThreadDelegate::readBufferSizeChanged() size " <<
size;
472#ifdef QHTTPTHREADDELEGATE_DEBUG
490 "Error transferring %1 - server replied: %2"));
510#ifdef QHTTPTHREADDELEGATE_DEBUG
516 "Error transferring %1 - server replied: %2"));
534#ifdef QHTTPTHREADDELEGATE_DEBUG
557#ifdef QHTTPTHREADDELEGATE_DEBUG
575#ifdef QHTTPTHREADDELEGATE_DEBUG
593 }
QT_CATCH(
const std::bad_alloc &) {
624#ifdef QHTTPTHREADDELEGATE_DEBUG
695#ifdef QHTTPTHREADDELEGATE_DEBUG
701 if (!credential.
isNull()) {
702 a->setUser(credential.
user);
711#ifndef QT_NO_NETWORKPROXY
717#ifdef QHTTPTHREADDELEGATE_DEBUG
722 if (!credential.
isNull()) {
723 a->setUser(credential.
user);
727#ifndef QT_NO_NETWORKPROXY
738#include "moc_qhttpthreaddelegate_p.cpp"
The QAuthenticator class provides an authentication object.
void setPassword(const QString &password)
Sets the password used for authentication.
void setUser(const QString &user)
Sets the user used for authentication.
bool isEmpty() const noexcept
Returns true if the byte array has size 0; otherwise returns false.
QByteArray toHex(char separator='\0') const
Returns a hex encoded copy of the byte array.
static QByteArray hash(QByteArrayView data, Algorithm method)
Returns the hash of data using method.
int exec(ProcessEventsFlags flags=AllEvents)
Enters the main event loop and waits until exit() is called.
Q_NETWORK_EXPORT qsizetype numberOfConnectionsPerHost() const
Returns the number of connections used per http(s) {host}:{port} combination.
QHttpNetworkReply * sendRequest(const QHttpNetworkRequest &request)
void setCacheProxy(const QNetworkProxy &networkProxy)
ConnectionType connectionType()
void setPeerVerifyName(const QString &peerName)
@ ConnectionTypeHTTP2Direct
void setTransparentProxy(const QNetworkProxy &networkProxy)
void setHttp2Parameters(const QHttp2Configuration ¶ms)
void setSslConfiguration(const QSslConfiguration &config)
QString errorString() const
bool readAnyAvailable() const
qint64 removedContentLength() const
QByteArray read(qint64 amount)
bool isPipeliningUsed() const
void setUserProvidedDownloadBuffer(char *)
bool isRedirecting() const
void setReadBufferSize(qint64 size)
QNetworkReply::NetworkError errorCode() const
bool supportsUserProvidedDownloadBuffer()
void setDownstreamLimited(bool t)
QString reasonPhrase() const
qint64 contentLength() const override
QList< QPair< QByteArray, QByteArray > > header() const override
QSslConfiguration sslConfiguration() const
QHttpNetworkRequest request() const
bool isCompressed() const
bool isH2cAllowed() const
bool isFollowRedirects() const
bool isHTTP2Direct() const
bool withCredentials() const
QUrl url() const override
QString peerVerifyName() const
bool isHTTP2Allowed() const
int redirectCount() const
QList< QPair< QByteArray, QByteArray > > incomingHeaders
void cacheCredentialsSlot(const QHttpNetworkRequest &request, QAuthenticator *authenticator)
QSharedPointer< char > downloadBuffer
QHttpNetworkReply * httpReply
void readBufferSizeChanged(qint64 size)
void synchronousAuthenticationRequiredSlot(const QHttpNetworkRequest &request, QAuthenticator *)
void synchronousFinishedWithErrorSlot(QNetworkReply::NetworkError errorCode, const QString &detail=QString())
void socketStartedConnecting()
QString incomingErrorDetail
QScopedPointer< QSslConfiguration > incomingSslConfiguration
std::shared_ptr< QAtomicInt > pendingDownloadData
void sslErrorsSlot(const QList< QSslError > &errors)
QNetworkAccessCachedHttpConnection * httpConnection
void synchronousFinishedSlot()
void redirected(const QUrl &url, int httpStatus, int maxRedirectsRemainig)
void downloadProgress(qint64, qint64)
QHttpNetworkRequest httpRequest
void downloadMetaData(const QList< QPair< QByteArray, QByteArray > > &, int, const QString &, bool, QSharedPointer< char >, qint64, qint64, bool, bool)
void preSharedKeyAuthenticationRequiredSlot(QSslPreSharedKeyAuthenticator *authenticator)
QHttp1Configuration http1Parameters
QByteArray synchronousDownloadData
qint64 connectionCacheExpiryTimeoutSeconds
QString incomingReasonPhrase
QNetworkProxy transparentProxy
QEventLoop * synchronousRequestLoop
QHttpThreadDelegate(QObject *parent=nullptr)
void proxyAuthenticationRequired(const QNetworkProxy &, QAuthenticator *)
void sslErrors(const QList< QSslError > &, bool *, QList< QSslError > *)
void error(QNetworkReply::NetworkError, const QString &)
void synchronousProxyAuthenticationRequiredSlot(const QNetworkProxy &, QAuthenticator *)
qint64 incomingContentLength
qint64 downloadBufferMaximumSize
void finishedWithErrorSlot(QNetworkReply::NetworkError errorCode, const QString &detail=QString())
void authenticationRequired(const QHttpNetworkRequest &request, QAuthenticator *)
void readBufferFreed(qint64 size)
QHttp2Configuration http2Parameters
static QThreadStorage< QNetworkAccessCache * > connections
void startRequestSynchronously()
std::shared_ptr< QAtomicInt > pendingDownloadProgress
QNetworkReply::NetworkError incomingErrorCode
void downloadData(const QByteArray &)
qint64 removedContentLength
std::shared_ptr< QNetworkAccessAuthenticationManager > authenticationManager
void synchronousHeaderChangedSlot()
void dataReadProgressSlot(qint64 done, qint64 total)
void preSharedKeyAuthenticationRequired(QSslPreSharedKeyAuthenticator *)
void sslConfigurationChanged(const QSslConfiguration &)
bool isEmpty() const noexcept
void setShareable(bool enable)
void setExpires(bool enable)
CacheableObject * requestEntryNow(const QByteArray &key)
void addEntry(const QByteArray &key, CacheableObject *entry, qint64 connectionCacheExpiryTimeoutSeconds=-1)
void releaseEntry(const QByteArray &key)
virtual void dispose() override
QNetworkAccessCachedHttpConnection(quint16 connectionCount, const QString &hostName, quint16 port, bool encrypt, QHttpNetworkConnection::ConnectionType connectionType)
The QNetworkProxy class provides a network layer proxy.
QString user() const
Returns the user name used for authentication.
QNetworkProxy::ProxyType type() const
Returns the proxy type for this instance.
QString password() const
Returns the password used for authentication.
QString hostName() const
Returns the host name of the proxy host.
quint16 port() const
Returns the port of the proxy host.
The QNetworkReply class contains the data and headers for a request sent with QNetworkAccessManager.
NetworkError
Indicates all possible error conditions found during the processing of the request.
@ ContentOperationNotPermittedError
@ OperationNotImplementedError
@ ServiceUnavailableError
@ ProtocolInvalidOperationError
@ ProxyAuthenticationRequiredError
@ AuthenticationRequiredError
QUrl url() const
Returns the URL this network request is referring to.
static QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
\threadsafe
void setParent(QObject *parent)
Makes the object a child of parent.
static bool disconnect(const QObject *sender, const char *signal, const QObject *receiver, const char *member)
\threadsafe
void deleteLater()
\threadsafe
T * data() const noexcept
Returns the value of the pointer referenced by this object.
bool isNull() const noexcept
Returns true if this object refers to \nullptr.
static const char ALPNProtocolHTTP2[]
void setAllowedNextProtocols(const QList< QByteArray > &protocols)
static const char NextProtocolHttp1_1[]
The QSslPreSharedKeyAuthenticator class provides authentication data for pre shared keys (PSK) cipher...
\macro QT_RESTRICTED_CAST_FROM_ASCII
QByteArray toLatin1() const &
static QString fromUtf8(QByteArrayView utf8)
This is an overloaded member function, provided for convenience. It differs from the above function o...
QString arg(qlonglong a, int fieldwidth=0, int base=10, QChar fillChar=u' ') const
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
QByteArray toUtf8() const &
bool hasLocalData() const
If T is a pointer type, returns true if the calling thread has non-zero data available.
void setLocalData(T t)
Sets the local data for the calling thread to data.
T & localData()
Returns a reference to the data that was set by the calling thread.
static Qt::HANDLE currentThreadId() noexcept Q_DECL_PURE_FUNCTION
bool singleShot
whether the timer is a single-shot timer
QString host(ComponentFormattingOptions=FullyDecoded) const
Returns the host of the URL if it is defined; otherwise an empty string is returned.
void setScheme(const QString &scheme)
Sets the scheme of the URL to scheme.
int port(int defaultPort=-1) const
QString toString(FormattingOptions options=FormattingOptions(PrettyDecoded)) const
Returns a string representation of the URL.
void setPort(int port)
Sets the port of the URL to port.
Combined button and popup list for selecting options.
static jboolean copy(JNIEnv *, jobject)
static QNetworkReply::NetworkError statusCodeFromHttp(int httpStatusCode, const QUrl &url)
static QByteArray makeCacheKey(QUrl &url, QNetworkProxy *proxy, const QString &peerVerifyName)
static bool isEncrypted(const my_mach_header *header)
GLboolean GLboolean GLboolean GLboolean a
[7]
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLenum GLuint GLenum GLsizei const GLchar * buf
#define qPrintable(string)
#define QStringLiteral(str)
#define QT_TRANSLATE_NOOP(scope, x)
QUrl url("example.com")
[constructor-url-reference]
QNetworkRequest request(url)
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent