tipi 0.49 → 0.52

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
  SHA256:
3
- metadata.gz: 4b39df2bde7e106405baeaa5cea41987fc709bd453c08aa0ec299ce925a7f957
4
- data.tar.gz: '0689c72ff5d79cbdf4a4b4141791701428ee1a1820fdfc1580587d5863a433e8'
3
+ metadata.gz: efec664af01dfb4781c30670e2471a591a6c8df3a8024b5f14dc4edded3f5c1d
4
+ data.tar.gz: 0f384c5a305c5afe524b9a0e28d2a06931340275fe879e963cc194d2cde3c766
5
5
  SHA512:
6
- metadata.gz: 109d929246c4aa7f3e2909128ba8d95fc0fdb4dd73e89e15f528d8eb55ec2cc2e5de7881de4d67b25dbfb234e2cb27a73c7cc19264a7b1b81a24fc75b7caf9ad
7
- data.tar.gz: c61d8d3b4edd034c3c1ddcac5a87fa33598498a68d93d94691d45bdacb4accc148cfa9e40a8ee8aa3aa9101b6689259c631bd40adc2825922f0b7be5a7565c17
6
+ metadata.gz: 7aa3995cd7ad560f3ba0f8a318da6c5ef62d53bc02209f05491f1e3db5b140e2697e8cd3158686a62c3dbae373d0260d803befabf4b8c417e862f2e6f68860bf
7
+ data.tar.gz: 7a17368c2fd9572531ac137822727082e48b85322190b91197f699d34d0554fd39d5dc7a18fe6f68bf8ea64dadbabbb464f39fa2b83475ee52cee99484c422a5
@@ -7,22 +7,26 @@ jobs:
7
7
  strategy:
8
8
  fail-fast: false
9
9
  matrix:
10
- os: [ubuntu-latest]
11
- ruby: [2.6, 2.7, 3.0]
10
+ os: [ubuntu-latest, macos-latest]
11
+ ruby: ['2.7', '3.0', '3.1', 'head']
12
12
 
13
13
  name: >-
14
14
  ${{matrix.os}}, ${{matrix.ruby}}
15
15
 
16
16
  runs-on: ${{matrix.os}}
17
+
18
+ env:
19
+ POLYPHONY_USE_LIBEV: "1"
20
+
17
21
  steps:
18
- - uses: actions/checkout@v1
19
- - uses: actions/setup-ruby@v1
22
+ - name: Setup machine
23
+ uses: actions/checkout@v1
24
+ - name: Setup Ruby
25
+ uses: ruby/setup-ruby@v1
20
26
  with:
21
27
  ruby-version: ${{matrix.ruby}}
22
- - name: Install dependencies
23
- run: |
24
- gem install bundler
25
- POLYPHONY_USE_LIBEV=1 bundle install
28
+ bundler-cache: true # 'bundle install' and cache
29
+ cache-version: 2
26
30
  - name: Show Linux kernel version
27
31
  run: uname -r
28
32
  - name: Run tests
data/CHANGELOG.md CHANGED
@@ -1,3 +1,15 @@
1
+ ## 0.52 2022-03-03
2
+
3
+ - Treat HTTP/2 headers as immutable
4
+
5
+ ## 0.51 2022-02-28
6
+
7
+ - Update dependencies
8
+
9
+ ## 0.50 2022-02-10
10
+
11
+ - Update Qeweney
12
+
1
13
  ## 0.49 2022-02-07
2
14
 
3
15
  - Update Polyphony
data/Gemfile CHANGED
@@ -1,9 +1,3 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
3
  gemspec
4
-
5
- # for local development
6
- %w{polyphony ever qeweney h1p}.each do |dep|
7
- dir = "../#{dep}"
8
- gem(dep, path: dir) if File.directory?(dir)
9
- end
data/Gemfile.lock CHANGED
@@ -1,37 +1,16 @@
1
- PATH
2
- remote: ../ever
3
- specs:
4
- ever (0.1)
5
-
6
- PATH
7
- remote: ../h1p
8
- specs:
9
- h1p (0.3)
10
-
11
- PATH
12
- remote: ../polyphony
13
- specs:
14
- polyphony (0.77)
15
-
16
- PATH
17
- remote: ../qeweney
18
- specs:
19
- qeweney (0.16)
20
- escape_utils (~> 1.2.1)
21
-
22
1
  PATH
