lowloop 0.8.10 → 0.8.12
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/lib/connections/connection_manager.rb +25 -0
- data/lib/servers/file_server.rb +8 -1
- data/lib/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 6b0bd2b3e783808038db19c6939be1a9a5bed9613c3a4ffed8eb68826a09c01b
|
|
4
|
+
data.tar.gz: d6a444d20f63010a16592955f07d25ab3a98253ab7e5e19af656ea81a9a3832c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 52176738f1f151968d630f49949c846c9a44b54a0094392cee18f3fd0f4e1cff83533996a65c95b08b0025b46403be6d0fe2f04376420f233d79625eca99aa42
|
|
7
|
+
data.tar.gz: 5421f9843ecb0b284bcb0fdd8fcc15a238c8eaecb53b04f67fe67f98b6a9e1da30b50339f7c77a652d16384ddae725280a8f78291c8af284b6f2dc51bdb21679
|
|
@@ -11,13 +11,38 @@ module Low
|
|
|
11
11
|
DEFAULT_KEEP_ALIVE_TIMEOUT = 30
|
|
12
12
|
DEFAULT_REQUEST_TIMEOUT = 10
|
|
13
13
|
|
|
14
|
+
class << self
|
|
15
|
+
# The connections open now. Each is a client like a browser or a proxy such as Caddy, which keeps a few open for
|
|
16
|
+
# its requests. They're all handled on the event loop's thread, so the count needs no lock.
|
|
17
|
+
def open_count
|
|
18
|
+
@open_count ||= 0
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def opened
|
|
22
|
+
@open_count = open_count + 1
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def closed
|
|
26
|
+
@open_count = open_count - 1
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
14
30
|
# on_error is called with an error raised while responding to a request, before responding with a 500.
|
|
15
31
|
def initialize(config:, on_error: nil)
|
|
16
32
|
@config = config
|
|
17
33
|
@on_error = on_error
|
|
18
34
|
end
|
|
19
35
|
|
|
36
|
+
# Counts the connection as open while its requests are served.
|
|
20
37
|
def handle_connection(socket:)
|
|
38
|
+
self.class.opened
|
|
39
|
+
serve_requests(socket:)
|
|
40
|
+
ensure
|
|
41
|
+
self.class.closed
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
# Answers each request on a connection until the client closes it or stops sending.
|
|
45
|
+
def serve_requests(socket:)
|
|
21
46
|
stream = RequestParser.create_stream(socket:)
|
|
22
47
|
keep_alive = true
|
|
23
48
|
version = nil
|
data/lib/servers/file_server.rb
CHANGED
|
@@ -16,7 +16,8 @@ module Low
|
|
|
16
16
|
@content_types = content_types.transform_keys(&:to_s)
|
|
17
17
|
@cache_control = cache_control
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
# A second file server, like one for a framework's own files, shares the one FileResponse rather than adding another.
|
|
20
|
+
observers(Events::FileEvent) << FileResponse unless responding?
|
|
20
21
|
end
|
|
21
22
|
|
|
22
23
|
def extension(file_path:)
|
|
@@ -48,5 +49,11 @@ module Low
|
|
|
48
49
|
|
|
49
50
|
Events::FileEvent.take(file:, request: event.request)
|
|
50
51
|
end
|
|
52
|
+
|
|
53
|
+
private
|
|
54
|
+
|
|
55
|
+
def responding?
|
|
56
|
+
Observers::Keys[Events::FileEvent].observers.any? { |observer| observer.object == FileResponse }
|
|
57
|
+
end
|
|
51
58
|
end
|
|
52
59
|
end
|
data/lib/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: lowloop
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.8.
|
|
4
|
+
version: 0.8.12
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- maedi
|
|
8
8
|
bindir: exe
|
|
9
9
|
cert_chain: []
|
|
10
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
11
|
dependencies:
|
|
12
12
|
- !ruby/object:Gem::Dependency
|
|
13
13
|
name: async
|
|
@@ -162,7 +162,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
162
162
|
- !ruby/object:Gem::Version
|
|
163
163
|
version: '0'
|
|
164
164
|
requirements: []
|
|
165
|
-
rubygems_version:
|
|
165
|
+
rubygems_version: 4.0.20
|
|
166
166
|
specification_version: 4
|
|
167
167
|
summary: An event-driven event loop
|
|
168
168
|
test_files: []
|