typhoeus 0.1.19 → 0.1.20
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/typhoeus.rb +1 -1
- data/lib/typhoeus/response.rb +8 -1
- data/spec/typhoeus/response_spec.rb +2 -2
- metadata +1 -1
data/lib/typhoeus.rb
CHANGED
data/lib/typhoeus/response.rb
CHANGED
@@ -22,7 +22,14 @@ module Typhoeus
|
|
22
22
|
hash
|
23
23
|
else
|
24
24
|
o = o.split(":")
|
25
|
-
|
25
|
+
key = o.first.strip
|
26
|
+
value = o.last ? o.last.strip : nil
|
27
|
+
if hash.has_key? key
|
28
|
+
hash[key] = [hash[key], value].flatten
|
29
|
+
else
|
30
|
+
hash[key] = value
|
31
|
+
end
|
32
|
+
|
26
33
|
hash
|
27
34
|
end
|
28
35
|
end
|
@@ -36,9 +36,9 @@ describe Typhoeus::Response do
|
|
36
36
|
|
37
37
|
describe "headers" do
|
38
38
|
it "can parse the headers into a hash" do
|
39
|
-
response = Typhoeus::Response.new(:headers => "HTTP/1.1 200 OK\r\nContent-Type: text/html; charset=utf-8\r\nConnection: close\r\nStatus: 200\r\nX-Powered-By: Phusion Passenger (mod_rails/mod_rack) 2.2.9\r\nX-Cache: miss\r\nX-Runtime: 184\r\nETag: e001d08d9354ab7bc7c27a00163a3afa\r\nCache-Control: private, max-age=0, must-revalidate\r\nContent-Length: 4725\r\nSet-Cookie: _some_session=BAh7CDoGciIAOg9zZXNzaW9uX2lkIiU1OTQ2OTcwMjljMWM5ZTQwODU1NjQwYTViMmQxMTkxMjoGcyIKL2NhcnQ%3D--b4c4663932243090c961bb93d4ad5e4327064730; path=/; HttpOnly\r\nServer: nginx/0.6.37 + Phusion Passenger 2.2.4 (mod_rails/mod_rack)\r\nP3P: CP=\"NOI DSP COR NID ADMa OPTa OUR NOR\"\r\n\r\n")
|
39
|
+
response = Typhoeus::Response.new(:headers => "HTTP/1.1 200 OK\r\nContent-Type: text/html; charset=utf-8\r\nConnection: close\r\nStatus: 200\r\nX-Powered-By: Phusion Passenger (mod_rails/mod_rack) 2.2.9\r\nX-Cache: miss\r\nX-Runtime: 184\r\nETag: e001d08d9354ab7bc7c27a00163a3afa\r\nCache-Control: private, max-age=0, must-revalidate\r\nContent-Length: 4725\r\nSet-Cookie: _some_session=BAh7CDoGciIAOg9zZXNzaW9uX2lkIiU1OTQ2OTcwMjljMWM5ZTQwODU1NjQwYTViMmQxMTkxMjoGcyIKL2NhcnQ%3D--b4c4663932243090c961bb93d4ad5e4327064730; path=/; HttpOnly\r\nServer: nginx/0.6.37 + Phusion Passenger 2.2.4 (mod_rails/mod_rack)\r\nSet-Cookie: foo=bar; path=/;\r\nP3P: CP=\"NOI DSP COR NID ADMa OPTa OUR NOR\"\r\n\r\n")
|
40
40
|
response.headers_hash["Status"].should == "200"
|
41
|
-
response.headers_hash["Set-Cookie"].should == "_some_session=BAh7CDoGciIAOg9zZXNzaW9uX2lkIiU1OTQ2OTcwMjljMWM5ZTQwODU1NjQwYTViMmQxMTkxMjoGcyIKL2NhcnQ%3D--b4c4663932243090c961bb93d4ad5e4327064730; path=/; HttpOnly"
|
41
|
+
response.headers_hash["Set-Cookie"].should == ["_some_session=BAh7CDoGciIAOg9zZXNzaW9uX2lkIiU1OTQ2OTcwMjljMWM5ZTQwODU1NjQwYTViMmQxMTkxMjoGcyIKL2NhcnQ%3D--b4c4663932243090c961bb93d4ad5e4327064730; path=/; HttpOnly", "foo=bar; path=/;"]
|
42
42
|
response.headers_hash["Content-Type"].should == "text/html; charset=utf-8"
|
43
43
|
end
|
44
44
|
end
|