httpi 0.7.2 → 0.7.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -14,6 +14,8 @@ Gem::Specification.new do |s|
14
14
 
15
15
  s.rubyforge_project = s.name
16
16
 
17
+ s.add_dependency "rack"
18
+
17
19
  s.add_development_dependency "httpclient", "~> 2.1.5"
18
20
  s.add_development_dependency "curb", "~> 0.7.8"
19
21
 
@@ -92,7 +92,7 @@ module HTTPI
92
92
  end
93
93
 
94
94
  def respond_with(response)
95
- Response.new response.code, Hash[response.header.all.flatten], response.content
95
+ Response.new response.code, Hash[response.header.all], response.content
96
96
  end
97
97
 
98
98
  end
@@ -106,9 +106,10 @@ module HTTPI
106
106
  end
107
107
 
108
108
  def respond_with(response)
109
- Response.new response.code, response.to_hash, response.body
109
+ headers = response.to_hash
110
+ headers.each {|k,v| headers[k] = v[0]}
111
+ Response.new response.code, headers, response.body
110
112
  end
111
-
112
113
  end
113
114
  end
114
115
  end
@@ -1,5 +1,6 @@
1
1
  require "uri"
2
2
  require "httpi/auth/config"
3
+ require "rack/utils"
3
4
 
4
5
  module HTTPI
5
6
 
@@ -47,11 +48,13 @@ module HTTPI
47
48
 
48
49
  # Returns a Hash of HTTP headers. Defaults to return an empty Hash.
49
50
  def headers
50
- @headers ||= {}
51
+ @headers ||= Rack::Utils::HeaderHash.new
51
52
  end
52
53
 
53
54
  # Sets the Hash of HTTP headers.
54
- attr_writer :headers
55
+ def headers=(headers)
56
+ @headers = Rack::Utils::HeaderHash.new(headers)
57
+ end
55
58
 
56
59
  # Adds a header information to accept gzipped content.
57
60
  def gzip
@@ -1,6 +1,7 @@
1
1
  require "zlib"
2
2
  require "stringio"
3
3
  require "httpi/dime"
4
+ require "rack/utils"
4
5
 
5
6
  module HTTPI
6
7
 
@@ -15,7 +16,7 @@ module HTTPI
15
16
  # Initializer expects an HTTP response +code+, +headers+ and +body+.
16
17
  def initialize(code, headers, body)
17
18
  self.code = code.to_i
18
- self.headers = headers
19
+ self.headers = Rack::Utils::HeaderHash.new(headers)
19
20
  self.raw_body = body
20
21
  end
21
22
 
@@ -1,5 +1,5 @@
1
1
  module HTTPI
2
2
 
3
- VERSION = "0.7.2"
3
+ VERSION = "0.7.3"
4
4
 
5
5
  end
@@ -16,32 +16,38 @@ describe HTTPI do
16
16
  @username = @password = "user1"
17
17
  @error_message = "Authorization Required"
18
18
  @example_web_page = "Example Web Page"
19
+ @content_type = "text/html"
19
20
  end
20
21
 
21
22
  shared_examples_for "an HTTP client" do
22
23
  it "and execute an HTTP GET request" do
23
24
  response = HTTPI.get "http://example.com", adapter
24
25
  response.body.should include(@example_web_page)
26
+ response.headers["Content-Type"].should include(@content_type)
25
27
  end
26
28
 
27
29
  it "and execute an HTTP POST request" do
28
30
  response = HTTPI.post "http://example.com", "<some>xml</some>", adapter
29
31
  response.body.should include(@example_web_page)
32
+ response.headers["Content-Type"].should include(@content_type)
30
33
  end
31
34
 
32
35
  it "and execute an HTTP HEAD request" do
33
36
  response = HTTPI.head "http://example.com", adapter
34
37
  response.code.should == 200
38
+ response.headers["Content-Type"].should include(@content_type)
35
39
  end
36
40
 
37
41
  it "and execute an HTTP PUT request" do
