tcp-client 0.0.4 → 0.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.
- checksums.yaml +4 -4
- data/README.md +1 -2
- data/lib/tcp-client/configuration.rb +6 -0
- data/lib/tcp-client/version.rb +1 -1
- data/sample/google.rb +1 -2
- data/sample/google_ssl.rb +1 -2
- data/test/tcp-client/configuration_test.rb +13 -1
- data/test/tcp_client_test.rb +2 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0bbd00fbb75a986e3ba4bf816193116bf727ec5dbbf7f8a668a9ceebb949d095
|
4
|
+
data.tar.gz: f9ec77cfb580fe6d441f9cd34d50f62417406551ef4a5b2d88aa0abdc566c2ed
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4ea1b91dd045ef05aab409a82161b2ec80d1e033744f036445c476f97b125bd5ac1ee4cf563ea27d5f26821a78995b274d1340ebf1ae2633da36867a3cfe26bd
|
7
|
+
data.tar.gz: 16abbb3a36204bb56f8fc9d3193bbb9460da2cb2e11677a0ffe10a175ed862250ff19c740c71b81fc2c99724c71e9a419f9388c0a881c806ad6af1f9a8fa13d6
|
data/README.md
CHANGED
@@ -18,8 +18,7 @@ end
|
|
18
18
|
# the following request sequence is not allowed to last longer than 2 seconds:
|
19
19
|
# 1 second to connect (incl. SSL handshake etc.)
|
20
20
|
# + 0.25 seconds to write data
|
21
|
-
# + 0.5 seconds to read
|
22
|
-
# a response
|
21
|
+
# + 0.5 seconds to read a response
|
23
22
|
TCPClient.open('www.google.com:443', configuration) do |client|
|
24
23
|
pp client.write("GET / HTTP/1.1\r\nHost: google.com\r\n\r\n") # simple HTTP get request
|
25
24
|
pp client.read(12) # "HTTP/1.1 " + 3 byte HTTP status code
|
@@ -18,6 +18,12 @@ class TCPClient
|
|
18
18
|
@ssl_params ? true : false
|
19
19
|
end
|
20
20
|
|
21
|
+
def ssl=(yn)
|
22
|
+
return @ssl_params = nil unless yn
|
23
|
+
return @ssl_params = yn if Hash === yn
|
24
|
+
@ssl_params = {} unless @ssl_params
|
25
|
+
end
|
26
|
+
|
21
27
|
def buffered=(yn)
|
22
28
|
@buffered = yn ? true : false
|
23
29
|
end
|
data/lib/tcp-client/version.rb
CHANGED
data/sample/google.rb
CHANGED
@@ -9,8 +9,7 @@ end
|
|
9
9
|
# the following request sequence is not allowed to last longer than 1.25 seconds:
|
10
10
|
# 0.5 seconds to connect
|
11
11
|
# + 0.25 seconds to write data
|
12
|
-
# + 0.5 seconds to read
|
13
|
-
# a response
|
12
|
+
# + 0.5 seconds to read a response
|
14
13
|
TCPClient.open('www.google.com:80', configuration) do |client|
|
15
14
|
pp client.write("GET / HTTP/1.1\r\nHost: google.com\r\n\r\n") # simple HTTP get request
|
16
15
|
pp client.read(12) # "HTTP/1.1 " + 3 byte HTTP status code
|
data/sample/google_ssl.rb
CHANGED
@@ -10,8 +10,7 @@ end
|
|
10
10
|
# the following request sequence is not allowed to last longer than 2 seconds:
|
11
11
|
# 1 second to connect (incl. SSL handshake etc.)
|
12
12
|
# + 0.25 seconds to write data
|
13
|
-
# + 0.5 seconds to read
|
14
|
-
# a response
|
13
|
+
# + 0.5 seconds to read a response
|
15
14
|
TCPClient.open('www.google.com:443', configuration) do |client|
|
16
15
|
pp client.write("GET / HTTP/1.1\r\nHost: google.com\r\n\r\n") # simple HTTP get request
|
17
16
|
pp client.read(12) # "HTTP/1.1 " + 3 byte HTTP status code
|
@@ -16,7 +16,7 @@ class ConfigurationTest < Test
|
|
16
16
|
subject = TCPClient::Configuration.create do |cfg|
|
17
17
|
cfg.buffered = cfg.keep_alive = cfg.reverse_lookup = false
|
18
18
|
cfg.timeout = 42
|
19
|
-
cfg.
|
19
|
+
cfg.ssl = true
|
20
20
|
end
|
21
21
|
refute(subject.buffered)
|
22
22
|
refute(subject.keep_alive)
|
@@ -27,6 +27,18 @@ class ConfigurationTest < Test
|
|
27
27
|
assert(subject.ssl?)
|
28
28
|
end
|
29
29
|
|
30
|
+
def test_ssl_params
|
31
|
+
subject = TCPClient::Configuration.new
|
32
|
+
refute(subject.ssl?)
|
33
|
+
assert_nil(subject.ssl_params)
|
34
|
+
subject.ssl = true
|
35
|
+
assert(subject.ssl?)
|
36
|
+
assert_empty(subject.ssl_params)
|
37
|
+
subject.ssl_params[:ssl_version] = :TLSv1_2
|
38
|
+
subject.ssl = false
|
39
|
+
assert_nil(subject.ssl_params)
|
40
|
+
end
|
41
|
+
|
30
42
|
def test_timeout_overwrite
|
31
43
|
subject = TCPClient::Configuration.create do |cfg|
|
32
44
|
cfg.connect_timeout = 1
|
data/test/tcp_client_test.rb
CHANGED
@@ -98,9 +98,8 @@ class TCPClientTest < Test
|
|
98
98
|
|
99
99
|
def test_connect_ssl_timeout
|
100
100
|
server = TCPServer.new(1236)
|
101
|
-
config = TCPClient::Configuration.
|
102
|
-
|
103
|
-
end
|
101
|
+
config = TCPClient::Configuration.new
|
102
|
+
config.ssl = true
|
104
103
|
[0.5, 1, 1.5].each do |timeout|
|
105
104
|
config.timeout = timeout
|
106
105
|
check_connect_timeout('localhost:1236', config, timeout)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tcp-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mike Blumtritt
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-02-
|
11
|
+
date: 2018-02-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|