class QWebEngineHttpRequest#

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

Synopsis#

Methods#

Static functions#

Note

This documentation may contain snippets that were automatically translated from C++ to Python. We always welcome contributions to the snippet translation. If you see an issue with the translation, you can also let us know by creating a ticket on https:/bugreports.qt.io/projects/PYSIDE

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 load() and load() accept a QWebEngineHttpRequest as a parameter.

class Method#

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

Constant

Description

QWebEngineHttpRequest.Get

The GET method.

QWebEngineHttpRequest.Post

The POST method.

__init__(other)#
Parameters:

otherQWebEngineHttpRequest

Creates a copy of other.

__init__([url=QUrl()[, method=QWebEngineHttpRequest.Get]])
Parameters:

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

See also

url() setUrl()

hasHeader(headerName)#
Parameters:

headerNameQByteArray

Return type:

bool

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

header(headerName)#
Parameters:

headerNameQByteArray

Return type:

QByteArray

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() .

headers()#
Return type:

.list of QByteArray

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

method()#
Return type:

Method

Returns the method this WebEngine request is using.

See also

setMethod()

__ne__(other)#
Parameters:

otherQWebEngineHttpRequest

Return type:

bool

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

See also

operator==()

__eq__(other)#
Parameters:

otherQWebEngineHttpRequest

Return type:

bool

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

See also

operator!=()

postData()#
Return type:

QByteArray

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

See also

setPostData()

static postRequest(url, postData)#
Parameters:
  • urlQUrl

  • postData – Dictionary with keys of type .QString and values of type QString.

Return type:

QWebEngineHttpRequest

Constructs a QWebEngineHttpRequest to url that uses the POST method.

Note

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

setHeader(headerName, value)#
Parameters:

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.

setMethod(method)#
Parameters:

methodMethod

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

See also

method()

setPostData(postData)#
Parameters:

postDataQByteArray

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

See also

postData()

setUrl(url)#
Parameters:

urlQUrl

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

See also

url()

swap(other)#
Parameters:

otherQWebEngineHttpRequest

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

unsetHeader(headerName)#
Parameters:

headerNameQByteArray

Removes the header specified by key, if present.

url()#
Return type:

QUrl

Returns the URL this WebEngine request is referring to.

See also

setUrl()