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 Client to use a proxy url #7

Merged
merged 1 commit into from
Sep 26, 2023
Merged

Conversation

t27duck
Copy link
Contributor

@t27duck t27duck commented Sep 23, 2023

This change adds a proxy_url option when creating the client.

If set, the Net::HTTP object will set the appropriate values and use a proxy server for the connection.

Copy link
Owner

@sferik sferik left a comment

Choose a reason for hiding this comment

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

@t27duck Thank you for submitting this pull request! Proxy support was one of the features from the twitter gem that I wanted to add here, but you beat me to it and your implementation looks great!

I left a few very minor comments, mostly related to the RBS signature file, but I’m optimistic that we can get this merged and released in version 0.9.0 this week.

Thanks so much for your contribution!

lib/x/client.rb Outdated
@@ -31,11 +31,12 @@ def initialize(bearer_token: nil,
debug_output: nil,
array_class: ResponseHandler::DEFAULT_ARRAY_CLASS,
object_class: ResponseHandler::DEFAULT_OBJECT_CLASS,
max_redirects: RedirectHandler::DEFAULT_MAX_REDIRECTS)
max_redirects: RedirectHandler::DEFAULT_MAX_REDIRECTS,
proxy_url: nil)
Copy link
Owner

Choose a reason for hiding this comment

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

Small suggestion: The order is technically irrelevant, but I would move this up to follow write_timeout, so the Connection options are all close together.

sig/x.rbs Outdated
@@ -93,10 +93,11 @@ module X
@http_client: Net::HTTP

attr_reader base_uri: URI::Generic
attr_reader proxy_uri: URI::Generic | nil
Copy link
Owner

Choose a reason for hiding this comment

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

The shorthand/syntactic sugar for this is: URI::Generic?

sig/x.rbs Outdated
attr_reader open_timeout : Float | Integer
attr_reader read_timeout : Float | Integer
attr_reader write_timeout : Float | Integer
def initialize: (?base_url: URI::Generic | String, ?open_timeout: Float | Integer, ?read_timeout: Float | Integer, ?write_timeout: Float | Integer, ?debug_output: IO?) -> void
def initialize: (?base_url: URI::Generic | String, ?open_timeout: Float | Integer, ?read_timeout: Float | Integer, ?write_timeout: Float | Integer, ?debug_output: IO?, ?proxy_url: URI::Generic | String | nil) -> void
Copy link
Owner

Choose a reason for hiding this comment

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

Same comment as above.

sig/x.rbs Outdated
@@ -168,7 +170,7 @@ module X
@response_handler: ResponseHandler

attr_reader base_uri: URI::Generic
def initialize: (?bearer_token: String?, ?api_key: String?, ?api_key_secret: String?, ?access_token: String?, ?access_token_secret: String?, ?base_url: URI::Generic | String, ?content_type: String, ?user_agent: String, ?open_timeout: Float | Integer, ?read_timeout: Float | Integer, ?write_timeout: Float | Integer, ?debug_output: IO?, ?array_class: Class, ?object_class: Class, ?max_redirects: Integer) -> void
def initialize: (?bearer_token: String?, ?api_key: String?, ?api_key_secret: String?, ?access_token: String?, ?access_token_secret: String?, ?base_url: URI::Generic | String, ?content_type: String, ?user_agent: String, ?open_timeout: Float | Integer, ?read_timeout: Float | Integer, ?write_timeout: Float | Integer, ?debug_output: IO?, ?array_class: Class, ?object_class: Class, ?max_redirects: Integer, ?proxy_url: URI::Generic | String | nil) -> void
Copy link
Owner

Choose a reason for hiding this comment

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

Same comment as above.

@sferik
Copy link
Owner

sferik commented Sep 25, 2023

PS: Don’t worry about the failing checks. They were caused by an update to the rubocop-minitest gem that was just released yesterday. It’s already fixed in the main branch, so the checks will pass after the pull request is merged.

This change adds a `proxy_url` option when creating the client.

If set, the `Net::HTTP` object will set the appropriate values and use a proxy server for the connection.
@t27duck t27duck force-pushed the proxy_server_option branch from ad74a98 to 6a2618b Compare September 26, 2023 00:35
@t27duck
Copy link
Contributor Author

t27duck commented Sep 26, 2023

Changes suggestions should be applied now.

Copy link
Owner

@sferik sferik left a comment

Choose a reason for hiding this comment

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

This looks perfect now! Thanks so much for your contribution!

@sferik sferik closed this Sep 26, 2023
@sferik sferik reopened this Sep 26, 2023
@sferik sferik merged commit 3740f4f into sferik:main Sep 26, 2023
@t27duck t27duck deleted the proxy_server_option branch September 26, 2023 10:39
@sferik
Copy link
Owner

sferik commented Sep 26, 2023

Just release version 0.9.0 with proxy support. Thanks again for your patch!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants