Skip to content

Commit 1c54b85

Browse files
author
vivian2011
committed
fix bug : can't get cookie when url include ip adrr
1 parent 9847bcd commit 1c54b85

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

lib/restclient/request.rb

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@ def initialize args
197197

198198
@tf = nil # If you are a raw request, this is your tempfile
199199
@max_redirects = args[:max_redirects] || 10
200+
200201
@processed_headers = make_headers headers
201202
@args = args
202203

@@ -307,10 +308,13 @@ def cookie_jar
307308
#
308309
def make_cookie_header
309310
return nil if cookie_jar.nil?
311+
uri_header = URI(url)
312+
unless @headers["Host"].nil?
313+
uri_header.hostname = @headers["Host"]
314+
end
310315

311-
arr = cookie_jar.cookies(url)
316+
arr = cookie_jar.cookies(uri_header.to_s)
312317
return nil if arr.empty?
313-
314318
return HTTP::Cookie.cookie_value(arr)
315319
end
316320

@@ -401,7 +405,6 @@ def process_cookie_args!(uri, headers, args)
401405
if key.is_a?(Symbol)
402406
key = key.to_s
403407
end
404-
405408
# assume implicit domain from the request URI, and set for_domain to
406409
# permit subdomains
407410
jar.add(HTTP::Cookie.new(key, val, domain: uri.hostname.downcase,

0 commit comments

Comments
 (0)