httpi 2.0.0 → 2.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,8 @@
1
+ ## 2.0.1 (2013-01-25)
2
+
3
+ * Fix: [#72](https://github.com/savonrb/httpi/pull/72) standardized response
4
+ headers from all adapters.
5
+
1
6
  ## 2.0.0 (2012-12-16)
2
7
 
3
8
  * Feature: [#66](https://github.com/savonrb/httpi/pull/66) adds a `query` method
@@ -63,7 +63,15 @@ module HTTPI
63
63
  end
64
64
 
65
65
  def respond_with(response)
66
- Response.new response.code, Hash[*response.header.all.flatten], response.content
66
+ headers = {}
67
+ response.header.all.each do |(header, value)|
68
+ if headers.key?(header)
69
+ headers[header] = Array(headers[header]) << value
70
+ else
71
+ headers[header] = value
72
+ end
73
+ end
74
+ Response.new response.code, headers, response.content
67
75
  end
68
76
 
69
77
  end
@@ -92,7 +92,9 @@ module HTTPI
92
92
 
93
93
  def respond_with(response)
94
94
  headers = response.to_hash
95
- headers.each { |key, value| headers[key] = value[0] }
95
+ headers.each do |key, value|
96
+ headers[key] = value[0] if value.size <= 1
97
+ end
96
98
  Response.new response.code, headers, response.body
97
99
  end
98
100
 
@@ -1,5 +1,5 @@
1
1
  module HTTPI
2
2
 
3
- VERSION = "2.0.0"
3
+ VERSION = "2.0.1"
4
4
 
5
5
  end
@@ -25,6 +25,14 @@ describe HTTPI::Adapter::Curb do
25
25
  response.body.should include("HTTPI")
26
26
  end
27
27
 
28
+ it "it supports headers with multiple values" do
29
+ request = HTTPI::Request.new(@server.url + "cookies")
30
+
31
+ response = HTTPI.get(request, adapter)
32
+ cookies = ["cookie1=chip1; path=/", "cookie2=chip2; path=/"]
33
+ response.headers["Set-Cookie"].should eq(cookies)
34
+ end
35
+
28
36
  it "executes GET requests" do
29
37
  response = HTTPI.get(@server.url, adapter)
30
38
  response.body.should eq("get")
@@ -34,6 +34,14 @@ describe HTTPI::Adapter::EmHttpRequest do
34
34
  response.body.should include("HTTPI")
35
35
  end
36
36
 
37
+ it "it supports headers with multiple values" do
38
+ request = HTTPI::Request.new(@server.url + "cookies")
39
+
40
+ response = HTTPI.get(request, adapter)
41
+ cookies = ["cookie1=chip1; path=/", "cookie2=chip2; path=/"]
42
+ response.headers["Set-Cookie"].should eq(cookies)
43
+ end
44
+
37
45
  it "executes GET requests" do
38
46
  response = HTTPI.get(@server.url, adapter)
39
47
  response.body.should eq("get")
@@ -22,6 +22,14 @@ describe HTTPI::Adapter::HTTPClient do
22
22
  response.body.should include("HTTPI")
23
23
  end
24
24
 
25
+ it "it supports headers with multiple values" do
26
+ request = HTTPI::Request.new(@server.url + "cookies")
27
+
28
+ response = HTTPI.get(request, adapter)
29
+ cookies = ["cookie1=chip1; path=/", "cookie2=chip2; path=/"]
30
+ response.headers["Set-Cookie"].should eq(cookies)
31
+ end
32
+
25
33
  it "executes GET requests" do
26
34
  response = HTTPI.get(@server.url, adapter)
27
35
  response.body.should eq("get")
@@ -22,6 +22,14 @@ describe HTTPI::Adapter::NetHTTP do
22
22
  response.body.should include("HTTPI")
23
23
  end
24
24
 
25
+ it "it supports headers with multiple values" do
26
+ request = HTTPI::Request.new(@server.url + "cookies")
27
+
28
+ response = HTTPI.get(request, adapter)
29
+ cookies = ["cookie1=chip1; path=/", "cookie2=chip2; path=/"]
30
+ response.headers["Set-Cookie"].should eq(cookies)
31
+ end
32
+
25
33
  it "executes GET requests" do
26
34
  response = HTTPI.get(@server.url, adapter)
27
35
  response.body.should eq("get")
@@ -26,6 +26,17 @@ class IntegrationServer
26
26
  }
27
27
  end
28
28
 
29
+ map "/cookies" do
30
+ run lambda { |env|
31
+ status, headers, body = IntegrationServer.respond_with("Many Cookies")
32
+ response = Rack::Response.new(body, status, headers)
33
+
34
+ response.set_cookie("cookie1", {:value => "chip1", :path => "/"})
35
+ response.set_cookie("cookie2", {:value => "chip2", :path => "/"})
36
+ response.finish
37
+ }
38
+ end
39
+
29
40
  map "/basic-auth" do
30
41
  use Rack::Auth::Basic, "basic-realm" do |username, password|
31
42
  username == "admin" && password == "secret"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: httpi
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.0.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2012-12-16 00:00:00.000000000 Z
13
+ date: 2013-01-25 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rack
@@ -171,7 +171,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
171
171
  version: '0'
172
172
  segments:
173
173
  - 0
174
- hash: -511386314545034600
174
+ hash: -1005658617748404150
175
175
  required_rubygems_version: !ruby/object:Gem::Requirement
176
176
  none: false
177
177
  requirements:
@@ -180,7 +180,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
180
180
  version: '0'
181
181
  segments:
182
182
  - 0
183
- hash: -511386314545034600
183
+ hash: -1005658617748404150
184
184
  requirements: []
185
185
  rubyforge_project: httpi
186
186
  rubygems_version: 1.8.24