Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replaced proxy option with agent #259

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ list.members('[email protected]').delete(function (err, data) {
* `publicApiKey` - Your public Mailgun API KEY
* `domain` - Your Mailgun Domain (Please note: domain field is `MY-DOMAIN-NAME.com`, not https://api.mailgun.net/v3/MY-DOMAIN-NAME.com)
* `mute` - Set to `true` if you wish to mute the console error logs in `validateWebhook()` function
* `proxy` - The proxy URI in format `http[s]://[auth@]host:port`. ex: `'http://proxy.example.com:8080'`
* `agent` - The [Agent](https://nodejs.org/docs/latest-v10.x/api/http.html#http_class_http_agent) to use - see [request](https://nodejs.org/docs/latest-v10.x/api/http.html#http_http_request_options_callback) options for the provided values. **Note** When providing an `agent` it must be able to handle the provided (or default) `protocol`.
* `timeout` - Request timeout in milliseconds
* `host` - the mailgun host (default: 'api.mailgun.net'). Note that if you are using the EU region the host should be set to 'api.eu.mailgun.net'
* `protocol` - the mailgun protocol (default: 'https:', possible values: 'http:' or 'https:')
Expand Down
2 changes: 1 addition & 1 deletion docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ list.members('[email protected]').update({ name: 'Foo Bar' }, function (err, body) {
* `publicApiKey` - Your public Mailgun API KEY
* `domain` - Your Mailgun Domain (Please note: domain field is `MY-DOMAIN-NAME.com`, not https://api.mailgun.net/v3/MY-DOMAIN-NAME.com)
* `mute` - Set to `true` if you wish to mute the console error logs in `validateWebhook()` function
* `proxy` - The proxy URI in format `http[s]://[auth@]host:port`. ex: `'http://proxy.example.com:8080'`
* `agent` - The [Agent](https://nodejs.org/docs/latest-v10.x/api/http.html#http_class_http_agent) to use - see [request](https://nodejs.org/docs/latest-v10.x/api/http.html#http_http_request_options_callback) options for the provided values. **Note** When providing an `agent` it must be able to handle the provided (or default) `protocol`.
* `timeout` - Request timeout in milliseconds
* `host` - the mailgun host (default: 'api.mailgun.net')
* `protocol` - the mailgun protocol (default: 'https:', possible values: 'http:' or 'https:')
Expand Down
6 changes: 2 additions & 4 deletions lib/mailgun.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,15 @@ class Mailgun {
this.testMode = options.testMode
this.testModeLogger = options.testModeLogger

if (options.proxy) {
this.proxy = options.proxy
}
this.agent = options.agent

this.options = {
host: this.host,
endpoint: this.endpoint,
protocol: this.protocol,
port: this.port,
auth: this.auth,
proxy: this.proxy,
agent: this.agent,
timeout: this.timeout,
retry: this.retry,
testMode: this.testMode,
Expand Down
9 changes: 2 additions & 7 deletions lib/request.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
const https = require('https')
const http = require('http')
const ProxyAgent = require('proxy-agent')
const qs = require('querystring')
const fs = require('fs')
const Readable = require('stream').Readable
Expand Down Expand Up @@ -60,7 +59,7 @@ class Request {
this.port = options.port
this.endpoint = options.endpoint
this.auth = options.auth
this.proxy = options.proxy
this.agent = options.agent
this.timeout = options.timeout
this.retry = options.retry || 1
this.testMode = options.testMode
Expand Down Expand Up @@ -124,14 +123,10 @@ class Request {
method,
'headers': this.headers,
'auth': this.auth,
'agent': false,
'agent': this.agent,
'timeout': this.timeout
}

if (this.proxy) {
opts.agent = new ProxyAgent(this.proxy)
}

if (this.testMode) {
this.testModeLogger(opts, this.payload, this.form)
return fn()
Expand Down
Loading