Browse Source

Add ability to opt-out of using `electron.net`

And support using it in the renderer process => #314
remove-strictssl-option
Sindre Sorhus 8 years ago
parent
commit
6fc1902805
  1. 8
      index.js
  2. 8
      readme.md

8
index.js

@ -40,8 +40,9 @@ function requestAsEventEmitter(opts) {
let fn = opts.protocol === 'https:' ? https : http;
if (process.versions.electron) {
fn = require('electron').net;
if (opts.useElectronNet && process.versions.electron) {
const electron = require('electron');
fn = electron.net || electron.remote.net;
}
const req = fn.request(opts, res => {
@ -278,7 +279,8 @@ function normalizeArguments(url, opts) {
opts = Object.assign(
{
path: '',
retries: 2
retries: 2,
useElectronNet: true
},
url,
{

8
readme.md

@ -152,6 +152,14 @@ Defines if redirect responses should be followed automatically.
Note that if a `303` is sent by the server in response to any request type (`POST`, `DELETE`, etc.), got will automatically
request the resource pointed to in the location header via `GET`. This is in accordance with [the spec](https://tools.ietf.org/html/rfc7231#section-6.4.4).
###### useElectronNet
Type: `boolean`<br>
Default: `true`
When used in Electron, Got will automatically use [`electron.net`](https://electron.atom.io/docs/api/net/) instead of the Node.js `http` module. It should be fully compatible, but you can turn it off here if you encounter a problem. Please open an issue if you do!
#### Streams
#### got.stream(url, [options])

Loading…
Cancel
Save