QWebEngineHttpRequest Class

The QWebEngineHttpRequest class holds a request to be sent with WebEngine. More...

Header: #include <QWebEngineHttpRequest>
Since: Qt 5.9

This class was introduced in Qt 5.9.

Public Types

enum Method { Get, Post }

Public Functions

QWebEngineHttpRequest(const QWebEngineHttpRequest &other)
QWebEngineHttpRequest(const QUrl &url = QUrl(), const QWebEngineHttpRequest::Method &method = QWebEngineHttpRequest::Get)
QWebEngineHttpRequest &operator=(const QWebEngineHttpRequest &other)
~QWebEngineHttpRequest()
bool hasHeader(const QByteArray &headerName) const
QByteArray header(const QByteArray &headerName) const
QVector<QByteArray> headers() const
QWebEngineHttpRequest::Method method() const
QByteArray postData() const
void setHeader(const QByteArray &headerName, const QByteArray &headerValue)
void setMethod(QWebEngineHttpRequest::Method method)
void setPostData(const QByteArray &postData)
void setUrl(const QUrl &url)
void swap(QWebEngineHttpRequest &other)
void unsetHeader(const QByteArray &key)
QUrl url() const
bool operator!=(const QWebEngineHttpRequest &other) const
bool operator==(const QWebEngineHttpRequest &other) const

Static Public Members

QWebEngineHttpRequest postRequest(const QUrl &url, const QMap<QString, QString> &postData)

Detailed Description

QWebEngineHttpRequest represents an HTTP request in the WebEngine networking stack. It holds the information necessary to send a request over the network. It contains a URL and some ancillary information that can be used to modify the request. Both QWebEnginePage::load() and QWebEngineView::load() accept a QWebEngineHttpRequest as a parameter.

Member Type Documentation

enum QWebEngineHttpRequest::Method

This enum type describes the method used to send the HTTP request:

ConstantValueDescription
QWebEngineHttpRequest::Get0The GET method.
QWebEngineHttpRequest::Post1The POST method.

Member Function Documentation

QWebEngineHttpRequest::QWebEngineHttpRequest(const QWebEngineHttpRequest &other)

Creates a copy of other.

QWebEngineHttpRequest::QWebEngineHttpRequest(const QUrl &url = QUrl(), const QWebEngineHttpRequest::Method &method = QWebEngineHttpRequest::Get)

Constructs a QWebEngineHttpRequest object with url as the URL to be requested and method as the method to be used.

See also url() and setUrl().

QWebEngineHttpRequest &QWebEngineHttpRequest::operator=(const QWebEngineHttpRequest &other)

Creates a copy of other.

QWebEngineHttpRequest::~QWebEngineHttpRequest()

Disposes of the QWebEngineHttpRequest object.

bool QWebEngineHttpRequest::hasHeader(const QByteArray &headerName) const

Returns true if the header headerName is present in this WebEngine request.

See also setHeader(), header(), unsetHeader(), and headers().

Returns the header specified by headerName. If no such header is present, an empty QByteArray is returned, which may be indistinguishable from a header that is present but has no content (use hasHeader() to find out if the header exists or not).

Headers can be set with setHeader().

See also setHeader(), hasHeader(), unsetHeader(), and headers().

QVector<QByteArray> QWebEngineHttpRequest::headers() const

Returns a list of all headers that are set in this WebEngine request. The list is in the order that the headers were set.

See also setHeader(), header(), hasHeader(), and unsetHeader().

QWebEngineHttpRequest::Method QWebEngineHttpRequest::method() const

Returns the method this WebEngine request is using.

See also setMethod().

QByteArray QWebEngineHttpRequest::postData() const

Returns the (raw) POST data this WebEngine request contains.

See also setPostData().

[static] QWebEngineHttpRequest QWebEngineHttpRequest::postRequest(const QUrl &url, const QMap<QString, QString> &postData)

Constructs a QWebEngineHttpRequest to url that uses the POST method.

Note: postData may contain arbitrary strings. They are translated to appropriate raw data.

See also postData and setPostData().

void QWebEngineHttpRequest::setHeader(const QByteArray &headerName, const QByteArray &headerValue)

Sets the header headerName to be of value headerValue.

Note: Setting the same header twice overrides the previous setting. To accomplish the behavior of multiple HTTP headers of the same name, you should concatenate the two values, separating them with a comma (",") and set one single header.

See also header(), hasHeader(), unsetHeader(), and headers().

void QWebEngineHttpRequest::setMethod(QWebEngineHttpRequest::Method method)

Sets the method this WebEngine request is using to be method.

See also method().

void QWebEngineHttpRequest::setPostData(const QByteArray &postData)

Sets the (raw) POST data this WebEngine request contains to be postData.

See also postData().

void QWebEngineHttpRequest::setUrl(const QUrl &url)

Sets the URL this WebEngine request is referring to be url.

See also url().

void QWebEngineHttpRequest::swap(QWebEngineHttpRequest &other)

Swaps this WebEngine request with other. This function is very fast and never fails.

void QWebEngineHttpRequest::unsetHeader(const QByteArray &key)

Removes the header specified by key, if present.

See also setHeader(), header(), hasHeader(), and headers().

QUrl QWebEngineHttpRequest::url() const

Returns the URL this WebEngine request is referring to.

See also setUrl().

bool QWebEngineHttpRequest::operator!=(const QWebEngineHttpRequest &other) const

Returns false if this object is not the same as other.

See also operator==().

bool QWebEngineHttpRequest::operator==(const QWebEngineHttpRequest &other) const

Returns true if this object is the same as other (that is, if they have the same method, URL, and headers).

See also operator!=().

© 2024 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.