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

fix some warnings #166

Merged
merged 1 commit into from
Apr 29, 2016
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
2 changes: 1 addition & 1 deletion lib/httpi.rb
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def initialize(message = nil, original = $!)
class << self

def query_builder
@query_builder || HTTPI::QueryBuilder::Flat
@query_builder ||= HTTPI::QueryBuilder::Flat
end

def query_builder=(builder)
Expand Down
4 changes: 2 additions & 2 deletions lib/httpi/auth/ssl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class SSL

VERIFY_MODES = [:none, :peer, :fail_if_no_peer_cert, :client_once]
CERT_TYPES = [:pem, :der]
SSL_VERSIONS = OpenSSL::SSL::SSLContext::METHODS.reject { |method| method.match /server|client/ }.sort.reverse
SSL_VERSIONS = OpenSSL::SSL::SSLContext::METHODS.reject { |method| method.match(/server|client/) }.sort.reverse

# Returns whether SSL configuration is present.
def present?
Expand Down Expand Up @@ -63,7 +63,7 @@ def verify_mode=(mode)

# Returns the SSL version number. Defaults to <tt>nil</tt> (auto-negotiate).
def ssl_version
@ssl_version
@ssl_version ||= nil
end

# Sets the SSL version number. Expects one of <tt>HTTPI::Auth::SSL::SSL_VERSIONS</tt>.
Expand Down
4 changes: 2 additions & 2 deletions lib/httpi/request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,7 @@ def proxy=(proxy)

# Returns whether to use SSL.
def ssl?
return @ssl unless @ssl.nil?
!!(url.to_s =~ /^https/)
@ssl ||= !!(url.to_s =~ /^https/)
end

# Sets whether to use SSL.
Expand Down Expand Up @@ -102,6 +101,7 @@ def body=(params)
# Sets the block to be called while processing the response. The block
# accepts a single parameter - the chunked response body.
def on_body(&block)
@on_body ||= nil
if block_given? then
@on_body = block
end
Expand Down
2 changes: 2 additions & 0 deletions lib/httpi/response.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,14 @@ def cookies

# Returns any DIME attachments.
def attachments
@body ||= nil
decode_body unless @body
@attachments ||= []
end

# Returns the HTTP response body.
def body
@body ||= nil
decode_body unless @body
@body
end
Expand Down
6 changes: 3 additions & 3 deletions spec/httpi/adapter/curb_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
it "supports ntlm authentication" do
request = HTTPI::Request.new(@server.url + "ntlm-auth")
adapter = HTTPI::Adapter::Curb.new(request)

request.auth.ntlm("tester", "vReqSoafRe5O")
expect(adapter.request(:get).body).to eq("ntlm-auth")
end
Expand Down Expand Up @@ -257,8 +257,8 @@
end

it 'to 2 when ssl_version is specified as SSLv2/SSLv23' do
version = OpenSSL::SSL::SSLContext::METHODS.reject { |method| method.match /server|client/ }
version = version.select { |method| method.to_s.match /SSLv2|SSLv23/ }.first
version = OpenSSL::SSL::SSLContext::METHODS.reject { |method| method.match(/server|client/) }
version = version.select { |method| method.to_s.match(/SSLv2|SSLv23/) }.first
request.auth.ssl.ssl_version = version
curb.expects(:ssl_version=).with(2)

Expand Down
2 changes: 1 addition & 1 deletion spec/httpi/auth/ssl_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

describe HTTPI::Auth::SSL do
before(:all) do
@ssl_versions = OpenSSL::SSL::SSLContext::METHODS.reject { |method| method.match /server|client/ }.sort.reverse
@ssl_versions = OpenSSL::SSL::SSLContext::METHODS.reject { |method| method.match(/server|client/) }.sort.reverse
end

describe "VERIFY_MODES" do
Expand Down