httpi 2.0.1 → 2.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG.md +5 -0
- data/lib/httpi/request.rb +9 -3
- data/lib/httpi/version.rb +1 -1
- data/spec/httpi/request_spec.rb +15 -0
- metadata +4 -4
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
## 2.0.2 (2013-01-26)
|
2
|
+
|
3
|
+
* Feature: Changed `HTTPI::Request#set_cookies` to accept an Array of `HTTPI::Cookie`
|
4
|
+
objects as well as any object that responds to `cookies` (like an `HTTPI::Response`).
|
5
|
+
|
1
6
|
## 2.0.1 (2013-01-25)
|
2
7
|
|
3
8
|
* Fix: [#72](https://github.com/savonrb/httpi/pull/72) standardized response
|
data/lib/httpi/request.rb
CHANGED
@@ -78,9 +78,15 @@ module HTTPI
|
|
78
78
|
headers["Accept-Encoding"] = "gzip,deflate"
|
79
79
|
end
|
80
80
|
|
81
|
-
# Sets the cookies from
|
82
|
-
|
83
|
-
|
81
|
+
# Sets the cookies from an object responding to `cookies` (e.g. `HTTPI::Response`)
|
82
|
+
# or an Array of `HTTPI::Cookie` objects.
|
83
|
+
def set_cookies(object_or_array)
|
84
|
+
if object_or_array.respond_to?(:cookies)
|
85
|
+
cookie_store.add *object_or_array.cookies
|
86
|
+
else
|
87
|
+
cookie_store.add *object_or_array
|
88
|
+
end
|
89
|
+
|
84
90
|
cookies = cookie_store.fetch
|
85
91
|
headers["Cookie"] = cookies if cookies
|
86
92
|
end
|
data/lib/httpi/version.rb
CHANGED
data/spec/httpi/request_spec.rb
CHANGED
@@ -142,11 +142,26 @@ describe HTTPI::Request do
|
|
142
142
|
request.headers["Cookie"].should include("some-cookie=choc-chip", "second-cookie=oatmeal")
|
143
143
|
end
|
144
144
|
|
145
|
+
it "accepts an Array of cookies" do
|
146
|
+
cookies = [
|
147
|
+
new_cookie("some-cookie=choc-chip"),
|
148
|
+
new_cookie("second-cookie=oatmeal")
|
149
|
+
]
|
150
|
+
|
151
|
+
request.set_cookies(cookies)
|
152
|
+
|
153
|
+
request.headers["Cookie"].should include("some-cookie=choc-chip", "second-cookie=oatmeal")
|
154
|
+
end
|
155
|
+
|
145
156
|
it "doesn't do anything if the response contains no cookies" do
|
146
157
|
request.set_cookies HTTPI::Response.new(200, {}, "")
|
147
158
|
request.headers.should_not include("Cookie")
|
148
159
|
end
|
149
160
|
|
161
|
+
def new_cookie(cookie_string)
|
162
|
+
HTTPI::Cookie.new(cookie_string)
|
163
|
+
end
|
164
|
+
|
150
165
|
def response_with_cookie(cookie)
|
151
166
|
HTTPI::Response.new(200, { "Set-Cookie" => "#{cookie}; Path=/; HttpOnly" }, "")
|
152
167
|
end
|
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.
|
4
|
+
version: 2.0.2
|
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: 2013-01-
|
13
|
+
date: 2013-01-26 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: -
|
174
|
+
hash: -2172357975066915796
|
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: -
|
183
|
+
hash: -2172357975066915796
|
184
184
|
requirements: []
|
185
185
|
rubyforge_project: httpi
|
186
186
|
rubygems_version: 1.8.24
|