Skip to content

Commit

Permalink
seems like after libcurl 8 cookies are handled this way... anyone fee…
Browse files Browse the repository at this point in the history
…l free to confirm if this is correct...
  • Loading branch information
taf2 committed Feb 9, 2025
1 parent 96b874f commit 187e8c0
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 9 deletions.
4 changes: 2 additions & 2 deletions tests/tc_curl_easy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def test_class_perform_01
end

def test_class_perform_02
data = ""
data = String.new
assert_instance_of Curl::Easy, c = Curl::Easy.perform($TEST_URL) { |curl| curl.on_body { |d| data << d; d.length } }

assert_nil c.body_str
Expand Down Expand Up @@ -211,7 +211,7 @@ def test_get_01
end

def test_get_02
data = ""
data = String.new
c = Curl::Easy.new($TEST_URL) do |curl|
curl.on_body { |d| data << d; d.length }
end
Expand Down
9 changes: 9 additions & 0 deletions tests/tc_curl_easy_cookielist.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,21 @@ def test_setopt_cookielist

# Since 7.43.0 cookies that were imported in the Set-Cookie format without a domain name are not exported by this option.
# So, before 7.43.0, c3 and c4 will be exported too; but that version is far too old for current curb version, so it's not handled here.
if Curl::CURL_VERSION.to_f > 8
expected_cookielist = [
".127.0.0.1\tTRUE\t/\tFALSE\t#{expires.to_time.to_i}\tc5\tv5",
".127.0.0.1\tTRUE\t/\tFALSE\t0\tc6\tv6",
".localhost\tTRUE\t/\tFALSE\t#{expires.to_time.to_i}\tc1\tv1",
".localhost\tTRUE\t/\tFALSE\t0\tc2\tv2",
]
else
expected_cookielist = [
"127.0.0.1\tFALSE\t/\tFALSE\t#{expires.to_time.to_i}\tc5\tv5",
"127.0.0.1\tFALSE\t/\tFALSE\t0\tc6\tv6",
".localhost\tTRUE\t/\tFALSE\t#{expires.to_time.to_i}\tc1\tv1",
".localhost\tTRUE\t/\tFALSE\t0\tc2\tv2",
]
end
assert_equal expected_cookielist, easy.cookielist

easy.url = "#{TestServlet.url}/get_cookies"
Expand Down
14 changes: 7 additions & 7 deletions tests/tc_curl_multi.rb
Original file line number Diff line number Diff line change
Expand Up @@ -114,13 +114,13 @@ def test_connection_autoclose
end

def test_new_multi_01
d1 = ""
d1 = String.new
c1 = Curl::Easy.new($TEST_URL) do |curl|
curl.headers["User-Agent"] = "myapp-0.0"
curl.on_body {|d| d1 << d; d.length }
end

d2 = ""
d2 = String.new
c2 = Curl::Easy.new($TEST_URL) do |curl|
curl.headers["User-Agent"] = "myapp-0.0"
curl.on_body {|d| d2 << d; d.length }
Expand Down Expand Up @@ -206,7 +206,7 @@ def test_n_requests
m = Curl::Multi.new
responses = []
n.times do|i|
responses[i] = ""
responses[i] = String.new
c = Curl::Easy.new($TEST_URL) do|curl|
curl.on_body{|data| responses[i] << data; data.size }
end
Expand All @@ -230,7 +230,7 @@ def test_n_requests_with_break
5.times do|it|
responses = []
n.times do|i|
responses[i] = ""
responses[i] = String.new
c = Curl::Easy.new($TEST_URL) do|curl|
curl.on_body{|data| responses[i] << data; data.size }
end
Expand Down Expand Up @@ -376,7 +376,7 @@ class TestForScope
attr_reader :buf

def t_method
@buf = ""
@buf = String.new
@m = Curl::Multi.new
10.times do|i|
c = Curl::Easy.new($TEST_URL)
Expand Down Expand Up @@ -422,8 +422,8 @@ def test_remote_requests
m = Curl::Multi.new
# add a few easy handles
requests.each do |url|
responses[url] = ""
responses["#{url}-header"] = ""
responses[url] = String.new
responses["#{url}-header"] = String.new
c = Curl::Easy.new(url) do|curl|
curl.follow_location = true
curl.on_header{|data| responses["#{url}-header"] << data; data.size }
Expand Down

0 comments on commit 187e8c0

Please sign in to comment.