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;
98 const bool isLocalSocket = scheme.
startsWith(
"unix"_L1);
101 if (scheme ==
"preconnect-http"_L1)
102 copy.setScheme(
"http"_L1);
103 else if (scheme ==
"preconnect-https"_L1)
104 copy.setScheme(
"https"_L1);
108#ifndef QT_NO_NETWORKPROXY
114 key.setScheme(
"proxy-socks5"_L1);
119 key.setScheme(
"proxy-http"_L1);
126 if (!
key.scheme().isEmpty()) {
141 result += u
':' + peerVerifyName;
189 , downloadBufferMaximumSize(0)
190 , readBufferMaxSize(0)
192 , pendingDownloadData()
193 , pendingDownloadProgress()
195 , connectionCacheExpiryTimeoutSeconds(-1)
196 , incomingStatusCode(0)
197 , isPipeliningUsed(
false)
199 , incomingContentLength(-1)
200 , removedContentLength(-1)
205 , synchronousRequestLoop(
nullptr)
212#ifdef QHTTPTHREADDELEGATE_DEBUG
229#ifdef QHTTPTHREADDELEGATE_DEBUG
238#ifdef QHTTPTHREADDELEGATE_DEBUG
251 urlCopy.setPort(urlCopy.port(
ssl ? 443 : 80));
277 QList<QByteArray> protocols;
293#ifndef QT_NO_NETWORKPROXY
309 isLocalSocket, connectionType);
320#ifndef QT_NO_NETWORKPROXY
330 if (!credential.user.isEmpty() && !credential.password.isEmpty()) {
333 auth.setPassword(credential.password);
352#ifndef QT_NO_NETWORKPROXY
379#ifndef QT_NO_NETWORKPROXY
398#ifdef QHTTPTHREADDELEGATE_DEBUG
419#ifdef QHTTPTHREADDELEGATE_DEBUG
420 qDebug() <<
"QHttpThreadDelegate::readBufferSizeChanged() size " <<
size;
480#ifdef QHTTPTHREADDELEGATE_DEBUG
498 "Error transferring %1 - server replied: %2"));
518#ifdef QHTTPTHREADDELEGATE_DEBUG
524 "Error transferring %1 - server replied: %2"));
542#ifdef QHTTPTHREADDELEGATE_DEBUG
565#ifdef QHTTPTHREADDELEGATE_DEBUG
583#ifdef QHTTPTHREADDELEGATE_DEBUG
629#ifdef QHTTPTHREADDELEGATE_DEBUG
677 QList<QSslError> specificErrors;
681 if (!specificErrors.isEmpty())
700#ifdef QHTTPTHREADDELEGATE_DEBUG
706 if (!credential.isNull()) {
707 a->setUser(credential.user);
708 a->setPassword(credential.password);
716#ifndef QT_NO_NETWORKPROXY
722#ifdef QHTTPTHREADDELEGATE_DEBUG
727 if (!credential.isNull()) {
728 a->setUser(credential.user);
729 a->setPassword(credential.password);
732#ifndef QT_NO_NETWORKPROXY
743#include "moc_qhttpthreaddelegate_p.cpp"
The QAuthenticator class provides an authentication object.
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.
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)
void setPeerVerifyName(const QString &peerName)
ConnectionType connectionType() const
@ ConnectionTypeHTTP2Direct
void setTransparentProxy(const QNetworkProxy &networkProxy)
void setHttp2Parameters(const QHttp2Configuration ¶ms)
void setSslConfiguration(const QSslConfiguration &config)
QHttpHeaders header() const override
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
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
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 downloadMetaData(const QHttpHeaders &, int, const QString &, bool, QSharedPointer< char >, qint64, qint64, bool, bool)
void downloadProgress(qint64, qint64)
QHttpNetworkRequest httpRequest
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 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 &)
QHttpHeaders incomingHeaders
qint64 removedContentLength
std::shared_ptr< QNetworkAccessAuthenticationManager > authenticationManager
void synchronousHeaderChangedSlot()
void dataReadProgressSlot(qint64 done, qint64 total)
void preSharedKeyAuthenticationRequired(QSslPreSharedKeyAuthenticator *)
void sslConfigurationChanged(const QSslConfiguration &)
void setShareable(bool enable)
void setExpires(bool enable)
QNetworkAccessCachedHttpConnection(quint16 connectionCount, const QString &hostName, quint16 port, bool encrypt, bool isLocalSocket, QHttpNetworkConnection::ConnectionType connectionType)
virtual void dispose() override
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 &
bool startsWith(const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the string starts with s; otherwise returns false.
bool isEmpty() const noexcept
Returns true if the string has no characters; otherwise returns false.
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
QByteArray toUtf8() const &
static Qt::HANDLE currentThreadId() noexcept Q_DECL_PURE_FUNCTION
bool singleShot
whether the timer is a single-shot timer
QString scheme() const
Returns the scheme of the URL.
QString toString(FormattingOptions options=FormattingOptions(PrettyDecoded)) const
Returns a string representation of the URL.
Combined button and popup list for selecting options.
static jboolean copy(JNIEnv *, jobject)
DBusConnection const char DBusError * error
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)