spider-gazelle 3.0.3 → 3.0.4

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
  SHA1:
3
- metadata.gz: 89774225b2801a3f2556563940da21588a6fef70
4
- data.tar.gz: 441d840391e7ccb87d98b4bd2830b80a2ed6b1e6
3
+ metadata.gz: be341884962cab440eacc49473a1fe8727e74023
4
+ data.tar.gz: fac733a36868410a4733d2720faa79fb1435d3db
5
5
  SHA512:
6
- metadata.gz: 96c3c3b76bf21d2756db7e9b51a50f4125ed26a8b60f12ba8e789b0e73aff65ccdd0a933254485bb600f340ce82b42f9bc8c324deb27eec29a1f14002c762712
7
- data.tar.gz: 1208f6382502b44b2f02099fd527441d0e923100c7c26801fd5582a48fb53c698d25672e7b85f4f95ddd159ca7c29d7570523bf514b389a64fdbf137855d75b4
6
+ metadata.gz: edf7132a30603414e03d3fca0399851b02bd94dcedb6895ca6f30ca1323901e79ef163ca336b80f521aab52eb705b2e7e15214dd1f297d8a265d88c573668e73
7
+ data.tar.gz: e87a60598ea47211402366ca3c6d8fce2bdcb161998720ea7e03f17f311cd22fb3422005bcfd93bc2a45cb9168b3408efc8c752b9d6f6f8b0ce93f99305d4be4
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "rack" # Ruby webserver abstraction
3
+ require 'rack' # Ruby webserver abstraction
4
4
  require 'spider-gazelle/gazelle/app_store'
5
5
  require 'spider-gazelle/gazelle/http1'
6
6
 
@@ -11,8 +11,6 @@ require "spider-gazelle/upgrades/websocket"
11
11
 
12
12
  module SpiderGazelle
13
13
  class Gazelle
14
- SPACE = ' '
15
-
16
14
  def initialize(thread, type)
17
15
  raise ArgumentError, "type must be one of #{MODES}" unless MODES.include?(type)
18
16
 
@@ -246,15 +246,31 @@ module SpiderGazelle
246
246
 
247
247
  # If a file, stream the body in a non-blocking fashion
248
248
  if body.respond_to? :to_path
249
- file = @thread.file body.to_path, File::RDONLY
249
+ begin
250
+ file = @thread.file body.to_path, File::RDONLY, wait: true
251
+
252
+ file.catch do |err|
253
+ @logger.warn "Error reading file: #{err}"
254
+
255
+ if data_written
256
+ file.close
257
+ @socket.shutdown
258
+ else
259
+ send_internal_error
260
+ end
261
+ end
262
+
263
+ # Request has completed - send the next one
264
+ file.finally do
265
+ send_next_response
266
+ end
250
267
 
251
- # Send the body in parallel without blocking the next request in dev
252
- # Also if this is a head request we still want the body closed
253
- body.close if body.respond_to?(:close)
254
- data_written = false
268
+ # Send the body in parallel without blocking the next request in dev
269
+ # Also if this is a head request we still want the body closed
270
+ body.close if body.respond_to?(:close)
271
+ data_written = false
255
272
 
256
- file.progress do
257
- statprom = file.stat
273
+ statprom = file.stat wait: false
258
274
  statprom.then do |stats|
259
275
  #etag = ::Digest::MD5.hexdigest "#{stats[:st_mtim][:tv_sec]}#{body.to_path}"
260
276
  #if etag == request.env[HTTP_ETAG]
@@ -278,7 +294,7 @@ module SpiderGazelle
278
294
 
279
295
  if send_body
280
296
  # File is open and available for reading
281
- promise = file.send_file(@socket, type)
297
+ promise = file.send_file(@socket, using: type)
282
298
  promise.then do
283
299
  file.close
284
300
  @socket.shutdown if request.keep_alive == false
@@ -298,22 +314,9 @@ module SpiderGazelle
298
314
  file.close
299
315
  send_internal_error
300
316
  end
301
- end
302
-
303
- file.catch do |err|
317
+ rescue => err
304
318
  @logger.warn "Error reading file: #{err}"
305
-
306
- if data_written
307
- file.close
308
- @socket.shutdown
309
- else
310
- send_internal_error
311
- end
312
- end
313
-
314
- # Request has completed - send the next one
315
- file.finally do
316
- send_next_response
319
+ send_internal_error
317
320
  end
318
321
  else
319
322
  # Optimize the response
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SpiderGazelle
4
- VERSION = '3.0.3'
4
+ VERSION = '3.0.4'
5
5
  EXEC_NAME = 'sg'
6
6
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spider-gazelle
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.3
4
+ version: 3.0.4
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: 2016-11-25 00:00:00.000000000 Z
11
+ date: 2017-03-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: http-parser
@@ -189,7 +189,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
189
189
  version: '0'
190
190
  requirements: []
191
191
  rubyforge_project:
192
- rubygems_version: 2.5.1
192
+ rubygems_version: 2.6.10
193
193
  signing_key:
194
194
  specification_version: 4
195
195
  summary: A fast, parallel and concurrent web server for ruby