QWebEngineUrlRequestInfo — PyQt Documentation v6.9.0 (original) (raw)
PyQt6.QtWebEngineCore.QWebEngineUrlRequestInfo
Description¶
The QWebEngineUrlRequestInfo class provides information about URL requests.
The QWebEngineUrlRequestInfo is useful for setting extra header fields for requests or for redirecting certain requests without payload data to another URL. This class cannot be instantiated or copied by the user, instead it will be created by Qt WebEngine and sent through the virtual function interceptRequest() if an interceptor has been set.
Enums¶
NavigationType
This enum type describes the navigation type of the request:
Member | Value | Description |
---|---|---|
NavigationTypeBackForward | 3 | Navigation initiated by a history action. |
NavigationTypeFormSubmitted | 2 | Navigation submits a form. |
NavigationTypeLink | 0 | Navigation initiated by clicking a link. |
NavigationTypeOther | 5 | None of the above. |
NavigationTypeRedirect | 6 | Navigation triggered automatically by page content or remote server. (Added in Qt 5.14) |
NavigationTypeReload | 4 | Navigation initiated by refreshing the page. |
NavigationTypeTyped | 1 | Navigation explicitly initiated by typing a URL. |
ResourceType
This enum type holds the type of the requested resource:
Note: For forward compatibility all values not matched should be treated as unknown, not just ResourceTypeUnknown
.
Member | Value | Description |
---|---|---|
ResourceTypeCspReport | 16 | A report of Content Security Policy (CSP) violations. CSP reports are in JSON format and they are delivered by HTTP POST requests to specified servers. (Added in Qt 5.7) |
ResourceTypeFavicon | 12 | A favicon. |
ResourceTypeFontResource | 5 | A font. |
ResourceTypeImage | 4 | An image (JPG, GIF, PNG, and so on). |
ResourceTypeJson | 21 | A JSON module. (Added in Qt 6.8) |
ResourceTypeMainFrame | 0 | Top level page. |
ResourceTypeMedia | 8 | A media resource. |
ResourceTypeNavigationPreloadMainFrame | 19 | A main-frame service worker navigation preload request. (Added in Qt 5.14) |
ResourceTypeNavigationPreloadSubFrame | 20 | A sub-frame service worker navigation preload request. (Added in Qt 5.14) |
ResourceTypeObject | 7 | An object (or embed) tag for a plugin or a resource that a plugin requested. |
ResourceTypePing | 14 | A ping request for . |
ResourceTypePluginResource | 17 | A resource requested by a plugin. (Added in Qt 5.7) |
ResourceTypePrefetch | 11 | An explicitly requested prefetch. |
ResourceTypeScript | 3 | An external script. |
ResourceTypeServiceWorker | 15 | The main resource of a service worker. |
ResourceTypeSharedWorker | 10 | The main resource of a shared worker. |
ResourceTypeStylesheet | 2 | A CSS stylesheet. |
ResourceTypeSubFrame | 1 | Frame or iframe. |
ResourceTypeSubResource | 6 | An “other” subresource. |
ResourceTypeUnknown | 255 | Unknown request type. |
ResourceTypeWebSocket | 254 | A WebSocket request. (Added in Qt 6.4) |
ResourceTypeWorker | 9 | The main resource of a dedicated worker. |
ResourceTypeXhr | 13 | An XMLHttpRequest. |
Methods¶
block(bool)
Blocks this request if shouldBlock is true, so that it will not proceed.
This function can be used to prevent navigating away from a given domain, for example.
firstPartyUrl() → QUrl
Returns the first party URL of the request. The first party URL is the URL of the page that issued the request.
Returns the request headers.
Note: Not all headers are visible at this stage as Chromium will add security and proxy headers at a later stage.
initiator() → QUrl
Returns the origin URL of the document that initiated the navigation of a frame to another frame.
isDownload() → bool
TODO
navigationType() → NavigationType
Returns the navigation type of the request.
redirect(QUrl)
Redirects this request to url. It is only possible to redirect requests that do not have payload data, such as GET requests.
requestBody() → QIODevice
Returns a pointer to a QIODevice that gives access to the request body. The request body can contain data for example when the request is a POST request. If the request body is empty the QIODevice reflects this and does not return any data when performing read operations on it.
requestMethod() → QByteArray
Returns the HTTP method of the request (for example, GET or POST).
requestUrl() → QUrl
Returns the requested URL.
resourceType() → ResourceType
Returns the resource type of the request.
Sets the request header name to value for this request.