132 if (
auto *absSocket = qobject_cast<QAbstractSocket *>(channels[i].socket)) {
135 QSslSocketPrivate::resumeSocketNotifiers(
static_cast<QSslSocket*>(absSocket));
138 QAbstractSocketPrivate::resumeSocketNotifiers(absSocket);
141 if (channels[i].state == QHttpNetworkConnectionChannel::WritingState)
142 QMetaObject::invokeMethod(&channels[i],
"_q_uploadDataReadyRead", Qt::QueuedConnection);
143#if QT_CONFIG(localserver)
144 }
else if (qobject_cast<QLocalSocket *>(channels[i].socket)) {
146 qDebug() <<
"Should resume socket but there is no way to do it for local sockets";
153 QMetaObject::invokeMethod(
this->q_func(),
"_q_startNextRequest", Qt::QueuedConnection);
253 QHttpNetworkRequest &request = messagePair.first;
254 QHttpNetworkReply *reply = messagePair.second;
260 QNonContiguousByteDevice* uploadByteDevice = request.uploadByteDevice();
261 if (uploadByteDevice) {
262 const qint64 contentLength = request.contentLength();
263 const qint64 uploadDeviceSize = uploadByteDevice->size();
264 if (contentLength != -1 && uploadDeviceSize != -1) {
266 if (uploadDeviceSize < contentLength)
267 request.setContentLength(uploadDeviceSize);
268 }
else if (contentLength == -1 && uploadDeviceSize != -1) {
270 request.setContentLength(uploadDeviceSize);
271 }
else if (contentLength != -1 && uploadDeviceSize == -1) {
273 }
else if (Q_UNLIKELY(contentLength == -1 && uploadDeviceSize == -1)) {
274 qFatal(
"QHttpNetworkConnectionPrivate: Neither content-length nor upload device size were given");
279#ifndef QT_NO_NETWORKPROXY
280 if (networkProxy.type() == QNetworkProxy::HttpCachingProxy) {
281 value = request.headerField(
"proxy-connection");
283 request.setHeaderField(
"Proxy-Connection",
"Keep-Alive");
286 value = request.headerField(
"connection");
288 request.setHeaderField(
"Connection",
"Keep-Alive");
289#ifndef QT_NO_NETWORKPROXY
298 value = request.headerField(
"accept-encoding");
299 if (value.isEmpty()) {
300#ifndef QT_NO_COMPRESS
301 const static QByteArray acceptedEncoding = QDecompressHelper::acceptedEncoding().join(
", ");
302 request.setHeaderField(
"Accept-Encoding", acceptedEncoding);
303 request.d->autoDecompress =
true;
306 request.d->autoDecompress =
false;
314 value = request.headerField(
"accept-language");
316 request.setHeaderField(
"Accept-Language", makeAcceptLanguage());
319 value = request.headerField(
"user-agent");
321 request.setHeaderField(
"User-Agent",
"Mozilla/5.0");
323 value = request.headerField(
"host");
328 request.prependHeaderField(
"Host", request.url().host().toLocal8Bit());
329 }
else if (value.isEmpty()) {
332 if (add.setAddress(hostName)) {
333 if (add.protocol() == QAbstractSocket::IPv6Protocol)
334 host = (u'[' + removeZoneId(hostName) + u']').toLatin1();
336 host = hostName.toLatin1();
339 host = QUrl::toAce(hostName);
342 int port = request.url().port();
345 host += QByteArray::number(port);
348 request.prependHeaderField(
"Host", host);
351 reply->d_func()->requestIsPrepared =
true;
358 QHttpNetworkReply *reply,
359 QNetworkReply::NetworkError errorCode)
361 Q_Q(QHttpNetworkConnection);
369 reply->d_func()->errorString = errorDetail(errorCode, socket);
370 emit reply->finishedWithError(errorCode, reply->d_func()->errorString);
372 reply->d_func()->eraseData();
376 channels[i].reply =
nullptr;
377 if (channels[i].protocolHandler)
378 channels[i].protocolHandler->setReply(
nullptr);
379 channels[i].request = QHttpNetworkRequest();
381 channels[i].requeueCurrentlyPipelinedRequests();
384 QMetaObject::invokeMethod(q,
"_q_startNextRequest", Qt::QueuedConnection);
394 if (fromChannel >= 0) {
395 QAuthenticatorPrivate *priv = QAuthenticatorPrivate::getPrivate(*auth);
397 && (priv->method == QAuthenticatorPrivate::Ntlm
398 || priv->method == QAuthenticatorPrivate::Negotiate)) {
404 QAuthenticator* otherAuth =
nullptr;
406 if (i == fromChannel)
409 otherAuth = &channels[i].proxyAuthenticator;
411 otherAuth = &channels[i].authenticator;
413 if (otherAuth->user().compare(auth->user()))
414 otherAuth->setUser(auth->user());
415 if (otherAuth->password().compare(auth->password()))
416 otherAuth->setPassword(auth->password());
423 bool isProxy,
bool &resend)
430 const auto headers = reply->header();
433 const QByteArray header = isProxy ?
"proxy-authenticate" :
"www-authenticate";
434 const QByteArrayList &authenticationMethods = reply->d_func()->headerFieldValues(header);
435 const bool isSupported =
std::any_of(authenticationMethods.begin(), authenticationMethods.end(),
436 QAuthenticatorPrivate::isMethodSupported);
438 int i = indexOf(socket);
440 QAuthenticator *auth = isProxy ? &channels[i].proxyAuthenticator
441 : &channels[i].authenticator;
445 QAuthenticatorPrivate *priv = QAuthenticatorPrivate::getPrivate(*auth);
446 priv->parseHttpResponse(headers, isProxy);
448 if (priv->method == QAuthenticatorPrivate::None)
451 if (priv->phase == QAuthenticatorPrivate::Done ||
452 (priv->phase == QAuthenticatorPrivate::Start
453 && (priv->method == QAuthenticatorPrivate::Ntlm
454 || priv->method == QAuthenticatorPrivate::Negotiate))) {
455 if (priv->phase == QAuthenticatorPrivate::Start)
456 priv->phase = QAuthenticatorPrivate::Phase1;
460 if (channels[i].authenticationCredentialsSent) {
462 priv = QAuthenticatorPrivate::getPrivate(*auth);
463 priv->hasFailed =
true;
464 priv->phase = QAuthenticatorPrivate::Done;
465 channels[i].authenticationCredentialsSent =
false;
467 emit reply->authenticationRequired(reply->request(), auth);
468#ifndef QT_NO_NETWORKPROXY
470 if (channels[i].proxyCredentialsSent) {
472 priv = QAuthenticatorPrivate::getPrivate(*auth);
473 priv->hasFailed =
true;
474 priv->phase = QAuthenticatorPrivate::Done;
475 channels[i].proxyCredentialsSent =
false;
477 emit reply->proxyAuthenticationRequired(networkProxy, auth);
482 if (priv->phase != QAuthenticatorPrivate::Done) {
484 copyCredentials(i, auth, isProxy);
486 }
else if (priv->phase == QAuthenticatorPrivate::Start) {
490 emit reply->cacheCredentials(reply->request(), auth);
496 if (priv->phase == QAuthenticatorPrivate::Done || !reply->request().withCredentials()) {
500 channels[i].proxyAuthenticator = QAuthenticator();
502 channels[i].authenticator = QAuthenticator();
505 emit reply->headerChanged();
506 emit reply->readyRead();
507 QNetworkReply::NetworkError errorCode =
509 ? QNetworkReply::ProxyAuthenticationRequiredError
510 : QNetworkReply::AuthenticationRequiredError;
511 reply->d_func()->errorString = errorDetail(errorCode, socket);
512 emit reply->finishedWithError(errorCode, reply->d_func()->errorString);
538 if (!reply->request().isFollowRedirects())
539 return {{}, QNetworkReply::NoError};
542 const QHttpHeaders fields = reply->header();
543 if (
const auto h = fields.values(QHttpHeaders::WellKnownHeader::Location); !h.empty()) {
544 redirectUrl = QUrl::fromEncoded(h.first());
548 if (!redirectUrl.isValid())
549 return {{}, QNetworkReply::ProtocolUnknownError};
552 if (reply->request().redirectCount() <= 0)
553 return {{}, QNetworkReply::TooManyRedirectsError};
556 if (redirectUrl.isRelative())
557 redirectUrl = reply->request().url().resolved(redirectUrl);
560 const QUrl priorUrl(reply->request().url());
561 const QString targetUrlScheme = redirectUrl.scheme();
562 if (targetUrlScheme ==
"http"_L1 || targetUrlScheme ==
"https"_L1
563 || targetUrlScheme.startsWith(
"unix"_L1)) {
564 switch (reply->request().redirectPolicy()) {
565 case QNetworkRequest::NoLessSafeRedirectPolicy:
572 case QNetworkRequest::SameOriginRedirectPolicy:
573 if (priorUrl.host() != redirectUrl.host()
574 || priorUrl.scheme() != targetUrlScheme
575 || priorUrl.port() != redirectUrl.port()) {
576 return {{}, QNetworkReply::InsecureRedirectError};
579 case QNetworkRequest::UserVerifiedRedirectPolicy:
582 Q_ASSERT(!
"Unexpected redirect policy");
585 return {{}, QNetworkReply::ProtocolUnknownError};
587 return {std::move(redirectUrl), QNetworkReply::NoError};
596 QAuthenticator *authenticator = &channel.authenticator;
597 QAuthenticatorPrivate *priv = QAuthenticatorPrivate::getPrivate(*authenticator);
599 if (priv && priv->method != QAuthenticatorPrivate::None) {
600 const bool ntlmNego = priv->method == QAuthenticatorPrivate::Ntlm
601 || priv->method == QAuthenticatorPrivate::Negotiate;
603 const bool ntlmNegoOk = ntlmNego && authNeeded
604 && (priv->phase != QAuthenticatorPrivate::Done
605 || !channel.authenticationCredentialsSent);
607 !ntlmNego && (authNeeded || request.headerField(
"Authorization").isEmpty());
608 if (ntlmNegoOk || otherOk) {
609 QByteArray response = priv->calculateResponse(request.methodName(), request.uri(
false),
610 request.url().host());
611 request.setHeaderField(
"Authorization", response);
616#if QT_CONFIG(networkproxy)
617 authenticator = &channel.proxyAuthenticator;
618 priv = QAuthenticatorPrivate::getPrivate(*authenticator);
620 if (priv && priv->method != QAuthenticatorPrivate::None) {
621 const bool ntlmNego = priv->method == QAuthenticatorPrivate::Ntlm
622 || priv->method == QAuthenticatorPrivate::Negotiate;
623 const bool proxyAuthNeeded = channel.lastStatus == 407;
624 const bool ntlmNegoOk = ntlmNego && proxyAuthNeeded
625 && (priv->phase != QAuthenticatorPrivate::Done || !channel.proxyCredentialsSent);
626 const bool otherOk = !ntlmNego;
627 if (ntlmNegoOk || otherOk) {
628 QByteArray response = priv->calculateResponse(request.methodName(), request.uri(
false),
629 networkProxy.hostName());
630 request.setHeaderField(
"Proxy-Authorization", response);
631 channel.proxyCredentialsSent =
true;
639 Q_Q(QHttpNetworkConnection);
642 QHttpNetworkReply *reply =
new QHttpNetworkReply(request.url());
643 reply->setRequest(request);
644 reply->d_func()->connection = q;
645 reply->d_func()->connectionChannel = &channels[0];
648 if (request.isPreConnect())
651 if (connectionType == QHttpNetworkConnection::ConnectionTypeHTTP
652 || (!encrypt && connectionType == QHttpNetworkConnection::ConnectionTypeHTTP2 && !channels[0].switchedToHttp2)) {
653 switch (request.priority()) {
654 case QHttpNetworkRequest::HighPriority:
655 highPriorityQueue.prepend(pair);
657 case QHttpNetworkRequest::NormalPriority:
658 case QHttpNetworkRequest::LowPriority:
659 lowPriorityQueue.prepend(pair);
664 if (!pair.second->d_func()->requestIsPrepared)
666 channels[0].h2RequestsToSend.insert(request.priority(), pair);
691 for (
auto &pair : highPriorityQueue) {
692 if (!pair.second->d_func()->requestIsPrepared)
693 prepareRequest(pair);
694 channels[0].h2RequestsToSend.insert(QHttpNetworkRequest::HighPriority, pair);
697 highPriorityQueue.clear();
699 for (
auto &pair : lowPriorityQueue) {
700 if (!pair.second->d_func()->requestIsPrepared)
701 prepareRequest(pair);
702 channels[0].h2RequestsToSend.insert(pair.first.priority(), pair);
705 lowPriorityQueue.clear();
783 if (highPriorityQueue.isEmpty() && lowPriorityQueue.isEmpty())
786 int i = indexOf(socket);
789 if (channels[i].reply ==
nullptr)
792 if (! (defaultPipelineLength - channels[i].alreadyPipelinedRequests.size() >= defaultRePipelineLength)) {
796 if (channels[i].pipeliningSupported != QHttpNetworkConnectionChannel::PipeliningProbablySupported)
800 if (!channels[i].request.isPipeliningAllowed())
804 if (channels[i].request.operation() != QHttpNetworkRequest::Get)
808 if (QSocketAbstraction::socketState(socket) != QAbstractSocket::ConnectedState)
812 if (channels[i].resendCurrent)
817 if (!channels[i].authenticator.isNull()
818 && (!channels[i].authenticator.user().isEmpty()
819 || !channels[i].authenticator.password().isEmpty()))
821 if (!channels[i].proxyAuthenticator.isNull()
822 && (!channels[i].proxyAuthenticator.user().isEmpty()
823 || !channels[i].proxyAuthenticator.password().isEmpty()))
827 if (! (channels[i].state == QHttpNetworkConnectionChannel::WaitingState
828 || channels[i].state == QHttpNetworkConnectionChannel::ReadingState))
832 while (!highPriorityQueue.isEmpty()) {
833 lengthBefore = channels[i].alreadyPipelinedRequests.size();
834 fillPipeline(highPriorityQueue, channels[i]);
836 if (channels[i].alreadyPipelinedRequests.size() >= defaultPipelineLength) {
837 channels[i].pipelineFlush();
841 if (lengthBefore == channels[i].alreadyPipelinedRequests.size())
845 while (!lowPriorityQueue.isEmpty()) {
846 lengthBefore = channels[i].alreadyPipelinedRequests.size();
847 fillPipeline(lowPriorityQueue, channels[i]);
849 if (channels[i].alreadyPipelinedRequests.size() >= defaultPipelineLength) {
850 channels[i].pipelineFlush();
854 if (lengthBefore == channels[i].alreadyPipelinedRequests.size())
859 channels[i].pipelineFlush();
906 case QNetworkReply::HostNotFoundError: {
907 const QString peerName = socket ? QSocketAbstraction::socketPeerName(socket) : hostName;
908 errorString = QCoreApplication::translate(
"QHttp",
"Host %1 not found").arg(peerName);
911 case QNetworkReply::ConnectionRefusedError:
912 errorString = QCoreApplication::translate(
"QHttp",
"Connection refused");
914 case QNetworkReply::RemoteHostClosedError:
915 errorString = QCoreApplication::translate(
"QHttp",
"Connection closed");
917 case QNetworkReply::TimeoutError:
918 errorString = QCoreApplication::translate(
"QAbstractSocket",
"Socket operation timed out");
920 case QNetworkReply::ProxyAuthenticationRequiredError:
921 errorString = QCoreApplication::translate(
"QHttp",
"Proxy requires authentication");
923 case QNetworkReply::AuthenticationRequiredError:
924 errorString = QCoreApplication::translate(
"QHttp",
"Host requires authentication");
926 case QNetworkReply::ProtocolFailure:
927 errorString = QCoreApplication::translate(
"QHttp",
"Data corrupted");
929 case QNetworkReply::ProtocolUnknownError:
930 errorString = QCoreApplication::translate(
"QHttp",
"Unknown protocol specified");
932 case QNetworkReply::SslHandshakeFailedError:
933 errorString = QCoreApplication::translate(
"QHttp",
"SSL handshake failed");
935 errorString +=
": "_L1 + socket->errorString();
937 case QNetworkReply::TooManyRedirectsError:
938 errorString = QCoreApplication::translate(
"QHttp",
"Too many redirects");
940 case QNetworkReply::InsecureRedirectError:
941 errorString = QCoreApplication::translate(
"QHttp",
"Insecure redirect");
945 errorString = extraDetail;
955 Q_Q(QHttpNetworkConnection);
960 if (channels[i].reply == reply) {
961 channels[i].reply =
nullptr;
962 if (channels[i].protocolHandler)
963 channels[i].protocolHandler->setReply(
nullptr);
964 channels[i].request = QHttpNetworkRequest();
965 channels[i].resendCurrent =
false;
967 if (!reply->isFinished() && !channels[i].alreadyPipelinedRequests.isEmpty()) {
970 channels[i].requeueCurrentlyPipelinedRequests();
976 if (reply->d_func()->isConnectionCloseEnabled() || !reply->isFinished()) {
977 if (reply->isAborted()) {
984 QMetaObject::invokeMethod(q,
"_q_startNextRequest", Qt::QueuedConnection);
989 for (
int j = 0; j < channels[i].alreadyPipelinedRequests.size(); j++) {
990 if (channels[i].alreadyPipelinedRequests.at(j).second == reply) {
992 channels[i].alreadyPipelinedRequests.removeAt(j);
994 channels[i].requeueCurrentlyPipelinedRequests();
1000 if (channels[i].reply)
1001 channels[i].reply->d_func()->forceConnectionCloseEnabled =
true;
1003 QMetaObject::invokeMethod(q,
"_q_startNextRequest", Qt::QueuedConnection);
1009 return pair.second == reply;
1011 auto &seq = channels[i].h2RequestsToSend;
1012 const auto end = seq.cend();
1013 auto it =
std::find_if(seq.cbegin(), end, foundReply);
1016 QMetaObject::invokeMethod(q,
"_q_startNextRequest", Qt::QueuedConnection);
1020 if ((connectionType == QHttpNetworkConnection::ConnectionTypeHTTP2Direct
1021 || channels[i].switchedToHttp2)
1022 && channels[i].protocolHandler) {
1023 if (channels[i].protocolHandler->tryRemoveReply(reply))
1028 if (!highPriorityQueue.isEmpty()) {
1029 for (
int j = highPriorityQueue.size() - 1; j >= 0; --j) {
1031 if (messagePair.second == reply) {
1032 highPriorityQueue.removeAt(j);
1033 QMetaObject::invokeMethod(q,
"_q_startNextRequest", Qt::QueuedConnection);
1039 if (!lowPriorityQueue.isEmpty()) {
1040 for (
int j = lowPriorityQueue.size() - 1; j >= 0; --j) {
1042 if (messagePair.second == reply) {
1043 lowPriorityQueue.removeAt(j);
1044 QMetaObject::invokeMethod(q,
"_q_startNextRequest", Qt::QueuedConnection);
1068 if (channels[i].resendCurrent && (channels[i].state != QHttpNetworkConnectionChannel::ClosingState)) {
1069 if (!channels[i].socket
1070 || QSocketAbstraction::socketState(channels[i].socket) == QAbstractSocket::UnconnectedState) {
1071 if (!channels[i].ensureConnection())
1074 channels[i].resendCurrent =
false;
1077 if (!channels[i].resetUploadData())
1079 channels[i].sendRequest();
1085 switch (connectionType) {
1086 case QHttpNetworkConnection::ConnectionTypeHTTP: {
1088 if (highPriorityQueue.isEmpty() && lowPriorityQueue.isEmpty())
1093 if (channels[i].socket) {
1094 if (!channels[i].reply && !channels[i].isSocketBusy()
1095 && QSocketAbstraction::socketState(channels[i].socket)
1096 == QAbstractSocket::ConnectedState) {
1097 if (dequeueRequest(channels[i].socket))
1098 channels[i].sendRequest();
1104 case QHttpNetworkConnection::ConnectionTypeHTTP2Direct:
1105 case QHttpNetworkConnection::ConnectionTypeHTTP2: {
1106 auto &channel = channels[0];
1107 if (channel.h2RequestsToSend.isEmpty() && !channel.reply
1108 && highPriorityQueue.isEmpty() && lowPriorityQueue.isEmpty()) {
1112 if (networkLayerState == IPv4)
1113 channel.networkLayerPreference = QAbstractSocket::IPv4Protocol;
1114 else if (networkLayerState == IPv6)
1115 channel.networkLayerPreference = QAbstractSocket::IPv6Protocol;
1116 channel.ensureConnection();
1119 if (channel.isPendingReconnect())
1122 if (
auto *s = channel.socket; s
1123 && QSocketAbstraction::socketState(s) == QAbstractSocket::ConnectedState
1124 && !channel.pendingEncrypt) {
1125 if (channel.h2RequestsToSend.size()) {
1126 channel.sendRequest();
1127 }
else if (!channel.reply && !channel.switchedToHttp2) {
1132 dequeueRequest(channel.socket);
1133 channel.sendRequest();
1148 if (highPriorityQueue.isEmpty() && lowPriorityQueue.isEmpty())
1151 if (channels[i].socket
1152 && QSocketAbstraction::socketState(channels[i].socket)
1153 == QAbstractSocket::ConnectedState) {
1154 fillPipeline(channels[i].socket);
1161 int queuedRequests = highPriorityQueue.size() + lowPriorityQueue.size();
1165 int neededOpenChannels = queuedRequests;
1171 if (neededOpenChannels <= 0)
1174 QVarLengthArray<
int> channelsToConnect;
1178 if (!channels[i].socket)
1181 using State = QAbstractSocket::SocketState;
1182 if ((QSocketAbstraction::socketState(channels[i].socket) == State::ConnectingState)
1183 || (QSocketAbstraction::socketState(channels[i].socket) == State::HostLookupState)
1184 || channels[i].pendingEncrypt) {
1185 neededOpenChannels--;
1189 if (!channels[i].reply && !channels[i].isSocketBusy()
1190 && (QSocketAbstraction::socketState(channels[i].socket) == State::UnconnectedState)) {
1191 channelsToConnect.push_back(i);
1192 neededOpenChannels--;
1198 if (channels[i].socket)
1201 channelsToConnect.push_back(i);
1202 neededOpenChannels--;
1205 auto channelToConnectSpan =
QSpan{channelsToConnect};
1206 while (!channelToConnectSpan.isEmpty()) {
1207 const int channel = channelToConnectSpan.front();
1208 channelToConnectSpan = channelToConnectSpan.sliced(1);
1210 if (networkLayerState == IPv4)
1211 channels[channel].networkLayerPreference = QAbstractSocket::IPv4Protocol;
1212 else if (networkLayerState == IPv6)
1213 channels[channel].networkLayerPreference = QAbstractSocket::IPv6Protocol;
1215 channels[channel].ensureConnection();
1242 QString lookupHost = hostName;
1243#ifndef QT_NO_NETWORKPROXY
1244 if (networkProxy.capabilities() & QNetworkProxy::HostNameLookupCapability) {
1245 lookupHost = networkProxy.hostName();
1246 }
else if (channels[0].proxy.capabilities() & QNetworkProxy::HostNameLookupCapability) {
1247 lookupHost = channels[0].proxy.hostName();
1251 if (temp.setAddress(lookupHost)) {
1252 const QAbstractSocket::NetworkLayerProtocol protocol = temp.protocol();
1253 if (protocol == QAbstractSocket::IPv4Protocol) {
1255 QMetaObject::invokeMethod(
this->q_func(),
"_q_startNextRequest", Qt::QueuedConnection);
1257 }
else if (protocol == QAbstractSocket::IPv6Protocol) {
1259 QMetaObject::invokeMethod(
this->q_func(),
"_q_startNextRequest", Qt::QueuedConnection);
1264 bool immediateResultValid =
false;
1265 QHostInfo hostInfo = qt_qhostinfo_lookup(lookupHost,
1267 SLOT(_q_hostLookupFinished(QHostInfo)),
1268 &immediateResultValid,
1270 if (immediateResultValid) {
1281 bool foundAddress =
false;
1285 const auto addresses = info.addresses();
1286 for (
const QHostAddress &address : addresses) {
1287 const QAbstractSocket::NetworkLayerProtocol protocol = address.protocol();
1288 if (protocol == QAbstractSocket::IPv4Protocol) {
1289 if (!foundAddress) {
1290 foundAddress =
true;
1294 }
else if (protocol == QAbstractSocket::IPv6Protocol) {
1295 if (!foundAddress) {
1296 foundAddress =
true;
1307 QMetaObject::invokeMethod(
this->q_func(),
"_q_startNextRequest", Qt::QueuedConnection);
1310 QMetaObject::invokeMethod(
this->q_func(),
"_q_startNextRequest", Qt::QueuedConnection);
1312 auto lookupError = QNetworkReply::HostNotFoundError;
1313#ifndef QT_NO_NETWORKPROXY
1316 auto proxyCapabilities = networkProxy.capabilities() | channels[0].proxy.capabilities();
1317 if (proxyCapabilities & QNetworkProxy::HostNameLookupCapability)
1318 lookupError = QNetworkReply::ProxyNotFoundError;
1320 if (dequeueRequest(channels[0].socket)) {
1321 emitReplyError(channels[0].socket, channels[0].reply, lookupError);
1323 }
else if (connectionType == QHttpNetworkConnection::ConnectionTypeHTTP2
1324 || connectionType == QHttpNetworkConnection::ConnectionTypeHTTP2Direct) {
1325 for (
const HttpMessagePair &h2Pair : std::as_const(channels[0].h2RequestsToSend)) {
1327 QHttpNetworkReply *currentReply = h2Pair.second;
1328 Q_ASSERT(currentReply);
1329 emitReplyError(channels[0].socket, currentReply, lookupError);
1334 qDebug(
"QHttpNetworkConnectionPrivate::_q_hostLookupFinished"
1335 " could not de-queue request, failed to report HostNotFoundError");
1388QHttpNetworkConnection::QHttpNetworkConnection(quint16 connectionCount,
const QString &hostName,
1389 quint16 port,
bool encrypt,
bool isLocalSocket, QObject *parent,
1390 QHttpNetworkConnection::ConnectionType connectionType)
1391 : QObject(*(
new QHttpNetworkConnectionPrivate(connectionCount, hostName, port, encrypt, isLocalSocket,
1392 connectionType)), parent)
1394 Q_D(QHttpNetworkConnection);
1438void QHttpNetworkConnection::setCacheProxy(
const QNetworkProxy &networkProxy)
1440 Q_D(QHttpNetworkConnection);
1441 d->networkProxy = networkProxy;
1443 if (!d->networkProxy.user().isEmpty()) {
1444 for (
int i = 0; i < d->channelCount; ++i) {
1445 d->channels[i].proxyAuthenticator.setUser(d->networkProxy.user());
1446 d->channels[i].proxyAuthenticator.setPassword(d->networkProxy.password());
1613 QHttpNetworkReply *reply;
1614 if ((connectionType == QHttpNetworkConnection::ConnectionTypeHTTP2
1615 && (chan->switchedToHttp2 || chan->h2RequestsToSend.size() > 0))
1616 || connectionType == QHttpNetworkConnection::ConnectionTypeHTTP2Direct) {
1620 Q_ASSERT(chan->h2RequestsToSend.size() > 0);
1621 reply = chan->h2RequestsToSend.cbegin().value().second;
1627 emit reply->proxyAuthenticationRequired(proxy, auth);
1629 int i = indexOf(chan->socket);
1630 copyCredentials(i, auth,
true);