This commit is contained in:
Félicien François 2015-11-21 19:42:16 +01:00
Родитель cf198db041
Коммит 1416fa9574
1 изменённых файлов: 16 добавлений и 3 удалений

Просмотреть файл

@ -1,10 +1,11 @@
electron-proxy-agent
===============
### A proxy `http.Agent` implementation for HTTP and HTTPS, made to work with [Electron](https://github.com/atom/electron) API
### A proxy `http.Agent` implementation for HTTP and HTTPS,
rewritten to work seamlessly with [Electron](https://github.com/atom/electron) API
This module provides an `http.Agent` implementation that uses the [session.resolveProxy](https://github.com/atom/electron/blob/master/docs/api/session.md#sesresolveproxyurl-callback) API of [Electron](https://github.com/atom/electron) to resolve which HTTP, HTTPS, or SOCKS proxy, or if a direct connection should be used to connect to the HTTP(S) endpoint.
It is designed to be be used with the built-in `http` and `https` modules.
It is designed to be be used with the built-in `http` and `https` modules
Installation
@ -17,9 +18,10 @@ $ npm install electron-proxy-agent --save
```
Example
Examples
-------
- Single request
``` js
var url = require('url');
var http = require('http');
@ -41,6 +43,17 @@ http.get(opts, function (res) {
});
```
- Global agent
``` js
var http = require('http');
var https = require('http');
var ElectronProxyAgent = require('electron-proxy-agent');
var session = require('session').defaultSession;
// use ElectronProxyAgent as http and https globalAgents
http.globalAgent = https.globalAgent = new ElectronProxyAgent(session);
```
Notes
-----
- Passing no or invalid parameter to the constructor would result in trying to use default session.