23
2
  remote: .
24
3
  specs:
25
- tipi (0.49)
4
+ tipi (0.52)
26
5
  acme-client (~> 2.0.9)
27
6
  ever (~> 0.1)
28
- extralite (~> 1.2)
29
- h1p (~> 0.3)
7
+ extralite (~> 1.14)
8
+ h1p (~> 0.4)
30
9
  http-2 (~> 0.11)
31
10
  localhost (~> 1.1.4)
32
11
  msgpack (~> 1.4.2)
33
- polyphony (~> 0.77)
34
- qeweney (~> 0.14)
12
+ polyphony (~> 0.80)
13
+ qeweney (~> 0.18)
35
14
  rack (>= 2.0.8, < 2.3.0)
36
15
  websocket (~> 1.2.8)
37
16
 
@@ -44,8 +23,9 @@ GEM
44
23
  rack (>= 1.6.0)
45
24
  docile (1.4.0)
46
25
  escape_utils (1.2.1)
47
- extralite (1.11)
48
- faraday (1.9.3)
26
+ ever (0.1)
27
+ extralite (1.14)
28
+ faraday (1.10.0)
49
29
  faraday-em_http (~> 1.0)
50
30
  faraday-em_synchrony (~> 1.0)
51
31
  faraday-excon (~> 1.1)
@@ -68,13 +48,17 @@ GEM
68
48
  faraday-patron (1.0.0)
69
49
  faraday-rack (1.0.0)
70
50
  faraday-retry (1.0.3)
51
+ h1p (0.4)
71
52
  http-2 (0.11.0)
72
53
  json (2.6.1)
73
54
  localhost (1.1.9)
74
55
  memory_profiler (1.0.0)
75
56
  minitest (5.11.3)
76
- msgpack (1.4.4)
57
+ msgpack (1.4.5)
77
58
  multipart-post (2.1.1)
59
+ polyphony (0.81)
60
+ qeweney (0.18)
61
+ escape_utils (~> 1.2.1)
78
62
  rack (2.2.3)
79
63
  rake (13.0.6)
80
64
  ruby2_keywords (0.0.5)
@@ -90,12 +74,8 @@ PLATFORMS
90
74
 
91
75
  DEPENDENCIES
92
76
  cuba (~> 3.9.3)
93
- ever!
94
- h1p!
95
77
  memory_profiler (~> 1.0.0)
96
78
  minitest (~> 5.11.3)
97
- polyphony!
98
- qeweney!
99
79
  rake (~> 13.0.6)
100
80
  simplecov (~> 0.17.1)
101
81
  tipi!
data/df/server_utils.rb CHANGED
@@ -162,11 +162,11 @@ if ENV['TRACE'] == '1'
162
162
  Thread.backend.trace_proc = proc do |event, fiber, value, pri|
163
163
  fiber_id = fiber.tag || fiber.inspect
164
164
  case event
165
- when :fiber_schedule
165
+ when :schedule
166
166
  log format("=> %s %s %s %s", event, fiber_id, value.inspect, pri ? '(priority)' : '')
167
- when :fiber_run
167
+ when :unblock
168
168
  log format("=> %s %s %s", event, fiber_id, value.inspect)
169
- when :fiber_create, :fiber_terminate
169
+ when :spin, :terminate
170
170
  log format("=> %s %s", event, fiber_id)
171
171
  else
172
172
  log format("=> %s", event)
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ run { |req|
4
+ req.serve_file(__FILE__)
5
+ }
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ run { |req|
4
+ req.send_headers('Content-Type' => 'text/event-stream')
5
+ 10.times { |i|
6
+ sleep 0.1
7
+ req.send_chunk("data: #{i.to_s * 40}\n")
8
+ }
9
+ req.finish
10
+ }
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ FILE_SIZES = {
4
+ 's.tmp' => 2**10,
5
+ 'm.tmp' => 2**17,
6
+ 'l.tmp' => 2**20,
7
+ 'xl.tmp' => 2**24
8
+ }
9
+
10
+ def create_files
11
+ FILE_SIZES.each { |fn, size|
12
+ IO.write(File.join('/tmp', fn), '*' * size)
13
+ }
14
+ end
15
+
16
+ create_files
17
+
18
+ run { |req|
19
+ file_path = File.join('/tmp', req.path)
20
+ if File.file?(file_path)
21
+ req.serve_file(file_path)
22
+ else
23
+ req.respond(nil, ':status' => 404)
24
+ end
25
+ }
@@ -24,9 +24,9 @@ module Tipi
24
24
  private
25
25
 
26
26
  def supervise_workers(worker_count)
27
- supervisor = spin do
27
+ supervisor = spin(:web_worker_supervisor) do
28
28
  worker_count.times do
29
- spin do
29
+ spin(:web_worker) do
30
30
  pid = Polyphony.fork { run_worker }
31
31
  puts "Forked worker pid: #{pid}"
32
32
  Polyphony.backend_waitpid(pid)
@@ -251,7 +251,7 @@ module Tipi
251
251
  }.freeze
252
252
 
253
253
  def spin_accept_loop(name, port, &block)
254
- spin do
254
+ spin(:accept_loop) do
255
255
  server = Polyphony::Net.tcp_listen('0.0.0.0', port, SOCKET_OPTS)
256
256
  loop do
257
257
  socket = server.accept
@@ -267,7 +267,7 @@ module Tipi
267
267
  end
268
268
 
269
269
  def spin_connection_handler(name, socket, block)
270
- spin do
270
+ spin(:connection_handler) do
271
271
  block.(socket)
272
272
  rescue Polyphony::BaseException
273
273
  raise
@@ -288,7 +288,7 @@ module Tipi
288
288
  end
289
289
 
290
290
  def gracefully_terminate_conections(fiber)
291
- supervisor = spin { supervise }.detach
291
+ supervisor = spin(:connection_termination_supervisor) { supervise }.detach
292
292
  fiber.attach_all_children_to(supervisor)
293
293
 
294
294
  # terminating the supervisor will
@@ -344,7 +344,7 @@ module Tipi
344
344
  end
345
345
 
346
346
  def start_server(service)
347
- spin do
347
+ spin(:web_server) do
348
348
  service.call
349
349
  supervise(restart: :always)
350
350
  end
@@ -220,10 +220,15 @@ module Tipi
220
220
  # @param done [boolean] whether the response is completed
221
221
  # @return [void]
222
222
  def send_chunk(request, chunk, done: false)
223
- data = +''
224
- data << "#{chunk.bytesize.to_s(16)}\r\n#{chunk}\r\n" if chunk
225
- data << "0\r\n\r\n" if done
226
- return if data.empty?
223
+ if done
224
+ data = chunk ?
225
+ "#{chunk.bytesize.to_s(16)}\r\n#{chunk}\r\n0\r\n\r\n" :
226
+ "0\r\n\r\n"
227
+ elsif chunk
228
+ data = "#{chunk.bytesize.to_s(16)}\r\n#{chunk}\r\n"
229
+ else
230
+ return
231
+ end
227
232
 
228
233
  request.tx_incr(data.bytesize)
229
234
  @conn.write(data)
@@ -113,21 +113,19 @@ module Tipi
113
113
  end
114
114
 
115
115
  # response API
116
- def respond(request, chunk, headers)
117
- headers[':status'] ||= Qeweney::Status::OK
118
- headers[':status'] = headers[':status'].to_s
116
+ def respond(request, body, headers)
117
+ headers = normalize_status_header(headers)
119
118
  with_transfer_count(request) do
120
119
  @stream.headers(transform_headers(headers))
121
120
  @headers_sent = true
122
- @stream.data(chunk || '')
121
+ @stream.data(body || '')
123
122
  end
124
123
  rescue HTTP2::Error::StreamClosed
125
124
  # ignore
