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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1100d0c6684061225cff8107b369fe38d56454f3e5bb4c7efd4a7e2c07adc491
4
- data.tar.gz: 584cda11bc5398b9dd1574ea1e459a4ec963cf73195a5a200bdd520aa9725ece
3
+ metadata.gz: 0bbd00fbb75a986e3ba4bf816193116bf727ec5dbbf7f8a668a9ceebb949d095
4
+ data.tar.gz: f9ec77cfb580fe6d441f9cd34d50f62417406551ef4a5b2d88aa0abdc566c2ed
5
5
  SHA512:
6
- metadata.gz: eafb90f60c331022b7115d291ede9334a6963842ba453329dff11d2ae9c208c5cc8acf2afaa9f4b377d20a3bddb6c60ab7baeccc0bee77a3b17665a2df18587f
7
- data.tar.gz: 7d174d7172e9d1da102da679741f655e8bda71f888e3b68868d1ec993cd9f82ba8ed6f185be58483296c77868eefce4c2897b79e2fcb1fe71b52c6774b05fb6a
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
@@ -1,3 +1,3 @@
1
1
  class TCPClient
2
- VERSION = '0.0.4'.freeze
2
+ VERSION = '0.0.5'.freeze
3
3
  end
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.ssl_params = {}
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
@@ -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.create do |cfg|
102
- cfg.ssl_params = {}
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
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-18 00:00:00.000000000 Z
11
+ date: 2018-02-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler