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.
@@ -1,4 +1,3 @@
1
-
2
1
  module Transport
3
2
 
4
3
  autoload :Common, File.join(File.dirname(__FILE__), "transport", "common")
@@ -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
- perform_request
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, nil, nil, nil, nil, :use_ssl => use_ssl) do |connection|
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
- it "should perform the request" do
26
- Net::HTTP.should_receive(:start).with("host", 1234, nil, nil, nil, nil, { :use_ssl => false }).and_return(@response)
27
- @transport.perform
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
- it "should perform the request" do
37
- Net::HTTP.should_receive(:start).with("host", 1234, nil, nil, nil, nil, { :use_ssl => true }).and_return(@response)
38
- @transport.perform
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
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-04 00:00:00.000000000 Z
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: 3188865586453898669
136
+ hash: -668763505907960514
137
137
  requirements:
138
138
  - The 'json' gem if ruby version 1.8.x is used.
139
139
  rubyforge_project: transport