httpi-ntlm 0.9.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. data/.autotest +5 -0
  2. data/.gitignore +9 -0
  3. data/.rspec +1 -0
  4. data/.travis.yml +8 -0
  5. data/CHANGELOG.md +69 -0
  6. data/Gemfile +9 -0
  7. data/LICENSE +20 -0
  8. data/README.md +223 -0
  9. data/Rakefile +18 -0
  10. data/autotest/discover.rb +1 -0
  11. data/httpi-ntlm.gemspec +27 -0
  12. data/lib/httpi-ntlm.rb +1 -0
  13. data/lib/httpi.rb +198 -0
  14. data/lib/httpi/adapter.rb +67 -0
  15. data/lib/httpi/adapter/curb.rb +125 -0
  16. data/lib/httpi/adapter/httpclient.rb +98 -0
  17. data/lib/httpi/adapter/net_http.rb +117 -0
  18. data/lib/httpi/auth/config.rb +81 -0
  19. data/lib/httpi/auth/ssl.rb +91 -0
  20. data/lib/httpi/dime.rb +56 -0
  21. data/lib/httpi/request.rb +90 -0
  22. data/lib/httpi/response.rb +85 -0
  23. data/lib/httpi/version.rb +5 -0
  24. data/spec/fixtures/attachment.gif +0 -0
  25. data/spec/fixtures/client_cert.pem +16 -0
  26. data/spec/fixtures/client_key.pem +15 -0
  27. data/spec/fixtures/xml.gz +0 -0
  28. data/spec/fixtures/xml.xml +10 -0
  29. data/spec/fixtures/xml_dime.dime +0 -0
  30. data/spec/fixtures/xml_dime.xml +1 -0
  31. data/spec/httpi/adapter/curb_spec.rb +232 -0
  32. data/spec/httpi/adapter/httpclient_spec.rb +164 -0
  33. data/spec/httpi/adapter/net_http_spec.rb +142 -0
  34. data/spec/httpi/adapter_spec.rb +55 -0
  35. data/spec/httpi/auth/config_spec.rb +117 -0
  36. data/spec/httpi/auth/ssl_spec.rb +128 -0
  37. data/spec/httpi/httpi_spec.rb +284 -0
  38. data/spec/httpi/request_spec.rb +135 -0
  39. data/spec/httpi/response_spec.rb +125 -0
  40. data/spec/integration/request_spec.rb +95 -0
  41. data/spec/integration/server.rb +39 -0
  42. data/spec/spec_helper.rb +12 -0
  43. data/spec/support/fixture.rb +27 -0
  44. data/spec/support/matchers.rb +19 -0
  45. metadata +200 -0
