uv-rays 0.2.0 → 0.2.1
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.
- checksums.yaml +4 -4
- data/lib/uv-rays/connection.rb +2 -2
- data/lib/uv-rays/http/request.rb +1 -1
- data/lib/uv-rays/http_endpoint.rb +20 -17
- data/lib/uv-rays/version.rb +1 -1
- data/spec/connection_spec.rb +5 -6
- data/spec/http_endpoint_spec.rb +3 -1
- data/uv-rays.gemspec +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 062fbd42aaa4ac76d836fbf53f1d20c069b2b0e6
|
4
|
+
data.tar.gz: f282b28e0a2b1c6831f14091f87928be777ad061
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1d8151d7d1240523a47ab1902e75abd95a61f0a30fb76422e6da23e486b1321022dfdda115e686ff11b55cc27e58317ac39260415b808e47574429a45f560f90
|
7
|
+
data.tar.gz: 0d8a947d398f9be35e9a3f5c4192cabdf7a2a02cc38dcdac4f8628c4a9bb0c86dca16f98dcf30e1bdc67e71bb082244faaa2a7ca3efcdf8ba7866abc044e15e5
|
data/lib/uv-rays/connection.rb
CHANGED
@@ -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)
|
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
|
-
|
185
|
+
@loop.lookup(recipient_address).then do |result|
|
186
186
|
@transport.send result[0][0], recipient_port, data
|
187
187
|
end
|
188
188
|
end
|
data/lib/uv-rays/http/request.rb
CHANGED
@@ -26,17 +26,19 @@ module UV
|
|
26
26
|
end # CookieJar
|
27
27
|
|
28
28
|
|
29
|
-
class HttpEndpoint <
|
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
|
data/lib/uv-rays/version.rb
CHANGED
data/spec/connection_spec.rb
CHANGED
@@ -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(
|
40
|
-
|
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(
|
159
|
+
expect(res[2]).to eq('hello')
|
161
160
|
end
|
162
161
|
end
|
163
162
|
end
|
data/spec/http_endpoint_spec.rb
CHANGED
@@ -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:
|
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.
|
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.
|
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-
|
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
|
+
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.
|
26
|
+
version: 0.11.20
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: bisect
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|