126
125
  end
127
126
 
128
127
  def respond_from_io(request, io, headers, chunk_size = 2**16)
129
- headers[':status'] ||= Qeweney::Status::OK
130
- headers[':status'] = headers[':status'].to_s
128
+ headers = normalize_status_header(headers)
131
129
  with_transfer_count(request) do
132
130
  @stream.headers(transform_headers(headers))
133
131
  @headers_sent = true
@@ -152,7 +150,8 @@ module Tipi
152
150
  def send_headers(request, headers, empty_response: false)
153
151
  return if @headers_sent
154
152
 
155
- headers[':status'] ||= (empty_response ? Qeweney::Status::NO_CONTENT : Qeweney::Status::OK).to_s
153
+ status = empty_response ? Qeweney::Status::NO_CONTENT : Qeweney::Status::OK
154
+ headers = normalize_status_header(headers, status)
156
155
  with_transfer_count(request) do
157
156
  @stream.headers(transform_headers(headers), end_stream: false)
158
157
  end
@@ -194,5 +193,17 @@ module Tipi
194
193
  @stream.close
195
194
  @stream_fiber.schedule(Polyphony::MoveOn.new)
196
195
  end
196
+
197
+ private
198
+
199
+ def normalize_status_header(headers, default_status = Qeweney::Status::OK)
200
+ if !headers[':status']
201
+ headers.merge(':status' => default_status.to_s)
202
+ elsif !headers[':status'].is_a?(String)
203
+ headers.merge(headers[':status'].to_s)
204
+ else
205
+ headers
206
+ end
207
+ end
197
208
  end
198
209
  end
data/lib/tipi/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Tipi
4
- VERSION = '0.49'
4
+ VERSION = '0.52'
5
5
  end
data/test/helper.rb CHANGED
@@ -76,16 +76,16 @@ class IO
76
76
 
77
77
  def self.mockup_connection(input, output, output2)
78
78
  eg(
79
- __parser_read_method__: ->() { :readpartial },
80
- read: ->(*args) { input.read(*args) },
81
- read_loop: ->(*args, &block) { input.read_loop(*args, &block) },
82
- recv_loop: ->(*args, &block) { input.read_loop(*args, &block) },
83
- readpartial: ->(*args) { input.readpartial(*args) },
84
- recv: ->(*args) { input.readpartial(*args) },
85
- '<<': ->(*args) { output.write(*args) },
86
- write: ->(*args) { output.write(*args) },
87
- close: -> { output.close },
88
- eof?: -> { output2.closed? }
79
+ __read_method__: -> { :readpartial },
80
+ read: ->(*args) { input.read(*args) },
81
+ read_loop: ->(*args, &block) { input.read_loop(*args, &block) },
82
+ recv_loop: ->(*args, &block) { input.read_loop(*args, &block) },
83
+ readpartial: ->(*args) { input.readpartial(*args) },
84
+ recv: ->(*args) { input.readpartial(*args) },
85
+ '<<': ->(*args) { output.write(*args) },
86
+ write: ->(*args) { output.write(*args) },
87
+ close: -> { output.close },
88
+ eof?: -> { output2.closed? }
89
89
  )
90
90
  end
91
91
  end
data/tipi.gemspec CHANGED
@@ -10,20 +10,23 @@ Gem::Specification.new do |s|
10
10
  s.files = `git ls-files`.split
11
11
  s.homepage = 'http://github.com/digital-fabric/tipi'
12
12
  s.metadata = {
13
- "source_code_uri" => "https://github.com/digital-fabric/tipi"
13
+ "source_code_uri" => "https://github.com/digital-fabric/tipi",
14
+ "documentation_uri" => "https://www.rubydoc.info/gems/tipi",
15
+ "homepage_uri" => "https://github.com/digital-fabric/tipi",
16
+ "changelog_uri" => "https://github.com/digital-fabric/tipi/blob/master/CHANGELOG.md"
14
17
  }
15
18
  s.rdoc_options = ["--title", "tipi", "--main", "README.md"]
16
19
  s.extra_rdoc_files = ["README.md"]
