uv-rays 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 663ee2734c50410a550b07bb2cf2e0fa868fa9a3
4
- data.tar.gz: d268b959e9d47496538b8133fb4049c316838057
3
+ metadata.gz: 062fbd42aaa4ac76d836fbf53f1d20c069b2b0e6
4
+ data.tar.gz: f282b28e0a2b1c6831f14091f87928be777ad061
5
5
  SHA512:
6
- metadata.gz: bf48b38bea0a918df33883661c51906bb7aebedb51356589495827de3a67549ccb31a86f547bfed83aa85f0402ae3aebf88976e30b8fbce5058ba8f24e6466be
7
- data.tar.gz: 91f4931a148d3219d01673253ba19c1411187477545609486a0a2f6f957d6405669363a7bcf4a534f24194364a71419ad89b2fc4401f4ed6b9a461113de37bd0
6
+ metadata.gz: 1d8151d7d1240523a47ab1902e75abd95a61f0a30fb76422e6da23e486b1321022dfdda115e686ff11b55cc27e58317ac39260415b808e47574429a45f560f90
7
+ data.tar.gz: 0d8a947d398f9be35e9a3f5c4192cabdf7a2a02cc38dcdac4f8628c4a9bb0c86dca16f98dcf30e1bdc67e71bb082244faaa2a7ca3efcdf8ba7866abc044e15e5
@@ -6,7 +6,7 @@ module UV
6
6
  tcp.progress handler.method(:on_read)
7
7
  tcp.connect server, port do
8
8
  tcp.enable_nodelay
9
- tcp.start_tls(handler.using_tls) unless handler.using_tls == false
9
+ tcp.start_tls(handler.using_tls) if handler.using_tls
10
10
 
11
11
  # on_connect could call use_tls so must come after start_tls
12
12
  handler.on_connect(tcp)
@@ -182,7 +182,7 @@ module UV
182
182
  else
183
183
  # Async DNS resolution
184
184
  # Note:: send here will chain the promise
185
- tcp.loop.lookup(server).then do |result|
185
+ @loop.lookup(recipient_address).then do |result|
186
186
  @transport.send result[0][0], recipient_port, data
187
187
  end
188
188
  end
@@ -30,7 +30,7 @@ module UV
30
30
 
31
31
  @path = options[:path]
32
32
  @method = options[:method]
33
- @uri = encode_host(endpoint.host, endpoint.port) + @path
33
+ @uri = "#{endpoint.scheme}#{encode_host(endpoint.host, endpoint.port)}#{@path}"
34
34
  end
35
35
 
36
36
  def resolve(response)
@@ -26,17 +26,19 @@ module UV
26
26
  end # CookieJar
27
27
 
28
28
 
29
- class HttpEndpoint < TcpConnection
30
- TRANSFER_ENCODING="TRANSFER_ENCODING"
31
- CONTENT_ENCODING="CONTENT_ENCODING"
32
- CONTENT_LENGTH="CONTENT_LENGTH"
33
- CONTENT_TYPE="CONTENT_TYPE"
34
- LAST_MODIFIED="LAST_MODIFIED"
35
- KEEP_ALIVE="CONNECTION"
36
- LOCATION="LOCATION"
37
- HOST="HOST"
38
- ETAG="ETAG"
39
- CRLF="\r\n"
29
+ class HttpEndpoint < OutboundConnection
30
+ TRANSFER_ENCODING="TRANSFER_ENCODING".freeze
31
+ CONTENT_ENCODING="CONTENT_ENCODING".freeze
32
+ CONTENT_LENGTH="CONTENT_LENGTH".freeze
33
+ CONTENT_TYPE="CONTENT_TYPE".freeze
34
+ LAST_MODIFIED="LAST_MODIFIED".freeze
35
+ KEEP_ALIVE="CONNECTION".freeze
36
+ LOCATION="LOCATION".freeze
37
+ HOST="HOST".freeze
38
+ ETAG="ETAG".freeze
39
+ CRLF="\r\n".freeze
40
+ HTTPS="https://".freeze
41
+ HTTP="http://".freeze
40
42
 
41
43
 
42
44
  @@defaults = {
@@ -44,7 +46,7 @@ module UV
44
46
  :keepalive => true
45
47
  }
46
48
 
47
- attr_reader :host, :port, :using_tls, :loop, :cookiejar
49
+ attr_reader :scheme, :host, :port, :using_tls, :loop, :cookiejar
48
50
  attr_reader :connect_timeout, :inactivity_timeout
49
51
 
50
52
  def initialize(uri, options = {})
@@ -52,12 +54,10 @@ module UV
52
54
  @inactivity_timeout = options[:inactivity_timeout] ||= 10 # default connection inactivity (post-setup) timeout
53
55
 
54
56
 
55
- @using_tls = options[:tls] || options[:ssl] || false
56
- @using_tls.delete(:server) unless @using_tls == false
57
-
58
57
  uri = uri.kind_of?(Addressable::URI) ? uri : Addressable::URI::parse(uri.to_s)
59
- @https = uri.scheme == "https"
58
+ @https = uri.scheme == "https" || @using_tls
60
59
  uri.port ||= (@https ? 443 : 80)
60
+ @scheme = @https ? HTTPS : HTTP
61
61
 
62
62
 
63
63
  @loop = Libuv::Loop.current || Libuv::Loop.default
@@ -117,7 +117,7 @@ module UV
117
117
  }
118
118
 
119
119
  ##
120
- # TODO:: Add middleware here
120
+ # TODO:: Add response middleware here
121
121
  request.then blk if blk
122
122
 
123
123
  # Add to pending requests and schedule using the breakpoint
@@ -168,6 +168,9 @@ module UV
168
168
  @connecting = false
169
169
  @ready = true
170
170
 
171
+ # start tls if connection is encrypted
172
+ use_tls() if @https
173
+
171
174
  # Update timeouts
172
175
  stop_timer
173
176
  if @inactivity_timeout > 0
@@ -1,3 +1,3 @@
1
1
  module UV
2
- VERSION = '0.2.0'
2
+ VERSION = '0.2.1'
3
3
  end
@@ -15,9 +15,10 @@ module TestConnect
15
15
  @loop.stop
16
16
  end
17
17
 
18
- def on_read(data, connection, port = nil)
18
+ def on_read(data, connection, port = nil, udp_test = nil)
19
19
  @received = data
20
20
  close_connection(:after_writing)
21
+ @loop.stop if udp_test # misc is set when test connect is a UDP connection
21
22
  end
22
23
 
23
24
  def check
@@ -36,10 +37,8 @@ module TestServer
36
37
  write('hello')
37
38
  end
38
39
 
39
- def on_read(*args) #data, ip, port, conection)
40
- #p "was sent #{data} from port #{port}"
41
- #send_datagram(data, ip, port)
42
- @loop.stop
40
+ def on_read(data, ip, port, conection)
41
+ send_datagram(data, ip, port)
43
42
  end
44
43
  end
45
44
 
@@ -157,7 +156,7 @@ describe UV::Connection do
157
156
  res = @klass.check
158
157
  expect(res[0]).to eq(nil)
159
158
  expect(res[1]).to eq(nil)
160
- expect(res[2]).to eq(nil) #'hello' (libuv receive bug?)
159
+ expect(res[2]).to eq('hello')
161
160
  end
162
161
  end
163
162
  end
@@ -9,7 +9,7 @@ module HttpServer
9
9
  end
10
10
 
11
11
  def on_message_complete(parser)
12
- write("HTTP/1.1 200 OK\r\nContent-type: text/html\r\nContent-length: 0\r\n\r\n")
12
+ write("HTTP/1.1 200 OK\r\nContent-type: text/html\r\nContent-length: 1\r\n\r\ny")
13
13
  end
14
14
 
15
15
  def on_read(data, connection)
@@ -84,6 +84,8 @@ describe UV::HttpEndpoint do
84
84
  expect(@response[:headers].status).to eq(200)
85
85
  expect(@response[:headers].cookies).to eq({})
86
86
  expect(@response[:headers].keep_alive).to eq(true)
87
+
88
+ expect(@response[:body]).to eq('y')
87
89
  end
88
90
 
89
91
  it "should send multiple requests on the same connection", :network => true do
data/uv-rays.gemspec CHANGED
@@ -13,7 +13,7 @@ Gem::Specification.new do |gem|
13
13
  gem.required_ruby_version = '>= 1.9.2'
14
14
  gem.require_paths = ["lib"]
15
15
 
16
- gem.add_runtime_dependency 'libuv', '>= 0.11.19'
16
+ gem.add_runtime_dependency 'libuv', '>= 0.11.20'
17
17
  gem.add_runtime_dependency 'bisect'
18
18
  gem.add_runtime_dependency 'tzinfo'
19
19
  gem.add_runtime_dependency 'cookiejar'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: uv-rays
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stephen von Takach
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-01-08 00:00:00.000000000 Z
11
+ date: 2014-01-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: libuv
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 0.11.19
19
+ version: 0.11.20
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: 0.11.19
26
+ version: 0.11.20
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: bisect
29
29
  requirement: !ruby/object:Gem::Requirement