@@ -0,0 +1,5 @@
1
+ Autotest.add_hook(:initialize) do |at|
2
+ at.clear_mappings
3
+ at.add_mapping(%r%^spec/httpi/.*_spec.rb$%) { |filename, _| filename }
4
+ at.add_mapping(%r%^lib/(.*)\.rb$%) { |_, m| ["spec/#{m[1]}_spec.rb"] }
5
+ end
@@ -0,0 +1,9 @@
1
+ .DS_Store
2
+ .yardoc
3
+ doc
4
+ coverage
5
+ tmp
6
+ *~
7
+ *.gem
8
+ .bundle
9
+ Gemfile.lock
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color
@@ -0,0 +1,8 @@
1
+ script: "rake ci"
2
+ rvm:
3
+ - 1.8.7
4
+ - 1.9.2
5
+ - ree
6
+ - rbx
7
+ - jruby
8
+ - ruby-head
@@ -0,0 +1,69 @@
1
+ ## 0.9.6 (2011-06-30)
2
+
3
+ * Added a `httpi-ntlm` file for convenience requires.
4
+
5
+ ## 0.9.5 (2011-06-30)
6
+
7
+ * Rebirth: httpi-ntlm provides experimental support for NTLM authentication.
8
+ Please test it and provide feedback to build a stable feature.
9
+
10
+ ## 0.9.4 (2011-05-15)
11
+
12
+ * Fix: issues [34](https://github.com/rubiii/httpi/issues/34) and
13
+ [29](https://github.com/rubiii/httpi/issues/29) - replaced the dependency
14
+ on `ntlm-http` with a dependency on `pyu-ntlm-http` which comes with quite
15
+ a few bugfixes.
16
+
17
+ * Fix: Setting the default adapter did not always load the adapter's client library.
18
+
19
+ * Improvement: Added a shortcut method to set the default adapter to use.
20
+
21
+ HTTPI.adapter = :net_http
22
+
23
+ ## 0.9.3 (2011-04-28)
24
+
25
+ * Fix: [issue 31](https://github.com/rubiii/httpi/issues/31) missing headers when using httpclient.
26
+
27
+ * Fix: [issue 30](https://github.com/rubiii/httpi/issues/30) fix for using SSL with Net::HTTP.
28
+
29
+ ## 0.9.2 (2011-04-05)
30
+
31
+ * Fix: issues [161](https://github.com/rubiii/savon/issues/161) and [165](https://github.com/rubiii/savon/issues/165)
32
+ reported at [rubiii/savon](https://github.com/rubiii/savon).
33
+
34
+ ## 0.9.1 (2011-04-04)
35
+
36
+ * Fix: [issue 25](https://github.com/rubiii/httpi/issues/22) problem with HTTPI using the Net::HTTP adapter [hakanensari].
37
+
38
+ ## 0.9.0 (2011-03-08)
39
+
40
+ * Feature: improved the adapter loading process ([d4a091](https://github.com/rubiii/httpi/commit/d4a091)) [rubiii].
41
+
42
+ Instead of using HTTPClient as the default and falling back to NetHTTP, the loading process now does the following:
43
+
44
+ 1. Check if either HTTPClient, Curb or NetHTTP are already defined.
45
+ If any one of those is defined, use it.
46
+
47
+ 2. Try to require HTTPClient, Curb and NetHTTP at last.
48
+ If any one of those can be required, use it.
49
+
50
+ Of course you can still manually specify the adapter to use.
51
+
52
+ * Fix: [issue 22](https://github.com/rubiii/httpi/issues/22) argument error on logging adapter warning [rubiii].
53
+
54
+ * Fix: [issue 23](https://github.com/rubiii/httpi/issues/23) the HTTPI.log method now works as expected [rubiii].
55
+
56
+ ## 0.8.0 (2011-03-07)
57
+
58
+ * Feature: added support for NTLM authentication ([96ceb1](https://github.com/rubiii/httpi/commit/96ceb1)) [MattHall].
59
+
60
+ You should now be able to use NTLM authentication by specifying your credentials via `HTTPI::Auth::Config#ntlm`:
61
+
62
+ request = HTTPI::Request.new
63
+ request.auth.ntlm "username", "password"
64
+
65
+ * Improvement: changed the default log level to :warn ([d01591](https://github.com/rubiii/httpi/commit/d01591))
66
+ and log at appropriate levels ([21ee1b](https://github.com/rubiii/httpi/commit/21ee1b)) [ichverstehe].
67
+
68
+ * Fix: [issue 18](https://github.com/rubiii/httpi/issues/18) don't mask exceptions in decoded_gzip_body
69
+ ([f3811b](https://github.com/rubiii/httpi/commit/f3811b)) [fj].
data/Gemfile ADDED
@@ -0,0 +1,9 @@
1
+ source :rubygems
2
+ gemspec
3
+
4
+ gem "jruby-openssl", :platforms => :jruby
5
+
6
+ # http clients
7
+ gem "httpclient", "~> 2.1.7"
8
+ gem "curb", "~> 0.7.8", :platforms => :ruby
9
+ gem "mock-server", :git => "https://github.com/djanowski/mock-server.git"
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2010 Daniel Harrington
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,223 @@
1
+ HTTPI [![Build Status](http://travis-ci.org/rubiii/httpi.png)](http://travis-ci.org/rubiii/httpi)
2
+ =====
3
+
4
+ HTTPI provides a common interface for Ruby HTTP libraries.
5
+
6
+ [Bugs](http://github.com/rubiii/httpi/issues) | [RDoc](http://rubydoc.info/gems/httpi/frames)
7
+
8
+ Installation
9
+ ------------
10
+
11
+ HTTPI is available through [Rubygems](http://rubygems.org/gems/httpi) and can be installed via:
12
+
13
+ ```
14
+ $ gem install httpi
15
+ ```
16
+
17
+
18
+ Getting started
19
+ ---------------
20
+
21
+ In order to provide a common interface, HTTPI provides the `HTTPI::Request` object for you to
22
+ configure your request. Here's a very simple GET request.
23
+
24
+ ``` ruby
25
+ request = HTTPI::Request.new("http://example.com")
26
+ HTTPI.get request
27
+ ```
28
+
29
+ To execute a POST request, you may want to specify a payload.
30
+
31
+ ``` ruby
32
+ request = HTTPI::Request.new
33
+ request.url = "http://post.example.com"
34
+ request.body = "some data"
35
+
36
+ HTTPI.post request
37
+ ```
38
+
39
+
40
+ HTTPI
41
+ -----
42
+
43
+ The `HTTPI` module uses one of the available adapters to execute HTTP requests.
44
+
45
+ #### GET
46
+
47
+ ``` ruby
48
+ HTTPI.get(request, adapter = nil)
49
+ HTTPI.get(url, adapter = nil)
50
+ ```
51
+
52
+ #### POST
53
+
54
+ ``` ruby
55
+ HTTPI.post(request, adapter = nil)
56
+ HTTPI.post(url, body, adapter = nil)
57
+ ```
58
+
59
+ #### HEAD
60
+
61
+ ``` ruby
62
+ HTTPI.head(request, adapter = nil)
63
+ HTTPI.head(url, adapter = nil)
64
+ ```
65
+
66
+ #### PUT
67
+
68
+ ``` ruby
69
+ HTTPI.put(request, adapter = nil)
70
+ HTTPI.put(url, body, adapter = nil)
71
+ ```
72
+
73
+ #### DELETE
74
+
75
+ ``` ruby
76
+ HTTPI.delete(request, adapter = nil)
77
+ HTTPI.delete(url, adapter = nil)
78
+ ```
79
+
80
+ #### Notice
81
+
82
+ * You can specify the adapter to use per request
83
+ * And request methods always return an `HTTPI::Response`
84
+
85
+ #### More control
86
+
87
+ If you need more control over the request, you can access the HTTP client instance
88
+ represented by your adapter in a block:
89
+
90
+ ``` ruby
91
+ HTTPI.post request do |http|
92
+ http.use_ssl = true # Curb example
93
+ end
94
+ ```
95
+
96
+
97
+ HTTPI::Adapter
98
+ --------------
99
+
100
+ HTTPI uses adapters to support multiple HTTP libraries.
101
+ It currently contains adapters for:
102
+
103
+ * [httpclient](http://rubygems.org/gems/httpclient) ~> 2.1.5
104
+ * [curb](http://rubygems.org/gems/curb) ~> 0.7.8
105
+ * [net/http](http://ruby-doc.org/stdlib/libdoc/net/http/rdoc)
106
+
107
+ You can manually specify the adapter to use via:
108
+
109
+ ``` ruby
110
+ HTTPI.adapter = :curb # or one of [:httpclient, :net_http]
111
+ ```
112
+
113
+ If you don't specify which adapter to use, HTTPI try to load HTTPClient, then Curb and finally NetHTTP.
114
+
115
+ #### Notice
116
+
117
+ HTTPI does not force you to install any of these libraries. If you'd like to use on of the more advanced
118
+ libraries (HTTPClient or Curb), you have to make sure they're in your LOAD_PATH. HTTPI will then load the
119
+ library when executing HTTP requests.
120
+
121
+
122
+ HTTPI::Request
123
+ --------------
124
+
125
+ #### URL
126
+
127
+ ``` ruby
128
+ request.url = "http://example.com"
129
+ request.url # => #<URI::HTTP:0x101c1ab18 URL:http://example.com>
130
+ ```
131
+
132
+ #### Proxy
133
+
134
+ ``` ruby
135
+ request.proxy = "http://example.com"
136
+ request.proxy # => #<URI::HTTP:0x101c1ab18 URL:http://example.com>
137
+ ```
138
+
139
+ #### Headers
140
+
141
+ ``` ruby
142
+ request.headers["Accept-Charset"] = "utf-8"
143
+ request.headers = { "Accept-Charset" => "utf-8" }
144
+ request.headers # => { "Accept-Charset" => "utf-8" }
145
+ ```
146
+
147
+ #### Body
148
+
149
+ ``` ruby
150
+ request.body = "some data"
151
+ request.body # => "some data"
152
+ ```
153
+
154
+ #### Open timeout
155
+
156
+ ``` ruby
157
+ request.open_timeout = 30 # sec
158
+ ```
159
+
160
+ #### Read timeout
161
+
162
+ ``` ruby
163
+ request.read_timeout = 30 # sec
164
+ ```
165
+
166
+
167
+ HTTPI::Auth
168
+ -----------
169
+
170
+ `HTTPI::Auth` supports HTTP basic and digest authentication.
171
+
172
+ ``` ruby
173
+ request.auth.basic("username", "password") # HTTP basic auth credentials
174
+ request.auth.digest("username", "password") # HTTP digest auth credentials
175
+ request.auth.ntlm("username", "password") # NTLM auth credentials
176
+ ```
177
+
178
+
179
+ HTTPI::Auth::SSL
180
+ ----------------
181
+
182
+ `HTTPI::Auth::SSL` manages SSL client authentication.
183
+
184
+ ``` ruby
185
+ request.auth.ssl.cert_key_file = "client_key.pem" # the private key file to use
186
+ request.auth.ssl.cert_key_password = "C3rtP@ssw0rd" # the key file's password
187
+ request.auth.ssl.cert_file = "client_cert.pem" # the certificate file to use
188
+ request.auth.ssl.ca_cert_file = "ca_cert.pem" # the ca certificate file to use
189
+ request.auth.ssl.verify_mode = :none # or one of [:peer, :fail_if_no_peer_cert, :client_once]
190
+ ```
191
+
192
+
193
+ HTTPI::Response
194
+ ---------------
195
+
196
+ Every request returns an `HTTPI::Response`. It contains the response code, headers and body.
197
+
198
+ ``` ruby
199
+ response = HTTPI.get request
200
+
201
+ response.code # => 200
202
+ response.headers # => { "Content-Encoding" => "gzip" }
203
+ response.body # => "<!DOCTYPE HTML PUBLIC ...>"
204
+ ```
205
+
206
+ The `response.body` handles gzipped and [DIME](http://en.wikipedia.org/wiki/Direct_Internet_Message_Encapsulation) encoded responses.
207
+
208
+ #### TODO
209
+
210
+ * Return the original `HTTPI::Request` for debugging purposes
211
+ * Return the time it took to execute the request
212
+
213
+
214
+ Logging
215
+ -------
216
+
217
+ HTTPI by default logs each HTTP request to STDOUT using a log level of :debug.
218
+
219
+ ``` ruby
220
+ HTTPI.log = false # disable logging
221
+ HTTPI.logger = MyLogger # change the logger
222
+ HTTPI.log_level = :info # change the log level
223
+ ```
@@ -0,0 +1,18 @@
1
+ require "bundler"
2
+ Bundler::GemHelper.install_tasks
3
+
4
+ require "rspec/core/rake_task"
5
+
6
+ RSpec::Core::RakeTask.new do |t|
7
+ t.pattern = "spec/httpi/**/*_spec.rb"
8
+ end
9
+
10
+ desc "Run RSpec integration examples"
11
+ RSpec::Core::RakeTask.new "spec_integration" do |t|
12
+ t.pattern = "spec/integration/*_spec.rb"
13
+ end
14
+
15
+ task :default => :spec
16
+
17
+ desc "Run RSpec code and integration examples"
18
+ task :ci => [:spec, :spec_integration]
@@ -0,0 +1 @@
1
+ Autotest.add_discovery { "rspec2" }
@@ -0,0 +1,27 @@
1
+ lib = File.expand_path("../lib/", __FILE__)
2
+ $:.unshift lib unless $:.include?(lib)
3
+
4
+ require "httpi/version"
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = "httpi-ntlm"
8
+ s.version = HTTPI::VERSION
9
+ s.authors = ["Daniel Harrington", "Martin Tepper"]
10
+ s.email = "me@rubiii.com"
11
+ s.homepage = "http://github.com/rubiii/httpi"
12
+ s.summary = "Interface for Ruby HTTP libraries"
13
+ s.description = "HTTPI provides a common interface for Ruby HTTP libraries."
14
+
15
+ s.rubyforge_project = s.name
16
+
17
+ s.add_dependency "rack"
18
+ s.add_dependency "pyu-ntlm-http", ">= 0.1.3.1"
19
+
20
+ s.add_development_dependency "rspec", "~> 2.2"
21
+ s.add_development_dependency "autotest"
22
+ s.add_development_dependency "mocha", "~> 0.9.9"
23
+ s.add_development_dependency "webmock", "~> 1.4.0"
24
+
25
+ s.files = `git ls-files`.split("\n")
26
+ s.require_path = "lib"
27
+ end
@@ -0,0 +1 @@
1
+ require "httpi"
@@ -0,0 +1,198 @@
1
+ require "logger"
2
+ require "httpi/version"
3
+ require "httpi/request"
4
+ require "httpi/adapter"
5
+
6
+ # = HTTPI
7
+ #
8
+ # Executes HTTP requests using a predefined adapter.
9
+ # All request methods accept an <tt>HTTPI::Request</tt> and an optional adapter.
10
+ # They may also offer shortcut methods for executing basic requests.
11
+ # Also they all return an <tt>HTTPI::Response</tt>.
12
+ #
13
+ # == GET
14
+ #
15
+ # request = HTTPI::Request.new :url => "http://example.com"
16
+ # HTTPI.get request, :httpclient
17
+ #
18
+ # === Shortcuts
19
+ #
20
+ # HTTPI.get "http://example.com", :curb
21
+ #
22
+ # == POST
23
+ #
24
+ # request = HTTPI::Request.new
25
+ # request.url = "http://example.com"
26
+ # request.body = "<some>xml</some>"
27
+ #
28
+ # HTTPI.post request, :httpclient
29
+ #
30
+ # === Shortcuts
31
+ #
32
+ # HTTPI.post "http://example.com", "<some>xml</some>", :curb
33
+ #
34
+ # == HEAD
35
+ #
36
+ # request = HTTPI::Request.new :url => "http://example.com"
37
+ # HTTPI.head request, :httpclient
38
+ #
39
+ # === Shortcuts
40
+ #
41
+ # HTTPI.head "http://example.com", :curb
42
+ #
43
+ # == PUT
44
+ #
45
+ # request = HTTPI::Request.new
46
+ # request.url = "http://example.com"
47
+ # request.body = "<some>xml</some>"
48
+ #
49
+ # HTTPI.put request, :httpclient
50
+ #
51
+ # === Shortcuts
52
+ #
53
+ # HTTPI.put "http://example.com", "<some>xml</some>", :curb
54
+ #
55
+ # == DELETE
56
+ #
57
+ # request = HTTPI::Request.new :url => "http://example.com"
58
+ # HTTPI.delete request, :httpclient
59
+ #
60
+ # === Shortcuts
61
+ #
62
+ # HTTPI.delete "http://example.com", :curb
63
+ #
64
+ # == More control
65
+ #
66
+ # If you need more control over your request, you can access the HTTP client
67
+ # instance represented by your adapter in a block.
68
+ #
69
+ # HTTPI.get request do |http|
70
+ # http.follow_redirect_count = 3 # HTTPClient example
71
+ # end
72
+ module HTTPI
73
+
74
+ REQUEST_METHODS = [:get, :post, :head, :put, :delete]
75
+
76
+ DEFAULT_LOG_LEVEL = :warn
77
+
78
+ class << self
79
+
80
+ # Executes an HTTP GET request.
81
+ def get(request, adapter = nil)
82
+ request = Request.new :url => request if request.kind_of? String
83
+
84
+ with_adapter :get, request, adapter do |adapter|
85
+ yield adapter.client if block_given?
86
+ adapter.get request
87
+ end
88
+ end
89
+
90
+ # Executes an HTTP POST request.
91
+ def post(*args)
92
+ request, adapter = request_and_adapter_from(args)
93
+
94
+ with_adapter :post, request, adapter do |adapter|
95
+ yield adapter.client if block_given?
96
+ adapter.post request
97
+ end
98
+ end
99
+
100
+ # Executes an HTTP HEAD request.
101
+ def head(request, adapter = nil)
102
+ request = Request.new :url => request if request.kind_of? String
103
+
104
+ with_adapter :head, request, adapter do |adapter|
105
+ yield adapter.client if block_given?
106
+ adapter.head request
107
+ end
108
+ end
109
+
110
+ # Executes an HTTP PUT request.
111
+ def put(*args)
112
+ request, adapter = request_and_adapter_from(args)
113
+
114
+ with_adapter :put, request, adapter do |adapter|
115
+ yield adapter.client if block_given?
116
+ adapter.put request
117
+ end
118
+ end
119
+
120
+ # Executes an HTTP DELETE request.
121
+ def delete(request, adapter = nil)
122
+ request = Request.new :url => request if request.kind_of? String
123
+
124
+ with_adapter :delete, request, adapter do |adapter|
125
+ yield adapter.client if block_given?
126
+ adapter.delete request
127
+ end
128
+ end
129
+
130
+ # Executes an HTTP request for the given +method+.
131
+ def request(method, request, adapter = nil)
132
+ raise ArgumentError, "Invalid request method: #{method}" unless REQUEST_METHODS.include? method
133
+ send method, request, adapter
134
+ end
135
+
136
+ # Shortcut for setting the default adapter to use.
137
+ def adapter=(adapter)
138
+ Adapter.use = adapter
139
+ end
140
+
141
+ # Sets whether to log HTTP requests.
142
+ attr_writer :log
143
+
144
+ # Returns whether to log HTTP requests. Defaults to +true+.
145
+ def log?
146
+ @log != false
147
+ end
148
+
149
+ # Sets the logger to use.
150
+ attr_writer :logger
151
+
152
+ # Returns the logger. Defaults to an instance of +Logger+ writing to STDOUT.
153
+ def logger
154
+ @logger ||= ::Logger.new STDOUT
155
+ end
156
+
157
+ # Sets the log level.
158
+ attr_writer :log_level
159
+
160
+ # Returns the log level. Defaults to :debug.
161
+ def log_level
162
+ @log_level ||= DEFAULT_LOG_LEVEL
163
+ end
164
+
165
+ # Logs given +messages+.
166
+ def log(*messages)
167
+ level = Symbol === messages.first ? messages.shift : log_level
168
+ logger.send level, messages.join(" ") if log?
169
+ end
170
+
171
+ # Reset the default config.
172
+ def reset_config!
173
+ @log = nil
174
+ @logger = nil
175
+ @log_level = nil
176
+ end
177
+
178
+ private
179
+
180
+ # Checks whether +args+ contains of an <tt>HTTPI::Request</tt> or a URL
181
+ # and a request body plus an optional adapter and returns an Array with
182
+ # an <tt>HTTPI::Request</tt> and (if given) an adapter.
183
+ def request_and_adapter_from(args)
184
+ return args if args[0].kind_of? Request
185
+ [Request.new(:url => args[0], :body => args[1]), args[2]]
186
+ end
187
+
188
+ # Expects a request +method+, a +request+ and an +adapter+ (defaults to
189
+ # <tt>Adapter.use</tt>) and yields an instance of the adapter to a given block.
190
+ def with_adapter(method, request, adapter)
191
+ adapter, adapter_class = Adapter.load adapter
192
+
193
+ log :debug, "HTTPI executes HTTP #{method.to_s.upcase} using the #{adapter} adapter"
194
+ yield adapter_class.new(request)
195
+ end
196
+
197
+ end
198
+ end