QWebEngineHttpRequest Class
The QWebEngineHttpRequest class holds a request to be sent with WebEngine. 更多...
头文件: | #include <QWebEngineHttpRequest> |
开始支持版本: | Qt 5.9 |
公有类型
enum | Method { Get, Post } |
公有函数
QWebEngineHttpRequest(const QUrl &url = QUrl(), const QWebEngineHttpRequest::Method &method = QWebEngineHttpRequest::Get) | |
QWebEngineHttpRequest(const QWebEngineHttpRequest &other) | |
~QWebEngineHttpRequest() | |
bool | hasHeader(const QByteArray &headerName) const |
QByteArray | header(const QByteArray &headerName) const |
QVector<QByteArray> | headers() const |
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 |
QWebEngineHttpRequest & | operator=(QWebEngineHttpRequest &&other) |
QWebEngineHttpRequest & | operator=(const QWebEngineHttpRequest &other) |
bool | operator==(const QWebEngineHttpRequest &other) const |
静态公有成员
QWebEngineHttpRequest | postRequest(const QUrl &url, const QMap<QString, QString> &postData) |
详细描述
The QWebEngineHttpRequest class holds a request to be sent with WebEngine.
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.
成员类型
enum QWebEngineHttpRequest::Method
This enum type describes the method used to send the HTTP request:
Constant | Value | Description |
---|---|---|
QWebEngineHttpRequest::Get | 0 | The GET method. |
QWebEngineHttpRequest::Post | 1 | The POST method. |
成员函数
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.
QWebEngineHttpRequest::QWebEngineHttpRequest(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.
参见 setHeader(), header(), unsetHeader(), and headers().
QByteArray QWebEngineHttpRequest::header(const QByteArray &headerName) const
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().
参见 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.
参见 setHeader(), header(), hasHeader(), and unsetHeader().
Method QWebEngineHttpRequest::method() const
Returns the method this WebEngine request is using.
参见 setMethod().
QByteArray QWebEngineHttpRequest::postData() const
Returns the (raw) POST data this WebEngine request contains.
参见 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.
参见 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.
参见 header(), hasHeader(), unsetHeader(), and headers().
void QWebEngineHttpRequest::setMethod(QWebEngineHttpRequest::Method method)
Sets the method this WebEngine request is using to be method.
参见 method().
void QWebEngineHttpRequest::setPostData(const QByteArray &postData)
Sets the (raw) POST data this WebEngine request contains to be postData.
参见 postData().
void QWebEngineHttpRequest::setUrl(const QUrl &url)
Sets the URL this WebEngine request is referring to be url.
参见 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.
参见 setHeader(), header(), hasHeader(), and headers().
QUrl QWebEngineHttpRequest::url() const
Returns the URL this WebEngine request is referring to.
参见 setUrl().
bool QWebEngineHttpRequest::operator!=(const QWebEngineHttpRequest &other) const
Returns false
if this object is not the same as other.
参见 operator==().
QWebEngineHttpRequest &QWebEngineHttpRequest::operator=(QWebEngineHttpRequest &&other)
Move-assignment operator.
QWebEngineHttpRequest &QWebEngineHttpRequest::operator=(const QWebEngineHttpRequest &other)
Creates a copy of other.
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).
参见 operator!=().