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

Allow configuring RequestHandler to use HTTP instead of HTTPS #1193

Open
wants to merge 4 commits into
base: dev
Choose a base branch
from

Conversation

molenzwiebel
Copy link

My use case was to tunnel all Eris traffic through a central rate limiter (Twilight's http-proxy), which uses HTTP instead of HTTPS. Given that we can already configure the domain and base URL, being able to configure whether to use HTTPS or HTTP seemed logical.

I've named it https and enabled it by default, to ensure concious opt-out by doing https: false. A name like useHttps might be more appropriate.

Could also consider storing the request method (https or http module) as an instance variable on RequestHandler instead of doing the ternary on each request, but I figured this'd be fine.

JSDoc and TypeScript typings should be good.

@abalabahaha abalabahaha changed the base branch from master to dev May 1, 2021 19:33
@tbnritzdoge
Copy link

Should we not just take the protocol from the rest URL provided?

@molenzwiebel
Copy link
Author

The domain doesn't have a protocol prefixed. Using it would probably be neater, but it would break backwards compat.

@@ -109,11 +109,12 @@ class Client extends EventEmitter {
* @arg {Function} [options.reconnectDelay] A function which returns how long the bot should wait until reconnecting to Discord.
* @arg {Number} [options.requestTimeout=15000] A number of milliseconds before requests are considered timed out. This option will stop affecting REST in a future release; that behavior is [DEPRECATED] and replaced by `options.rest.requestTimeout`
* @arg {Object} [options.rest] Options for the REST request handler
* @arg {Object} [options.rest.agent] A HTTPS Agent used to proxy requests
* @arg {Object} [options.rest.agent] A HTTPS Agent (if https: true, default) or an HTTP agent (if https: false) used to proxy requests
Copy link
Contributor

@DonovanDMC DonovanDMC Jun 8, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* @arg {Object} [options.rest.agent] A HTTPS Agent (if https: true, default) or an HTTP agent (if https: false) used to proxy requests
* @arg {Object} [options.rest.agent] An HTTP Agent used to proxy requests

this would probably be better said as HTTP Agent, noting that difference doesn't seem that important (and if you want to argue for it, HTTP/S could be used instead of those distinctions)

Copy link
Collaborator

@bsian03 bsian03 Jan 7, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* @arg {Object} [options.rest.agent] A HTTPS Agent (if https: true, default) or an HTTP agent (if https: false) used to proxy requests
* @arg {Object} [options.rest.agent] A HTTP/S Agent used to proxy requests

DonovanDMC added a commit to DonovanArchive/ErisPRUpdateBot that referenced this pull request Jul 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants