8# include <QtNetwork/qsslkey.h>
9# include <QtNetwork/qsslcipher.h>
10# include <QtNetwork/qsslconfiguration.h>
13#include <private/qdecompresshelper_p.h>
28 d->connection->d_func()->removeReply(
this);
44 return d_func()->redirectUrl;
61 return d_func()->contentLength();
72 return d_func()->parser.headers();
77 return d_func()->headerField(
name, defaultValue);
100 return d_func()->request;
112 return d_func()->parser.getStatusCode();
118 d->parser.setStatusCode(code);
123 return d_func()->errorString;
128 return d_func()->httpErrorCode;
133 return d_func()->parser.getReasonPhrase();
138 d_func()->parser.setReasonPhrase(reason);
149 return d_func()->parser.getMajorVersion();
154 return d_func()->parser.getMinorVersion();
159 d_func()->parser.setMajorVersion(version);
164 d_func()->parser.setMinorVersion(version);
171 return d->connection->d_func()->uncompressedBytesAvailable(*
this);
180 return d->connection->d_func()->uncompressedBytesAvailableNextBlock(*
this);
188 return (
d->responseData.bufferCount() > 0);
194 if (
d->responseData.bufferCount() == 0)
198 if (
d->downstreamLimited &&
d->responseData.bufferCount() == 1 && !
isFinished())
199 d->connection->d_func()->readMoreLater(
this);
200 return d->responseData.read();
206 return d->responseData.readAll();
212 return d->responseData.read(amount);
219 return d->responseData.sizeNextBlock();
225 d->downstreamLimited = dsl;
226 d->connection->d_func()->readMoreLater(
this);
232 d->readBufferMaxSize =
size;
238 return !
d->isChunked() && !
d->autoDecompress &&
239 d->bodyLength > 0 &&
d->parser.getStatusCode() == 200;
246 d->userProvidedDownloadBuffer =
b;
252 return d->userProvidedDownloadBuffer;
273 return d_func()->pipeliningUsed;
278 return d_func()->h2Used;
283 d_func()->h2Used = h2;
288 return d_func()->removedContentLength;
293 return d_func()->isRedirecting();
298 return d_func()->connection;
304 ,
state(NothingDoneState)
306 bodyLength(0), contentRead(0), totalProgress(0),
307 chunkedTransferEncoding(
false),
308 connectionCloseEnabled(true),
309 forceConnectionCloseEnabled(
false),
310 lastChunkRead(
false),
311 currentChunkSize(0), currentChunkRead(0), readBufferMaxSize(0),
312 totallyUploadedData(0),
313 removedContentLength(-1),
315 autoDecompress(
false), responseData(), requestIsPrepared(
false)
317 ,userProvidedDownloadBuffer(
nullptr)
320 QString scheme = newUrl.scheme();
321 if (scheme ==
"preconnect-http"_L1 || scheme ==
"preconnect-https"_L1)
364 return d->isCompressed();
373 bool parseOk =
false;
396 else if (haveRead == 0)
398 else if (haveRead == 1 &&
fragment.
size() == 0 && (
c == 11 ||
c ==
'\n' ||
c ==
'\r' ||
c ==
' ' ||
c == 31))
425 }
while (haveRead == 1);
446 bool allHeaders =
false;
453 }
else if (haveRead == -1) {
474 }
while (!allHeaders && haveRead > 0);
524 if (haveRead == -1) {
551 if (haveRead == -1) {
600 while (toBeRead > 0) {
602 byteData.
resize(toBeRead);
610 byteData.
resize(haveRead);
611 out->append(byteData);
660 if ((haveRead == 2 && crlf[0] ==
'\r' && crlf[1] ==
'\n') || (haveRead == 1 && crlf[0] ==
'\n'))
662 else if (haveRead == 1 && crlf[0] ==
'\r')
664 else if (haveRead > 0) {
696 if ((fragmentSize && sniffedBytes == 2 && crlf[0] ==
'\r' && crlf[1] ==
'\n')
705 *chunkSize = fragmentView.toLong(&
ok, 16);
742 if ((statusCode >= 100 && statusCode < 200)
743 || statusCode == 204 || statusCode == 304)
748 if (expectedContentLength == 0)
750 if (expectedContentLength == -1 &&
bodyLength == 0) {
771 if (!
d->connectionChannel)
774 QSslSocket *sslSocket = qobject_cast<QSslSocket*>(
d->connectionChannel->socket);
778 return sslSocket->sslConfiguration();
785 d->connection->setSslConfiguration(
config);
792 d->connection->ignoreSslErrors();
799 d->connection->ignoreSslErrors(errors);
808#include "moc_qhttpnetworkreply_p.cpp"
qint64 bytesAvailable() const override
Returns the number of incoming bytes that are waiting to be read.
constexpr QByteArrayView mid(qsizetype pos, qsizetype n=-1) const
char * data()
\macro QT_NO_CAST_FROM_BYTEARRAY
bool endsWith(char c) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
qsizetype size() const noexcept
Returns the number of bytes in this byte array.
void reserve(qsizetype size)
Attempts to allocate memory for at least size bytes.
qsizetype indexOf(char c, qsizetype from=0) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
void truncate(qsizetype pos)
Truncates the byte array at index position pos.
bool startsWith(QByteArrayView bv) const
bool contains(char c) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
bool isEmpty() const noexcept
Returns true if the byte array has size 0; otherwise returns false.
void clear()
Clears the contents of the byte array and makes it null.
QByteArray toLower() const &
void resize(qsizetype size)
Sets the size of the byte array to size bytes.
QByteArray & append(char c)
This is an overloaded member function, provided for convenience. It differs from the above function o...
void append(const QByteDataBuffer &other)
static bool isSupportedEncoding(QByteArrayView encoding)
bool isConnectionCloseEnabled()
QPointer< QHttpNetworkConnection > connection
qint64 bytesAvailable() const
enum QHttpNetworkReplyPrivate::ReplyState state
bool parseStatus(QByteArrayView status)
qint64 readBody(QIODevice *socket, QByteDataBuffer *out)
~QHttpNetworkReplyPrivate()
qint64 removedContentLength
QPointer< QHttpNetworkConnectionChannel > connectionChannel
bool chunkedTransferEncoding
qint64 readHeader(QIODevice *socket)
void removeAutoDecompressHeader()
bool isRedirecting() const
bool forceConnectionCloseEnabled
QHttpNetworkReplyPrivate(const QUrl &newUrl=QUrl())
void parseHeader(QByteArrayView header)
qint64 readStatus(QIODevice *socket)
qint64 readBodyFast(QIODevice *socket, QByteDataBuffer *rb)
void clearHttpLayerInformation()
qint64 readBodyVeryFast(QIODevice *socket, char *b)
bool isCompressed() const
qint64 getChunkSize(QIODevice *in, qint64 *chunkSize)
bool connectionCloseEnabled
QHttpNetworkRequest request
qint64 readReplyBodyChunked(QIODevice *in, QByteDataBuffer *out)
void appendHeaderField(const QByteArray &name, const QByteArray &data)
qint64 readReplyBodyRaw(QIODevice *in, QByteDataBuffer *out, qint64 size)
QByteDataBuffer responseData
QHttpNetworkConnection * connection()
void setStatusCode(int code)
QByteArray headerField(QByteArrayView name, const QByteArray &defaultValue=QByteArray()) const override
void setUrl(const QUrl &url) override
QHttpHeaders header() const override
QString errorString() const
bool readAnyAvailable() const
qint64 bytesAvailableNextBlock() const
virtual ~QHttpNetworkReply()
qint64 removedContentLength() const
qint64 bytesAvailable() const
static bool isHttpRedirect(int statusCode)
QByteArray read(qint64 amount)
void setReasonPhrase(const QString &reason)
void setErrorString(const QString &error)
bool isPipeliningUsed() const
void setMajorVersion(int version)
void setUserProvidedDownloadBuffer(char *)
bool isRedirecting() const
void setHttp2WasUsed(bool h2Used)
void setReadBufferSize(qint64 size)
void setSslConfiguration(const QSslConfiguration &config)
QNetworkReply::NetworkError errorCode() const
bool supportsUserProvidedDownloadBuffer()
void setDownstreamLimited(bool t)
QHttpNetworkReply(const QUrl &url=QUrl(), QObject *parent=nullptr)
int minorVersion() const override
void setRequest(const QHttpNetworkRequest &request)
QString reasonPhrase() const
qint64 contentLength() const override
QSslConfiguration sslConfiguration() const
QHttpNetworkRequest request() const
char * userProvidedDownloadBuffer()
void setMinorVersion(int version)
void setRedirectUrl(const QUrl &url)
QUrl url() const override
void setHeaderField(const QByteArray &name, const QByteArray &data) override
void parseHeader(QByteArrayView header)
void setContentLength(qint64 length) override
void appendHeaderField(const QByteArray &name, const QByteArray &data)
bool isCompressed() const
int majorVersion() const override
bool isFollowRedirects() const
Operation operation() const
\inmodule QtCore \reentrant
qint64 peek(char *data, qint64 maxlen)
qint64 read(char *data, qint64 maxlen)
Reads at most maxSize bytes from the device into data, and returns the number of bytes read.
NetworkError
Indicates all possible error conditions found during the processing of the request.
The QSslConfiguration class holds the configuration and state of an SSL connection.
The QSslSocket class provides an SSL encrypted socket for both clients and servers.
\macro QT_RESTRICTED_CAST_FROM_ASCII
QString url(FormattingOptions options=FormattingOptions(PrettyDecoded)) const
Returns a string representation of the URL.
Combined button and popup list for selecting options.
DBusConnection const char DBusError * error
DBusConnection * connection
static QString header(const QString &name)
typedef QByteArray(EGLAPIENTRYP PFNQGSGETDISPLAYSPROC)()
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
constexpr const T & qMin(const T &a, const T &b)
GLboolean GLboolean GLboolean b
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLenum GLuint GLenum GLsizei length
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
QTextStream out(stdout)
[7]
QUrl url("example.com")
[constructor-url-reference]
QNetworkRequest request(url)