slow_server 0.1.0 → 0.1.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/exe/slow_client +7 -0
- data/lib/slow_server/client.rb +43 -0
- data/lib/slow_server/config.rb +0 -4
- data/lib/slow_server/server.rb +4 -1
- data/lib/slow_server/version.rb +1 -1
- data/lib/slow_server.rb +1 -0
- metadata +4 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 98a454a46560f8b71016c5c592610d4da07bb4ad
|
4
|
+
data.tar.gz: d0025614da0c095da1d88de6f2ad743962470621
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2e727d936277e662731f0910f22a53f3c300dd0aee64200f9eca44365a756a2198994fde9f9aedce0622a98fcb6a2ebf4f0e138f52c1a711f1dd589495672aa7
|
7
|
+
data.tar.gz: 2571c0b2c24a5d9434a354a833e135cb7e8e3beed4f09fb97e0b48b9a5f0e27182dbf4e86df3fbfad27bee1262227d0c944483ac070b5576ab0e3229a0aebe08
|
data/exe/slow_client
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'socket'
|
2
|
+
|
3
|
+
module SlowServer
|
4
|
+
class Client
|
5
|
+
|
6
|
+
def config
|
7
|
+
SlowServer.config
|
8
|
+
end
|
9
|
+
|
10
|
+
def chunk_size
|
11
|
+
(request.size / config.chunks.to_f).ceil
|
12
|
+
end
|
13
|
+
|
14
|
+
def chunks
|
15
|
+
request.scan(/.{1,#{chunk_size}}/m)
|
16
|
+
end
|
17
|
+
|
18
|
+
def request
|
19
|
+
"GET /"
|
20
|
+
end
|
21
|
+
|
22
|
+
def start
|
23
|
+
TCPSocket.open("127.0.0.1", 4000) do |socket|
|
24
|
+
STDERR.puts "Waiting for #{config.response_delay} seconds"
|
25
|
+
sleep config.response_delay
|
26
|
+
|
27
|
+
chunks.each do |chunk|
|
28
|
+
STDERR.puts "Sending #{chunk_size} bytes"
|
29
|
+
socket.print chunk
|
30
|
+
STDERR.puts "Waiting for #{config.chunk_delay} seconds"
|
31
|
+
sleep config.chunk_delay
|
32
|
+
end
|
33
|
+
socket.print("\r\n\r\n")
|
34
|
+
|
35
|
+
response = socket.read
|
36
|
+
headers,body = response.split("\r\n\r\n", 2)
|
37
|
+
STDERR.puts "\n"
|
38
|
+
print body
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
43
|
+
end
|
data/lib/slow_server/config.rb
CHANGED
data/lib/slow_server/server.rb
CHANGED
@@ -11,8 +11,11 @@ module SlowServer
|
|
11
11
|
@server ||= TCPServer.open('0.0.0.0', config.port)
|
12
12
|
end
|
13
13
|
|
14
|
+
def chunk_size
|
15
|
+
config.response.size / config.chunks
|
16
|
+
end
|
17
|
+
|
14
18
|
def chunks
|
15
|
-
#config.response.unpack("a#{config.chunks}"*(config.response.size/config.chunks))
|
16
19
|
config.response.scan(/.{1,#{config.chunk_size}}/m)
|
17
20
|
end
|
18
21
|
|
data/lib/slow_server/version.rb
CHANGED
data/lib/slow_server.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: slow_server
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jason Scholl
|
@@ -71,6 +71,7 @@ description: Simple web server and client with adjustable delays for testing tim
|
|
71
71
|
email:
|
72
72
|
- jason.e.scholl@gmail.com
|
73
73
|
executables:
|
74
|
+
- slow_client
|
74
75
|
- slow_server
|
75
76
|
extensions: []
|
76
77
|
extra_rdoc_files: []
|
@@ -84,9 +85,11 @@ files:
|
|
84
85
|
- Rakefile
|
85
86
|
- bin/console
|
86
87
|
- bin/setup
|
88
|
+
- exe/slow_client
|
87
89
|
- exe/slow_server
|
88
90
|
- files/response.txt
|
89
91
|
- lib/slow_server.rb
|
92
|
+
- lib/slow_server/client.rb
|
90
93
|
- lib/slow_server/config.rb
|
91
94
|
- lib/slow_server/server.rb
|
92
95
|
- lib/slow_server/version.rb
|