httpi 0.9.5 → 0.9.6

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.
@@ -1,8 +1,11 @@
1
- script: "rake ci"
1
+ language: "ruby"
2
+ script: "bundle exec rake ci"
2
3
  rvm:
3
4
  - 1.8.7
4
5
  - 1.9.2
6
+ - 1.9.3
7
+ - jruby-18mode
8
+ - jruby-19mode
9
+ - rbx-18mode
10
+ - rbx-19mode
5
11
  - ree
6
- - rbx
7
- - jruby
8
- - ruby-head
@@ -1,3 +1,22 @@
1
+ ## 0.9.6 (2012-02-23)
2
+
3
+ * Feature: Merged [pull request 46](https://github.com/rubiii/httpi/pull/46) to support
4
+ request body Hashes. Fixes [issue 45](https://github.com/rubiii/httpi/issues/45).
5
+
6
+ ``` ruby
7
+ request.body = { :foo => :bar, :baz => :foo } # => "foo=bar&baz=foo"
8
+ ```
9
+
10
+ * Feature: Merged [pull request 43](https://github.com/rubiii/httpi/pull/43) to allow
11
+ proxy authentication with net/http.
12
+
13
+ * Feature: Merged [pull request 42](https://github.com/rubiii/httpi/pull/42) which sets up
14
+ HTTP basic authentication if user information is present in the URL.
15
+
16
+ * Fix: Merged [pull request 44](https://github.com/rubiii/httpi/pull/44) to fix
17
+ [issue 26](https://github.com/rubiii/httpi/issues/26) and probably also
18
+ [issue 32](https://github.com/rubiii/httpi/issues/32) - SSL client authentication.
19
+
1
20
  ## 0.9.5 (2011-06-30)
2
21
 
3
22
  * Improvement: Moved support for NTLM authentication into a separate gem.
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- HTTPI [![Build Status](http://travis-ci.org/rubiii/httpi.png)](http://travis-ci.org/rubiii/httpi)
1
+ HTTPI [![Build Status](https://secure.travis-ci.org/rubiii/httpi.png)](http://travis-ci.org/rubiii/httpi)
2
2
  =====
3
3
 
4
4
  HTTPI provides a common interface for Ruby HTTP libraries.
data/Rakefile CHANGED
@@ -1,6 +1,4 @@
1
- require "bundler"
2
- Bundler::GemHelper.install_tasks
3
-
1
+ require "bundler/gem_tasks"
4
2
  require "rspec/core/rake_task"
5
3
 
6
4
  RSpec::Core::RakeTask.new do |t|
@@ -16,10 +16,13 @@ Gem::Specification.new do |s|
16
16
 
17
17
  s.add_dependency "rack"
18
18
 
19
- s.add_development_dependency "rspec", "~> 2.2"
19
+ s.add_development_dependency "rake", "~> 0.8.7"
20
+ s.add_development_dependency "rspec", "~> 2.7"
21
+ s.add_development_dependency "mocha", "~> 0.9.9"
22
+ s.add_development_dependency "webmock", "~> 1.4.0"
23
+
20
24
  s.add_development_dependency "autotest"
21
- s.add_development_dependency "mocha", "~> 0.9.9"
22
- s.add_development_dependency "webmock", "~> 1.4.0"
25
+ s.add_development_dependency "ZenTest", "4.5.0"
23
26
 
24
27
  s.files = `git ls-files`.split("\n")
25
28
  s.require_path = "lib"
@@ -63,8 +63,9 @@ module HTTPI
63
63
  attr_writer :client
64
64
 
65
65
  def new_client(request)
66
- proxy = request.proxy || URI("")
67
- Net::HTTP::Proxy(proxy.host, proxy.port).new request.url.host, request.url.port
66
+ proxy_url = request.proxy || URI("")
67
+ proxy = Net::HTTP::Proxy(proxy_url.host, proxy_url.port, proxy_url.user, proxy_url.password)
68
+ proxy.new request.url.host, request.url.port
68
69
  end
69
70
 
70
71
  def do_request(type, request)
@@ -13,7 +13,7 @@ module HTTPI
13
13
 
14
14
  # Returns whether SSL configuration is present.
15
15
  def present?
16
- (verify_mode == :none) || (cert && cert_key)
16
+ (verify_mode == :none) || (cert && cert_key) || ca_cert_file
17
17
  rescue TypeError, Errno::ENOENT
18
18
  false
19
19
  end
@@ -24,6 +24,7 @@ module HTTPI
24
24
  # Sets the +url+ to access. Raises an +ArgumentError+ unless the +url+ is valid.
25
25
  def url=(url)
26
26
  @url = normalize_url! url
27
+ auth.basic @url.user, @url.password || '' if @url.user
27
28
  end
28
29
 
29
30
  # Returns the +url+ to access.
@@ -61,7 +62,13 @@ module HTTPI
61
62
  headers["Accept-Encoding"] = "gzip,deflate"
62
63
  end
63
64
 
64
- attr_accessor :body, :open_timeout, :read_timeout
65
+ attr_accessor :open_timeout, :read_timeout
66
+ attr_reader :body
67
+
68
+ # Sets a body request given a String or a Hash.
69
+ def body=(params)
70
+ @body = params.kind_of?(Hash) ? Rack::Utils.build_query(params) : params
71
+ end
65
72
 
66
73
  # Returns the <tt>HTTPI::Authentication</tt> object.
67
74
  def auth
@@ -1,5 +1,5 @@
1
1
  module HTTPI
2
2
 
3
- VERSION = "0.9.5"
3
+ VERSION = "0.9.6"
4
4
 
5
5
  end
@@ -31,6 +31,16 @@ describe HTTPI::Request do
31
31
  it "raises an ArgumentError in case of an invalid url" do
32
32
  expect { request.url = "invalid" }.to raise_error(ArgumentError)
33
33
  end
34
+
35
+ it "uses username and password as basic authentication if present in the URL" do
36
+ request.url = "http://username:password@example.com"
37
+ request.auth.basic.should == ['username', 'password']
38
+ end
39
+
40
+ it "uses a blank password if only username is specified in the URL" do
41
+ request.url = "http://username@example.com"
42
+ request.auth.basic.should == ['username', '']
43
+ end
34
44
  end
35
45
 
36
46
  describe "#proxy" do
@@ -91,10 +101,15 @@ describe HTTPI::Request do
91
101
  end
92
102
 
93
103
  describe "#body" do
94
- it "lets you specify the HTTP request body" do
104
+ it "lets you specify the HTTP request body using a String" do
95
105
  request.body = "<some>xml</some>"
96
106
  request.body.should == "<some>xml</some>"
97
107
  end
108
+
109
+ it "lets you specify the HTTP request body using a Hash" do
110
+ request.body = {:foo => :bar, :baz => :foo}
111
+ request.body.split("&").should =~ ["foo=bar", "baz=foo"]
112
+ end
98
113
  end
99
114
 
100
115
  describe "#open_timeout" do
@@ -9,7 +9,7 @@ describe HTTPI do
9
9
 
10
10
  before :all do
11
11
  WebMock.allow_net_connect!
12
-
12
+
13
13
  @username = "admin"
14
14
  @password = "pwd"
15
15
  @error_message = "Authorization Required"
@@ -78,17 +78,21 @@ describe HTTPI do
78
78
  end
79
79
 
80
80
  HTTPI::Adapter::ADAPTERS.keys.each do |adapter|
81
- context "using :#{adapter}" do
82
- let(:adapter) { adapter }
83
- it_should_behave_like "an HTTP client"
84
- it_should_behave_like "it works with HTTP basic auth"
81
+ unless adapter == :curb && RUBY_PLATFORM =~ /java/
82
+ context "using :#{adapter}" do
83
+ let(:adapter) { adapter }
84
+ it_should_behave_like "an HTTP client"
85
+ it_should_behave_like "it works with HTTP basic auth"
86
+ end
85
87
  end
86
88
  end
87
89
 
88
90
  (HTTPI::Adapter::ADAPTERS.keys - [:net_http]).each do |adapter|
89
- context "using :#{adapter}" do
90
- let(:adapter) { adapter }
91
- it_should_behave_like "it works with HTTP digest auth"
91
+ unless adapter == :curb && RUBY_PLATFORM =~ /java/
92
+ context "using :#{adapter}" do
93
+ let(:adapter) { adapter }
94
+ it_should_behave_like "it works with HTTP digest auth"
95
+ end
92
96
  end
93
97
  end
94
98
 
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: 49
4
+ hash: 55
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 9
9
- - 5
10
- version: 0.9.5
9
+ - 6
10
+ version: 0.9.6
11
11
  platform: ruby
12
12
  authors:
13
13
  - Daniel Harrington
@@ -16,11 +16,11 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2011-06-29 00:00:00 Z
19
+ date: 2012-02-22 00:00:00 Z
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
22
- name: rack
23
22
  prerelease: false
23
+ type: :runtime
24
24
  requirement: &id001 !ruby/object:Gem::Requirement
25
25
  none: false
26
26
  requirements:
@@ -30,40 +30,42 @@ dependencies:
30
30
  segments:
31
31
  - 0
32
32
  version: "0"
33
- type: :runtime
34
33
  version_requirements: *id001
34
+ name: rack
35
35
  - !ruby/object:Gem::Dependency
36
- name: rspec
37
36
  prerelease: false
37
+ type: :development
38
38
  requirement: &id002 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ~>
42
42
  - !ruby/object:Gem::Version
43
- hash: 7
43
+ hash: 49
44
44
  segments:
45
- - 2
46
- - 2
47
- version: "2.2"
48
- type: :development
45
+ - 0
46
+ - 8
47
+ - 7
48
+ version: 0.8.7
49
49
  version_requirements: *id002
50
+ name: rake
50
51
  - !ruby/object:Gem::Dependency
51
- name: autotest
52
52
  prerelease: false
53
+ type: :development
53
54
  requirement: &id003 !ruby/object:Gem::Requirement
54
55
  none: false
55
56
  requirements:
56
- - - ">="
57
+ - - ~>
57
58
  - !ruby/object:Gem::Version
58
- hash: 3
59
+ hash: 13
59
60
  segments:
60
- - 0
61
- version: "0"
62
- type: :development
61
+ - 2
62
+ - 7
63
+ version: "2.7"
63
64
  version_requirements: *id003
65
+ name: rspec
64
66
  - !ruby/object:Gem::Dependency
65
- name: mocha
66
67
  prerelease: false
68
+ type: :development
67
69
  requirement: &id004 !ruby/object:Gem::Requirement
68
70
  none: false
69
71
  requirements:
@@ -75,11 +77,11 @@ dependencies:
75
77
  - 9
76
78
  - 9
77
79
  version: 0.9.9
78
- type: :development
79
80
  version_requirements: *id004
81
+ name: mocha
80
82
  - !ruby/object:Gem::Dependency
81
- name: webmock
82
83
  prerelease: false
84
+ type: :development
83
85
  requirement: &id005 !ruby/object:Gem::Requirement
84
86
  none: false
85
87
  requirements:
@@ -91,8 +93,38 @@ dependencies:
91
93
  - 4
92
94
  - 0
93
95
  version: 1.4.0
94
- type: :development
95
96
  version_requirements: *id005
97
+ name: webmock
98
+ - !ruby/object:Gem::Dependency
99
+ prerelease: false
100
+ type: :development
101
+ requirement: &id006 !ruby/object:Gem::Requirement
102
+ none: false
103
+ requirements:
104
+ - - ">="
105
+ - !ruby/object:Gem::Version
106
+ hash: 3
107
+ segments:
108
+ - 0
109
+ version: "0"
110
+ version_requirements: *id006
111
+ name: autotest
112
+ - !ruby/object:Gem::Dependency
113
+ prerelease: false
114
+ type: :development
115
+ requirement: &id007 !ruby/object:Gem::Requirement
116
+ none: false
117
+ requirements:
118
+ - - "="
119
+ - !ruby/object:Gem::Version
120
+ hash: 43
121
+ segments:
122
+ - 4
123
+ - 5
124
+ - 0
125
+ version: 4.5.0
126
+ version_requirements: *id007
127
+ name: ZenTest
96
128
  description: HTTPI provides a common interface for Ruby HTTP libraries.
97
129
  email: me@rubiii.com
98
130
  executables: []
@@ -102,7 +134,6 @@ extensions: []
102
134
  extra_rdoc_files: []
103
135
 
104
136
  files:
105
- - .autotest
106
137
  - .gitignore
107
138
  - .rspec
108
139
  - .travis.yml
@@ -111,7 +142,6 @@ files:
111
142
  - LICENSE
112
143
  - README.md
113
144
  - Rakefile
114
- - autotest/discover.rb
115
145
  - httpi.gemspec
116
146
  - lib/httpi.rb
117
147
  - lib/httpi/adapter.rb
@@ -174,7 +204,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
174
204
  requirements: []
175
205
 
176
206
  rubyforge_project: httpi
177
- rubygems_version: 1.8.5
207
+ rubygems_version: 1.8.10
178
208
  signing_key:
179
209
  specification_version: 3
180
210
  summary: Interface for Ruby HTTP libraries
data/.autotest DELETED
@@ -1,5 +0,0 @@
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
@@ -1 +0,0 @@
1
- Autotest.add_discovery { "rspec2" }