38
42
  response = HTTPI.put "http://example.com", "<some>xml</some>", adapter
39
43
  response.body.should include("PUT is not allowed")
44
+ response.headers["Content-Type"].should include(@content_type)
40
45
  end
41
46
 
42
47
  it "and execute an HTTP DELETE request" do
43
48
  response = HTTPI.delete "http://example.com", adapter
44
49
  response.body.should include("DELETE is not allowed")
50
+ response.headers["Content-Type"].should include(@content_type)
45
51
  end
46
52
  end
47
53
 
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: 7
4
+ hash: 5
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 7
9
- - 2
10
- version: 0.7.2
9
+ - 3
10
+ version: 0.7.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Daniel Harrington
@@ -16,13 +16,27 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2010-12-02 00:00:00 +01:00
19
+ date: 2010-12-10 00:00:00 +01:00
20
20
  default_executable:
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency
23
- name: httpclient
23
+ name: rack
24
24
  prerelease: false
25
25
  requirement: &id001 !ruby/object:Gem::Requirement
26
+ none: false
27
+ requirements:
28
+ - - ">="
29
+ - !ruby/object:Gem::Version
30
+ hash: 3
31
+ segments:
32
+ - 0
33
+ version: "0"
34
+ type: :runtime
35
+ version_requirements: *id001
36
+ - !ruby/object:Gem::Dependency
37
+ name: httpclient
38
+ prerelease: false
39
+ requirement: &id002 !ruby/object:Gem::Requirement
26
40
  none: false
27
41
  requirements:
28
42
  - - ~>
@@ -34,11 +48,11 @@ dependencies:
34
48
  - 5
35
49
  version: 2.1.5
36
50
  type: :development
37
- version_requirements: *id001
51
+ version_requirements: *id002
38
52
  - !ruby/object:Gem::Dependency
39
53
  name: curb
40
54
  prerelease: false
41
- requirement: &id002 !ruby/object:Gem::Requirement
55
+ requirement: &id003 !ruby/object:Gem::Requirement
42
56
  none: false
43
57
  requirements:
44
58
  - - ~>
@@ -50,11 +64,11 @@ dependencies:
50
64
  - 8
51
65
  version: 0.7.8
52
66
  type: :development
53
- version_requirements: *id002
67
+ version_requirements: *id003
54
68
  - !ruby/object:Gem::Dependency
55
69
  name: rspec
56
70
  prerelease: false
57
- requirement: &id003 !ruby/object:Gem::Requirement
71
+ requirement: &id004 !ruby/object:Gem::Requirement
58
72
  none: false
59
73
  requirements:
60
74
  - - "="
@@ -66,11 +80,11 @@ dependencies:
66
80
  - 0
67
81
  version: 2.0.0
68
82
  type: :development
69
- version_requirements: *id003
83
+ version_requirements: *id004
70
84
  - !ruby/object:Gem::Dependency
71
85
  name: mocha
72
86
  prerelease: false
73
- requirement: &id004 !ruby/object:Gem::Requirement
87
+ requirement: &id005 !ruby/object:Gem::Requirement
74
88
  none: false
75
89
  requirements:
76
90
  - - ~>
@@ -82,11 +96,11 @@ dependencies:
82
96
  - 9
83
97
  version: 0.9.9
84
98
  type: :development
85
- version_requirements: *id004
99
+ version_requirements: *id005
86
100
  - !ruby/object:Gem::Dependency
87
101
  name: webmock
88
102
  prerelease: false
89
- requirement: &id005 !ruby/object:Gem::Requirement
103
+ requirement: &id006 !ruby/object:Gem::Requirement
90
104
  none: false
91
105
  requirements:
92
106
  - - ~>
@@ -98,7 +112,7 @@ dependencies:
98
112
  - 0
99
113
  version: 1.4.0
100
114
  type: :development
101
- version_requirements: *id005
115
+ version_requirements: *id006
102
116
  description: HTTPI provides a common interface for Ruby HTTP libraries.
103
117
  email: me@rubiii.com
104
118
  executables: []