Skip to content
Merged
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
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,8 @@ end
If you see something that could be done better or would like
to help out in the development of this code please feel free to clone the
'git' repository and send me patches:
`git clone git://github.com/zenchild/Viewpoint.git`
`git clone https://github.com/WinRb/Viewpoint.git`
or add an issue on GitHub:
http://github.com/zenchild/Viewpoint/issues
https://github.com/WinRb/Viewpoint/issues

Cheers!
12 changes: 6 additions & 6 deletions lib/ews/connection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,11 @@ class Viewpoint::EWS::Connection
include Viewpoint::EWS

attr_reader :endpoint
@@supported_httpclient_opts = %i[agent_name default_header]

# @param [String] endpoint the URL of the web service.
# @example https://<site>/ews/Exchange.asmx
# @param [Hash] opts Misc config options (mostly for developement)
# @param [Hash] opts Misc config options (mostly for development)
# @option opts [Fixnum] :ssl_verify_mode
# @option opts [Fixnum] :receive_timeout override the default receive timeout
# seconds
Expand All @@ -34,11 +36,9 @@ class Viewpoint::EWS::Connection
# @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)

@httpcli = HTTPClient.new(agent_name: opts[:user_agent])
else
@httpcli = HTTPClient.new
end

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

if opts[:trust_ca]
@httpcli.ssl_config.clear_cert_store
Expand Down