17
20
  s.require_paths = ["lib"]
18
- s.required_ruby_version = '>= 2.6'
21
+ s.required_ruby_version = '>= 2.7'
19
22
 
20
23
  s.executables = ['tipi']
21
24
 
22
- s.add_runtime_dependency 'polyphony', '~>0.77'
25
+ s.add_runtime_dependency 'polyphony', '~>0.80'
23
26
  s.add_runtime_dependency 'ever', '~>0.1'
24
- s.add_runtime_dependency 'qeweney', '~>0.14'
25
- s.add_runtime_dependency 'extralite', '~>1.2'
26
- s.add_runtime_dependency 'h1p', '~>0.3'
27
+ s.add_runtime_dependency 'qeweney', '~>0.18'
28
+ s.add_runtime_dependency 'extralite', '~>1.14'
29
+ s.add_runtime_dependency 'h1p', '~>0.4'
27
30
 
28
31
  s.add_runtime_dependency 'http-2', '~>0.11'
29
32
  s.add_runtime_dependency 'rack', '>=2.0.8', '<2.3.0'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tipi
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.49'
4
+ version: '0.52'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sharon Rosner
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-02-07 00:00:00.000000000 Z
11
+ date: 2022-03-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: polyphony
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0.77'
19
+ version: '0.80'
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.77'
26
+ version: '0.80'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: ever
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -44,42 +44,42 @@ dependencies:
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '0.14'
47
+ version: '0.18'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '0.14'
54
+ version: '0.18'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: extralite
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '1.2'
61
+ version: '1.14'
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: '1.2'
68
+ version: '1.14'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: h1p
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: '0.3'
75
+ version: '0.4'
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: '0.3'
82
+ version: '0.4'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: http-2
85
85
  requirement: !ruby/object:Gem::Requirement
@@ -240,7 +240,7 @@ dependencies:
240
240
  - - "~>"
241
241
  - !ruby/object:Gem::Version
242
242
  version: 3.9.3
243
- description:
243
+ description:
244
244
  email: sharon@noteflakes.com
245
245
  executables:
246
246
  - tipi
@@ -305,12 +305,15 @@ files:
305
305
  - examples/rack_server_https_forked.rb
306
306
  - examples/routing_server.rb
307
307
  - examples/servername_cb.rb
308
+ - examples/source.rb
309
+ - examples/streaming.rb
308
310
  - examples/websocket_client.rb
309
311
  - examples/websocket_demo.rb
310
312
  - examples/websocket_secure_server.rb
311
313
  - examples/websocket_server.rb
312
314
  - examples/ws_page.html
313
315
  - examples/wss_page.html
316
+ - examples/zlib-bench.rb
314
317
  - lib/tipi.rb
315
318
  - lib/tipi/acme.rb
316
319
  - lib/tipi/cli.rb
@@ -352,7 +355,10 @@ licenses:
352
355
  - MIT
353
356
  metadata:
354
357
  source_code_uri: https://github.com/digital-fabric/tipi
355
- post_install_message:
358
+ documentation_uri: https://www.rubydoc.info/gems/tipi
359
+ homepage_uri: https://github.com/digital-fabric/tipi
360
+ changelog_uri: https://github.com/digital-fabric/tipi/blob/master/CHANGELOG.md
361
+ post_install_message:
356
362
  rdoc_options:
357
363
  - "--title"
358
364
  - tipi
@@ -364,15 +370,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
364
370
  requirements:
365
371
  - - ">="
366
372
  - !ruby/object:Gem::Version
367
- version: '2.6'
373
+ version: '2.7'
368
374
  required_rubygems_version: !ruby/object:Gem::Requirement
369
375
  requirements:
370
376
  - - ">="
371
377
  - !ruby/object:Gem::Version
372
378
  version: '0'
373
379
  requirements: []
374
- rubygems_version: 3.3.3
375
- signing_key:
380
+ rubygems_version: 3.1.6
381
+ signing_key:
376
382
  specification_version: 4
377
383
  summary: Tipi - the All-in-one Web Server for Ruby Apps
378
384
  test_files: []