Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

handle more than one Set-Cookie header

  • Loading branch information...
commit a4f65034c295dd32bbdd9fc1ba4810245669885b 1 parent aaf375c
@sroller authored
Showing with 25 additions and 3 deletions.
  1. +25 −3 lib/httpi/adapter/httpclient.rb
View
28 lib/httpi/adapter/httpclient.rb
@@ -84,15 +84,37 @@ def setup_ssl_auth(ssl)
unless ssl.verify_mode == :none
client.ssl_config.client_cert = ssl.cert
client.ssl_config.client_key = ssl.cert_key
- client.ssl_config.client_ca = ssl.ca_cert if ssl.ca_cert_file
+ # client.ssl_config.client_ca = ssl.ca_cert if ssl.ca_cert_file
+ client.ssl_config.set_trust_ca(ssl.ca_cert_file) if ssl.ca_cert_file
end
client.ssl_config.verify_mode = ssl.openssl_verify_mode
end
+ #
+ # Steffen Roller <steffen@rollers.de>
+ #
+ # response.header.all is an array of 2-element arrays
+ # some headers eg. "Set-Cookie" can occur more than one
+ # To convert the array of arrays into a hash
+ # we iterate over the array. If the first element already
+ # exists in the hash we convert the entry into an array.
+ #
def respond_with(response)
- Response.new response.code, Hash[*response.header.all.flatten], response.content
+ header_hash = {}
+ response.header.all.each do |item|
+ if header_hash.has_key?(item[0])
+ if header_hash[item[0]].is_a? Array
+ header_hash[item[0]] << item[1]
+ else
+ header_hash[item[0]] = [header_hash[item[0]], item[1]]
+ end
+ else
+ header_hash[item[0]] = item[1]
+ end
+ end
+ # Response.new response.code, Hash[*response.header.all.flatten], response.content
+ Response.new response.code, header_hash, response.content
end
-
end
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.