Skip to content

Conversation

@MhRantz
Copy link
Contributor

@MhRantz MhRantz commented Oct 20, 2025

Allow for setting default headers beyond agent_name adding customization

Note: Looks like changelog.txt is not is use, but happy to update.

@MhRantz
Copy link
Contributor Author

MhRantz commented Oct 23, 2025

@zentourist Hey Dan, any thoughts on this change?

@zentourist
Copy link
Member

@zentourist Hey Dan, any thoughts on this change?

Hey @MhRantz - I'm out of the office until next week. Let me have a look when I'm back. ✌️

Copy link
Member

@zentourist zentourist left a comment

Choose a reason for hiding this comment

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

Logically it looks good, but I think we can clean it up a bit and allow for easier future extensions.

I no longer have access to Exchange and don't write much Ruby these days, so you'll want to give it a whirl, but this should work.

# @option opts [String] :user_agent the http user agent to use in all requests
def initialize(endpoint, opts = {})
@log = Logging.logger[self.class.name.to_s.to_sym]
if opts[:user_agent]
Copy link
Member

Choose a reason for hiding this comment

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

I think to properly support both options, you'll want to filter the supported opts and pass them all in at once. As it is written, if you send in a :user_agent opt and a :default_header opt, only the :default_header will be applied. I would suggest something like the following:

Add a class var to the top of the Connection class:

@@supported_httpclient_opts = %i[agent_name default_header]

Then remove the if/elseif/else statement in favor of this:

httpclient_opts = opts.slice(@@supported_httpclient_opts)
@httpcli = HTTPClient.new(**httpclient_opts)

Copy link
Member

@zentourist zentourist left a comment

Choose a reason for hiding this comment

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

Thanks @MhRantz!

@zentourist zentourist merged commit 3c97b4c into WinRb:main Oct 28, 2025
5 checks passed
@zentourist
Copy link
Member

@MhRantz - I published this gem as 1.2.0 because there was a number of other commits that had not been released yet.

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