PySide6.QtWebEngineCore.QWebEngineUrlScheme¶
- class QWebEngineUrlScheme¶
- The - QWebEngineUrlSchemeclass configures a custom URL scheme.- Details- A web engine URL scheme describes a URL scheme from the web engine’s perspective, specifying how URLs of this scheme should be parsed, and which security restrictions should be placed on resources originating from such URLs. - Custom URL schemes must be configured early at application startup, before creating any Qt WebEngine classes. In general this means the schemes need to be configured before a QGuiApplication or QApplication instance is created. - Every registered scheme configuration applies globally to all profiles. - int main(int argc, char **argv) { QWebEngineUrlScheme scheme("myscheme"); scheme.setSyntax(QWebEngineUrlScheme::Syntax::HostAndPort); scheme.setDefaultPort(2345); scheme.setFlags(QWebEngineUrlScheme::SecureScheme); QWebEngineUrlScheme::registerScheme(scheme); ... } - To actually make use of the custom URL scheme, a - QWebEngineUrlSchemeHandlermust be created and registered in a profile.- See also - Synopsis¶- Methods¶- def - __init__()
- def - defaultPort()
- def - flags()
- def - name()
- def - __ne__()
- def - __eq__()
- def - setDefaultPort()
- def - setFlags()
- def - setName()
- def - setSyntax()
- def - syntax()
 - Static functions¶- def - registerScheme()
- def - schemeByName()
 - 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 - class Syntax¶
- This enum type lists types of URL syntax. - To apply the same-origin policy to a custom URL scheme, WebEngine must be able to compute the origin (host and port combination) of a URL. The - Host...options indicate that the URL scheme conforms to the standard URL syntax (like- http) and automatically enable the same-origin policy. The- Pathoption indicates that the URL scheme uses a non-standard syntax and that the same-origin policy cannot be applied.- Constant - Description - QWebEngineUrlScheme.Syntax.Syntax.HostPortAndUserInformation - The authority component of a URL of this type has all of the standard elements: host, port, user name, and password. A URL without a port will use the - defaultPort(which must not be- PortUnspecified).- QWebEngineUrlScheme.Syntax.Syntax.HostAndPort - The authority component of a URL of this type has only the host and port elements. A URL without a port will use the - defaultPort(which must not be- PortUnspecified).- QWebEngineUrlScheme.Syntax.Syntax.Host - The authority component of a URL of this type has only the host part and no port. The - defaultPortmust be set to- PortUnspecified.- QWebEngineUrlScheme.Syntax.Syntax.Path - A URL of this type has no authority component at all. Everything after scheme name and separator character (:) will be preserved as is without validation or canonicalization. All URLs of such a scheme will be considered as having the same origin (unless the - NoAccessAllowedflag is used).
 - class SpecialPort¶
- This enum type defines special values for - defaultPort.- Constant - Description - QWebEngineUrlScheme.SpecialPort.PortUnspecified - Indicates that the URL scheme does not have a port element. 
 - class Flag¶
- (inherits - enum.Flag) This enum type specifies security options that should apply to a URL scheme.- Constant - Description - QWebEngineUrlScheme.Flag.SecureScheme - Indicates that the URL scheme is potentially trustworthy . This flag should only be applied to URL schemes which ensure data authenticity, confidentiality, and integrity, either through encryption or other means. Examples of secure builtin schemes include - https(authenticated and encrypted) and- qrc(local resources only), whereas- httpis an example of an insecure scheme.- QWebEngineUrlScheme.Flag.LocalScheme - Indicates that the URL scheme provides access to local resources. The purpose of this flag is to prevent network content from accessing local resources. Only schemes with the - LocalAccessAllowedflag may load resources from a scheme with the- LocalSchemeflag. The only builtin scheme with this flag is- file.- QWebEngineUrlScheme.Flag.LocalAccessAllowed - Indicates that content from this scheme should be allowed to load resources from schemes with the - LocalSchemeflag.- QWebEngineUrlScheme.Flag.NoAccessAllowed - Indicates that all content from this scheme should be forced to have unique opaque origins: no two resources will have the same origin. - QWebEngineUrlScheme.Flag.ServiceWorkersAllowed - Indicates that the Service Workers API should be enabled. - QWebEngineUrlScheme.Flag.ViewSourceAllowed - Indicates that the View Source feature should be enabled. - QWebEngineUrlScheme.Flag.ContentSecurityPolicyIgnored - Indicates that accesses to this scheme should bypass all Content-Security-Policy checks. - QWebEngineUrlScheme.Flag.CorsEnabled - Enables cross-origin resource sharing (CORS) for this scheme. This flag is required in order for content to be loaded by documents of a different origin, this includes access from other schemes. The appropriate CORS headers are generated automatically by the - QWebEngineUrlRequestJobclass. By default only- httpand- httpsare CORS enabled. (Added in Qt 5.14)- QWebEngineUrlScheme.Flag.FetchApiAllowed - Enables a URL scheme to be used by the HTML5 fetch API and - XMLHttpRequest.sendwith a body. By default only- httpand- httpscan be send to using the Fetch API or with an XMLHttpRequest with a body.
 - __init__()¶
 - Constructs a web engine URL scheme with default values. - __init__(name)
- Parameters:
- name – - QByteArray
 
 - Constructs a web engine URL scheme with given - name.- __init__(that)
- Parameters:
- that – - QWebEngineUrlScheme
 
 - Copies - that.- defaultPort()¶
- Return type:
- int 
 
 - Returns the default port of this URL scheme. - The default value is - PortUnspecified.- See also - Returns the flags for this URL scheme. - The default value is an empty set of flags. - See also - Flags- setFlags()- name()¶
- Return type:
 
 - Returns the name of this URL scheme. - The default value is an empty string. - See also - __ne__(that)¶
- Parameters:
- that – - QWebEngineUrlScheme
- Return type:
- bool 
 
 - Returns - trueif this and- thatobject are not equal.- __eq__(that)¶
- Parameters:
- that – - QWebEngineUrlScheme
- Return type:
- bool 
 
 - Returns - trueif this and- thatobject are equal.- static registerScheme(scheme)¶
- Parameters:
- scheme – - QWebEngineUrlScheme
 
 - Registers - schemewith the web engine’s URL parser and security model.- It is recommended that all custom URL schemes are first registered with this function at application startup, even if the default options are to be used. - Warning - This function must be called early at application startup, before creating any WebEngine classes. Late calls will be ignored. - See also - static schemeByName(name)¶
- Parameters:
- name – - QByteArray
- Return type:
 
 - Returns the web engine URL scheme with the given - nameor the default-constructed scheme.- See also - setDefaultPort(newValue)¶
- Parameters:
- newValue – int 
 
 - Sets the default port of this URL scheme to - newValue.- See also - Sets the flags for this URL scheme to - newValue.- See also - Flags- flags()- setName(newValue)¶
- Parameters:
- newValue – - QByteArray
 
 - Sets the name of this URL scheme to - newValue.- Sets the syntax type of this URL scheme to - newValue.- Returns the syntax type of this URL scheme. - The default value is - Path.- See also