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 lib/httpclient.rb
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ def initialize(*args, &block)
load_environment
self.proxy = proxy if proxy
keep_webmock_compat
instance_eval &block if block
instance_eval(&block) if block
end

# webmock 1.6.2 depends on HTTP::Message#body.content to work.
Expand Down Expand Up @@ -1081,7 +1081,7 @@ def success_content(res)
def protect_keep_alive_disconnected
begin
yield
rescue KeepAliveDisconnected => e
rescue KeepAliveDisconnected
# Force to create new connection
Thread.current[:HTTPClient_AcquireNewConnection] = true
begin
Expand Down
2 changes: 1 addition & 1 deletion lib/httpclient/auth.rb
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,7 @@ def set?
def get(req)
target_uri = req.header.request_uri
synchronize {
domain_uri, param = @challenge.find { |uri, v|
_domain_uri, param = @challenge.find { |uri, v|
Util.uri_part_of(target_uri, uri)
}
return nil unless param
Expand Down
7 changes: 4 additions & 3 deletions test/test_auth.rb
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ def self.decode_utf16le(*arg)
end
# Make it work if @value == nil
class SecurityBuffer < FieldSet
remove_method(:data_size) if method_defined?(:data_size)
def data_size
@active && @value ? @value.size : 0
end
Expand Down Expand Up @@ -230,7 +231,7 @@ def test_BASIC_auth_multi_thread
c.www_auth.basic_auth.instance_eval { @scheme = "BASIC" }
c.set_auth("http://localhost:#{serverport}/", 'admin', 'admin')

threads = 100.times.map { |idx|
100.times.map { |idx|
Thread.new(idx) { |idx2|
Thread.abort_on_exception = true
Thread.pass
Expand All @@ -251,7 +252,7 @@ def test_basic_auth_reuses_credentials
c.test_loopback_http_response << "HTTP/1.0 200 OK\nContent-Length: 2\n\nOK"
c.debug_dev = str = ''
c.get_content("http://localhost:#{serverport}/basic_auth/sub/dir/")
assert_match /Authorization: Basic YWRtaW46YWRtaW4=/, str
assert_match(/Authorization: Basic YWRtaW46YWRtaW4=/, str)
end

def test_digest_auth
Expand All @@ -267,7 +268,7 @@ def test_digest_auth_reuses_credentials
c.test_loopback_http_response << "HTTP/1.0 200 OK\nContent-Length: 2\n\nOK"
c.debug_dev = str = ''
c.get_content("http://localhost:#{serverport}/digest_auth/sub/dir/")
assert_match /Authorization: Digest/, str
assert_match(/Authorization: Digest/, str)
end

def test_digest_auth_with_block
Expand Down
4 changes: 2 additions & 2 deletions test/test_cookie.rb
Original file line number Diff line number Diff line change
Expand Up @@ -290,8 +290,8 @@ def test_keep_escaped
def test_load_cookies_escaped
uri = urify('http://example.org/')
f = Tempfile.new('test_cookie')
File.open(f.path, 'w') do |f|
f.write <<EOF
File.open(f.path, 'w') do |out|
out.write <<EOF
http://example.org/ key1 "value" 0 .example.org / 13 0
http://example.org/ key2 "" 0 .example.org / 13 0
http://example.org/ key3 0 .example.org / 13 0
Expand Down
14 changes: 7 additions & 7 deletions test/test_httpclient.rb
Original file line number Diff line number Diff line change
Expand Up @@ -770,8 +770,8 @@ def test_get_with_block

def test_get_with_block_arity_2
called = false
res = @client.get(serverurl + 'servlet') { |res, str|
assert_equal(200, res.status)
res = @client.get(serverurl + 'servlet') { |blk_res, str|
assert_equal(200, blk_res.status)
assert_equal('get', str)
called = true
}
Expand All @@ -783,7 +783,7 @@ def test_get_with_block_arity_2
def test_get_with_block_string_recycle
@client.read_block_size = 2
body = []
res = @client.get(serverurl + 'servlet') { |str|
_res = @client.get(serverurl + 'servlet') { |str|
body << str
}
assert_equal(2, body.size)
Expand All @@ -800,7 +800,7 @@ def test_get_with_block_chunked_string_recycle
url = "http://localhost:#{server.addr[1]}/"
body = []
begin
res = @client.get(url + 'chunked') { |str|
_res = @client.get(url + 'chunked') { |str|
body << str
}
ensure
Expand Down Expand Up @@ -955,7 +955,7 @@ def myio.size
1
end
@client.debug_dev = str = StringIO.new
res = @client.post(serverurl + 'servlet', { :file => myio })
_res = @client.post(serverurl + 'servlet', { :file => myio })
assert_match(/\r\n4\r\n/, str.string, 'should send "4" not "45"')
end

Expand All @@ -972,7 +972,7 @@ def size
end
end
@client.debug_dev = str = StringIO.new
res = @client.post(serverurl + 'servlet', { :file1 => myio1, :file2 => myio2 })
_res = @client.post(serverurl + 'servlet', { :file1 => myio1, :file2 => myio2 })
assert_match(/\r\n45\r\n/, str.string)
end

Expand Down Expand Up @@ -1243,7 +1243,7 @@ def test_extra_headers

def test_http_custom_date_header
@client.debug_dev = (str = "")
res = @client.get(serverurl + 'hello', :header => {'Date' => 'foo'})
_res = @client.get(serverurl + 'hello', :header => {'Date' => 'foo'})
lines = str.split(/(?:\r?\n)+/)
assert_equal('Date: foo', lines[4])
end
Expand Down
4 changes: 2 additions & 2 deletions test/test_webagent-cookie.rb
Original file line number Diff line number Diff line change
Expand Up @@ -440,8 +440,8 @@ def test_escaped
def test_load_cookies_escaped
uri = urify('http://example.org/')
f = Tempfile.new('test_cookie')
File.open(f.path, 'w') do |f|
f.write <<EOF
File.open(f.path, 'w') do |out|
out.write <<EOF
http://example.org/ key "value" 0 .example.org / 13 0
http://example.org/ key "" .example.org / 13 0
http://example.org/ key .example.org / 13 0
Expand Down