transport 1.0.4 → 1.0.5
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/lib/transport.rb +0 -1
- data/lib/transport/http.rb +15 -2
- data/spec/lib/transport/http_spec.rb +24 -6
- metadata +3 -3
data/lib/transport.rb
CHANGED
data/lib/transport/http.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'net/http'
|
2
|
+
require 'openssl'
|
2
3
|
require File.join(File.dirname(__FILE__), "common")
|
3
4
|
|
4
5
|
module Transport
|
@@ -11,7 +12,11 @@ module Transport
|
|
11
12
|
autoload :Formatter, File.join(File.dirname(__FILE__), "http", "formatter")
|
12
13
|
|
13
14
|
def perform
|
14
|
-
|
15
|
+
if RUBY_VERSION < "1.9"
|
16
|
+
perform_request_1_8
|
17
|
+
else
|
18
|
+
perform_request
|
19
|
+
end
|
15
20
|
log_transport
|
16
21
|
check_status_code
|
17
22
|
end
|
@@ -20,7 +25,15 @@ module Transport
|
|
20
25
|
|
21
26
|
def perform_request
|
22
27
|
use_ssl = @uri.scheme == 'https'
|
23
|
-
@http_response = Net::HTTP.start(@uri.host, @uri.port,
|
28
|
+
@http_response = Net::HTTP.start(@uri.host, @uri.port, :use_ssl => use_ssl, :verify_mode => OpenSSL::SSL::VERIFY_NONE) do |connection|
|
29
|
+
connection.request @request
|
30
|
+
end
|
31
|
+
@response = @http_response.body
|
32
|
+
end
|
33
|
+
|
34
|
+
def perform_request_1_8
|
35
|
+
warn "SSL not supported with this version of Ruby" if @uri.scheme == 'https'
|
36
|
+
@http_response = Net::HTTP.start(@uri.host, @uri.port) do |connection|
|
24
37
|
connection.request @request
|
25
38
|
end
|
26
39
|
@response = @http_response.body
|
@@ -22,9 +22,16 @@ describe Transport::HTTP do
|
|
22
22
|
describe "perform" do
|
23
23
|
|
24
24
|
context "when using HTTP scheme" do
|
25
|
-
|
26
|
-
|
27
|
-
|
25
|
+
if RUBY_VERSION < "1.9"
|
26
|
+
it "should perform the request" do
|
27
|
+
Net::HTTP.should_receive(:start).with("host", 1234).and_return(@response)
|
28
|
+
@transport.perform
|
29
|
+
end
|
30
|
+
else
|
31
|
+
it "should perform the request" do
|
32
|
+
Net::HTTP.should_receive(:start).with("host", 1234, anything()).and_return(@response)
|
33
|
+
@transport.perform
|
34
|
+
end
|
28
35
|
end
|
29
36
|
end
|
30
37
|
|
@@ -33,9 +40,20 @@ describe Transport::HTTP do
|
|
33
40
|
https_uri = mock URI, :host => "host", :port => 1234, :scheme => "https"
|
34
41
|
@transport = described_class.new https_uri, @request, @options
|
35
42
|
end
|
36
|
-
|
37
|
-
|
38
|
-
|
43
|
+
if RUBY_VERSION < "1.9"
|
44
|
+
it "should perform the request" do
|
45
|
+
Net::HTTP.should_receive(:start).with("host", 1234).and_return(@response)
|
46
|
+
@transport.perform
|
47
|
+
end
|
48
|
+
it "should trigger a warning" do
|
49
|
+
@transport.should_receive(:warn).with("SSL not supported with this version of Ruby")
|
50
|
+
@transport.perform
|
51
|
+
end
|
52
|
+
else
|
53
|
+
it "should perform the request" do
|
54
|
+
Net::HTTP.should_receive(:start).with("host", 1234, { :use_ssl => true, :verify_mode => OpenSSL::SSL::VERIFY_NONE }).and_return(@response)
|
55
|
+
@transport.perform
|
56
|
+
end
|
39
57
|
end
|
40
58
|
end
|
41
59
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: transport
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-03-
|
12
|
+
date: 2013-03-05 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
@@ -133,7 +133,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
133
133
|
version: '0'
|
134
134
|
segments:
|
135
135
|
- 0
|
136
|
-
hash:
|
136
|
+
hash: -668763505907960514
|
137
137
|
requirements:
|
138
138
|
- The 'json' gem if ruby version 1.8.x is used.
|
139
139
|
rubyforge_project: transport
|