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 +4 -4
- data/lib/spider-gazelle/gazelle.rb +1 -3
- data/lib/spider-gazelle/gazelle/http1.rb +26 -23
- data/lib/spider-gazelle/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: be341884962cab440eacc49473a1fe8727e74023
|
4
|
+
data.tar.gz: fac733a36868410a4733d2720faa79fb1435d3db
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: edf7132a30603414e03d3fca0399851b02bd94dcedb6895ca6f30ca1323901e79ef163ca336b80f521aab52eb705b2e7e15214dd1f297d8a265d88c573668e73
|
7
|
+
data.tar.gz: e87a60598ea47211402366ca3c6d8fce2bdcb161998720ea7e03f17f311cd22fb3422005bcfd93bc2a45cb9168b3408efc8c752b9d6f6f8b0ce93f99305d4be4
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
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
|
-
|
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
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
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
|
-
|
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
|
-
|
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
|
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.
|
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:
|
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.
|
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
|