feat: HTTP preconnect feature minimal for electronjs (#18671)

This commit is contained in:
Kuts Alexey 2019-08-26 19:47:32 +03:00 committed by Jeremy Apthorp
parent c57db7f163
commit cddbddc543
17 changed files with 377 additions and 1 deletions

View file

@ -91,6 +91,20 @@ session.defaultSession.on('will-download', (event, item, webContents) => {
})
```
#### Event: 'preconnect'
Returns:
* `event` Event
* `preconnectUrl` String - The URL being requested for preconnection by the
renderer.
* `allowCredentials` Boolean - True if the renderer is requesting that the
connection include credentials (see the
[spec](https://w3c.github.io/resource-hints/#preconnect) for more details.)
Emitted when a render process requests preconnection to a URL, generally due to
a [resource hint](https://w3c.github.io/resource-hints/).
### Instance Methods
The following methods are available on instances of `Session`:
@ -238,6 +252,14 @@ window.webContents.session.enableNetworkEmulation({
window.webContents.session.enableNetworkEmulation({ offline: true })
```
#### `ses.preconnect(options)`
* `options` Object
* `url` String - URL for preconnect. Only the origin is relevant for opening the socket.
* `numSockets` Number (optional) - number of sockets to preconnect. Must be between 1 and 6. Defaults to 1.
Preconnects the given number of sockets to an origin.
#### `ses.disableNetworkEmulation()`
Disables any network emulation already active for the `session`. Resets to