httpi 0.7.0 → 0.7.1
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/README.md +16 -14
- data/lib/httpi/adapter/curb.rb +2 -2
- data/lib/httpi/version.rb +1 -1
- data/spec/httpi/adapter/curb_spec.rb +14 -0
- data/spec/spec_helper.rb +2 -3
- metadata +4 -4
data/README.md
CHANGED
@@ -88,6 +88,22 @@ by your adapter in a block:
|
|
88
88
|
http.use_ssl = true # Curb example
|
89
89
|
end
|
90
90
|
|
91
|
+
HTTPI::Adapter
|
92
|
+
--------------
|
93
|
+
|
94
|
+
HTTPI uses adapters to support multiple HTTP libraries.
|
95
|
+
It currently contains adapters for:
|
96
|
+
|
97
|
+
* [httpclient](http://rubygems.org/gems/httpclient) ~> 2.1.5
|
98
|
+
* [curb](http://rubygems.org/gems/curb) ~> 0.7.8
|
99
|
+
* [net/http](http://ruby-doc.org/stdlib/libdoc/net/http/rdoc)
|
100
|
+
|
101
|
+
By default, HTTPI uses the `HTTPClient` adapter. But changing the default is fairly easy:
|
102
|
+
|
103
|
+
HTTPI::Adapter.use = :curb # or one of [:httpclient, :net_http]
|
104
|
+
|
105
|
+
Notice: HTTPI does not force you to install any of these libraries. Instead you need to make sure to install the HTTP library of your choice and/or add it to your Gemfile. HTTPI will then load the library when executing HTTP requests.
|
106
|
+
|
91
107
|
HTTPI::Request
|
92
108
|
--------------
|
93
109
|
|
@@ -143,20 +159,6 @@ HTTPI::Auth::SSL
|
|
143
159
|
request.auth.ssl.cert_file = "client_cert.pem"
|
144
160
|
request.auth.ssl.verify_mode = :none
|
145
161
|
|
146
|
-
HTTPI::Adapter
|
147
|
-
--------------
|
148
|
-
|
149
|
-
HTTPI uses adapters to support multiple HTTP libraries.
|
150
|
-
It currently contains adapters for:
|
151
|
-
|
152
|
-
* [httpclient](http://rubygems.org/gems/httpclient) ~> 2.1.5
|
153
|
-
* [curb](http://rubygems.org/gems/curb) ~> 0.7.8
|
154
|
-
* [net/http](http://ruby-doc.org/stdlib/libdoc/net/http/rdoc)
|
155
|
-
|
156
|
-
By default, HTTPI uses the `HTTPClient`. But changing the default is fairly easy:
|
157
|
-
|
158
|
-
HTTPI::Adapter.use = :curb # or one of [:httpclient, :net_http]
|
159
|
-
|
160
162
|
HTTPI::Response
|
161
163
|
---------------
|
162
164
|
|
data/lib/httpi/adapter/curb.rb
CHANGED
@@ -28,7 +28,7 @@ module HTTPI
|
|
28
28
|
# Executes an HTTP POST request.
|
29
29
|
# @see HTTPI.post
|
30
30
|
def post(request)
|
31
|
-
do_request(request) { |client
|
31
|
+
do_request(request) { |client| client.http_post request.body }
|
32
32
|
end
|
33
33
|
|
34
34
|
# Executes an HTTP HEAD request.
|
@@ -40,7 +40,7 @@ module HTTPI
|
|
40
40
|
# Executes an HTTP PUT request.
|
41
41
|
# @see HTTPI.put
|
42
42
|
def put(request)
|
43
|
-
do_request(request) { |client
|
43
|
+
do_request(request) { |client| client.http_put request.body }
|
44
44
|
end
|
45
45
|
|
46
46
|
# Executes an HTTP DELETE request.
|
data/lib/httpi/version.rb
CHANGED
@@ -41,6 +41,13 @@ describe HTTPI::Adapter::Curb do
|
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
44
|
+
describe "#post includes body of request" do
|
45
|
+
it "should send the body in the request" do
|
46
|
+
curb.expects(:http_post).with('xml=hi&name=123')
|
47
|
+
adapter.post(basic_request { |request| request.body = 'xml=hi&name=123' } )
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
44
51
|
describe "#head" do
|
45
52
|
before do
|
46
53
|
curb.expects(:http_head)
|
@@ -67,6 +74,13 @@ describe HTTPI::Adapter::Curb do
|
|
67
74
|
end
|
68
75
|
end
|
69
76
|
|
77
|
+
describe "#put includes body of request" do
|
78
|
+
it "should send the body in the request" do
|
79
|
+
curb.expects(:http_put).with('xml=hi&name=123')
|
80
|
+
adapter.put(basic_request { |request| request.body = 'xml=hi&name=123' } )
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
70
84
|
describe "#delete" do
|
71
85
|
before do
|
72
86
|
curb.expects(:http_delete)
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: httpi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 1
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 7
|
9
|
-
-
|
10
|
-
version: 0.7.
|
9
|
+
- 1
|
10
|
+
version: 0.7.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Daniel Harrington
|
@@ -16,7 +16,7 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2010-11-
|
19
|
+
date: 2010-11-23 00:00:00 +01:00
|
20
20
|
default_executable:
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|