protocol-rack 0.5.1 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/lib/protocol/rack/adapter/generic.rb +19 -1
- data/lib/protocol/rack/adapter/rack2.rb +2 -4
- data/lib/protocol/rack/adapter/rack3.rb +2 -3
- data/lib/protocol/rack/body/streaming.rb +19 -3
- data/lib/protocol/rack/constants.rb +2 -0
- data/lib/protocol/rack/input.rb +0 -2
- data/lib/protocol/rack/version.rb +1 -1
- data.tar.gz.sig +0 -0
- metadata +5 -5
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: abae8a03873e4b82fb2d64d88e0a3014a9fd8c0d9eacca1aeb419fb4651f32f8
|
4
|
+
data.tar.gz: 1d1ae6ec253f7fe688907563ed0cdd16cc2e482325344d36384cd6647b403227
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 65c3cfc64676c05b7c7c380a89d4c1f6ab3fa196899877651a574437c6587dab36c75c46f3a1031afb6e13a2e5bedc3cbbf7d39111bbf873b7875bec0ef43a81
|
7
|
+
data.tar.gz: b8f67ded7fc90df8893e98873f3300ba9e2af062d368917216e6f13447e41737c2ed0ae339557932cdf73008df64c4ad5a6a2423af9655bdb96921bb29d06f6d
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
@@ -45,7 +45,11 @@ module Protocol
|
|
45
45
|
http_key = "HTTP_#{key.upcase.tr('-', '_')}"
|
46
46
|
|
47
47
|
if current_value = env[http_key]
|
48
|
-
|
48
|
+
if http_key == CGI::HTTP_COOKIE
|
49
|
+
env[http_key] = "#{current_value};#{value}"
|
50
|
+
else
|
51
|
+
env[http_key] = "#{current_value},#{value}"
|
52
|
+
end
|
49
53
|
else
|
50
54
|
env[http_key] = value
|
51
55
|
end
|
@@ -138,6 +142,20 @@ module Protocol
|
|
138
142
|
def failure_response(exception)
|
139
143
|
Protocol::HTTP::Response.for_exception(exception)
|
140
144
|
end
|
145
|
+
|
146
|
+
def self.extract_protocol(env, response, headers)
|
147
|
+
if protocol = response.protocol
|
148
|
+
# This is the newer mechanism for protocol upgrade:
|
149
|
+
if env['rack.protocol']
|
150
|
+
headers['rack.protocol'] = protocol
|
151
|
+
|
152
|
+
# Older mechanism for protocol upgrade:
|
153
|
+
elsif env[CGI::HTTP_UPGRADE]
|
154
|
+
headers['upgrade'] = protocol
|
155
|
+
headers['connection'] = 'upgrade'
|
156
|
+
end
|
157
|
+
end
|
158
|
+
end
|
141
159
|
end
|
142
160
|
end
|
143
161
|
end
|
@@ -11,7 +11,7 @@ require_relative '../rewindable'
|
|
11
11
|
module Protocol
|
12
12
|
module Rack
|
13
13
|
module Adapter
|
14
|
-
class Rack2
|
14
|
+
class Rack2 < Generic
|
15
15
|
RACK_VERSION = 'rack.version'
|
16
16
|
RACK_MULTITHREAD = 'rack.multithread'
|
17
17
|
RACK_MULTIPROCESS = 'rack.multiprocess'
|
@@ -121,9 +121,7 @@ module Protocol
|
|
121
121
|
# These interfaces should be largely compatible:
|
122
122
|
headers = response.headers.to_h
|
123
123
|
|
124
|
-
|
125
|
-
headers['rack.protocol'] = protocol
|
126
|
-
end
|
124
|
+
self.extract_protocol(env, response, headers)
|
127
125
|
|
128
126
|
if body = response.body and body.stream?
|
129
127
|
if env[RACK_IS_HIJACK]
|
@@ -92,9 +92,8 @@ module Protocol
|
|
92
92
|
def self.make_response(env, response)
|
93
93
|
# These interfaces should be largely compatible:
|
94
94
|
headers = response.headers.to_h
|
95
|
-
|
96
|
-
|
97
|
-
end
|
95
|
+
|
96
|
+
self.extract_protocol(env, response, headers)
|
98
97
|
|
99
98
|
if body = response.body and body.stream?
|
100
99
|
# Force streaming response:
|
@@ -22,22 +22,38 @@ module Protocol
|
|
22
22
|
class Output
|
23
23
|
def initialize(input, block)
|
24
24
|
stream = ::Protocol::HTTP::Body::Stream.new(input, self)
|
25
|
-
|
25
|
+
|
26
|
+
@from = nil
|
27
|
+
|
28
|
+
@fiber = Fiber.new do |from|
|
29
|
+
@from = from
|
26
30
|
block.call(stream)
|
27
31
|
@fiber = nil
|
28
32
|
end
|
29
33
|
end
|
30
34
|
|
31
35
|
def write(chunk)
|
32
|
-
|
36
|
+
if from = @from
|
37
|
+
@from = nil
|
38
|
+
@from = from.transfer(chunk)
|
39
|
+
else
|
40
|
+
raise RuntimeError, "Stream is not being read!"
|
41
|
+
end
|
33
42
|
end
|
34
43
|
|
35
44
|
def close
|
36
45
|
@fiber = nil
|
46
|
+
|
47
|
+
if from = @from
|
48
|
+
@from = nil
|
49
|
+
from.transfer(nil)
|
50
|
+
end
|
37
51
|
end
|
38
52
|
|
39
53
|
def read
|
40
|
-
@
|
54
|
+
raise RuntimeError, "Stream is already being read!" if @from
|
55
|
+
|
56
|
+
@fiber&.transfer(Fiber.current)
|
41
57
|
end
|
42
58
|
end
|
43
59
|
|
data/lib/protocol/rack/input.rb
CHANGED
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: protocol-rack
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
@@ -38,7 +38,7 @@ cert_chain:
|
|
38
38
|
Q2K9NVun/S785AP05vKkXZEFYxqG6EW012U4oLcFl5MySFajYXRYbuUpH6AY+HP8
|
39
39
|
voD0MPg1DssDLKwXyt1eKD/+Fq0bFWhwVM/1XiAXL7lyYUyOq24KHgQ2Csg=
|
40
40
|
-----END CERTIFICATE-----
|
41
|
-
date: 2024-
|
41
|
+
date: 2024-09-02 00:00:00.000000000 Z
|
42
42
|
dependencies:
|
43
43
|
- !ruby/object:Gem::Dependency
|
44
44
|
name: protocol-http
|
@@ -46,14 +46,14 @@ dependencies:
|
|
46
46
|
requirements:
|
47
47
|
- - "~>"
|
48
48
|
- !ruby/object:Gem::Version
|
49
|
-
version: '0.
|
49
|
+
version: '0.27'
|
50
50
|
type: :runtime
|
51
51
|
prerelease: false
|
52
52
|
version_requirements: !ruby/object:Gem::Requirement
|
53
53
|
requirements:
|
54
54
|
- - "~>"
|
55
55
|
- !ruby/object:Gem::Version
|
56
|
-
version: '0.
|
56
|
+
version: '0.27'
|
57
57
|
- !ruby/object:Gem::Dependency
|
58
58
|
name: rack
|
59
59
|
requirement: !ruby/object:Gem::Requirement
|
@@ -112,7 +112,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
112
112
|
- !ruby/object:Gem::Version
|
113
113
|
version: '0'
|
114
114
|
requirements: []
|
115
|
-
rubygems_version: 3.5.
|
115
|
+
rubygems_version: 3.5.11
|
116
116
|
signing_key:
|
117
117
|
specification_version: 4
|
118
118
|
summary: An implementation of the Rack protocol/specification.
|
metadata.gz.sig
CHANGED
Binary file
|