protocol-rack 0.2.1 → 0.2.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
  SHA256:
3
- metadata.gz: c5cd531684b517c9695d07dfaa9f4301e3e77fcf52389b471f1f89aaa2227227
4
- data.tar.gz: aa8f85b68326ca7f646d4c9e15bbdf0f6165bb969fad7345e933a8232e5263fb
3
+ metadata.gz: 2b6a6be852ed5686a4a29416d5e7f308a0b8fecdac08945f7a94c654fe961295
4
+ data.tar.gz: e0afd920038faa59a9739eb0780acc7d517d34fdd9bc336c80069c39b06892e4
5
5
  SHA512:
6
- metadata.gz: 27afe33758a33782b67f9f569e65a828304296c63f21f892b9f27413c71c7021fceb2e57e02c21ce3f7e9f9abcac444626d64aaf73743d7be3b4119cea4c7893
7
- data.tar.gz: 72089305ac61d33065352316385def71c940d1578c7739df08a4ea27704b494576d8830703b462c078ebb0e5a1f61a39be381e2a34496868c1057d8281f511f9
6
+ metadata.gz: 6d289be5ff94b209e23de3cb3569cfe76df31356daf072e2caf22ec34e22f3dce6e2e46cc027548b515c83ecd6186c1318f74a1bebaed388618ed7c221b704f4
7
+ data.tar.gz: 36c188b1011e436f29fdbf2c317d0c81ed46ae1831a1439cad18248492a005f735d14f2babc5855fd455940018c5f26719978878a697794c17d2d35d1846216d
checksums.yaml.gz.sig CHANGED
Binary file
@@ -33,7 +33,6 @@ module Protocol
33
33
  RACK_MULTITHREAD => false,
34
34
  RACK_MULTIPROCESS => true,
35
35
  RACK_RUN_ONCE => false,
36
- RACK_IS_HIJACK => true,
37
36
 
38
37
  PROTOCOL_HTTP_REQUEST => request,
39
38
 
@@ -84,9 +83,10 @@ module Protocol
84
83
 
85
84
  headers, meta = self.wrap_headers(headers)
86
85
 
87
- if hijack_body = meta[RACK_HIJACK]
88
- body = hijack_body
89
- end
86
+ # Rack 2 spec does not allow only partial hijacking.
87
+ # if hijack_body = meta[RACK_HIJACK]
88
+ # body = hijack_body
89
+ # end
90
90
 
91
91
  return Response.wrap(env, status, headers, meta, body, request)
92
92
  rescue => exception
@@ -14,41 +14,47 @@ module Protocol
14
14
  def initialize(block, input = nil)
15
15
  @block = block
16
16
  @input = input
17
+ @output = nil
17
18
  end
18
19
 
19
20
  attr :block
20
-
21
- def each(&block)
22
- stream = ::Protocol::HTTP::Body::Stream.new(@input, Output.new(block))
23
-
24
- @block.call(stream)
25
- end
26
-
27
- def stream?
28
- true
29
- end
30
-
31
- def call(stream)
32
- @block.call(stream)
33
- end
34
21
 
35
22
  class Output
36
- def initialize(block)
37
- @block = block
23
+ def initialize(input, block)
24
+ stream = ::Protocol::HTTP::Body::Stream.new(input, self)
25
+ @fiber = Fiber.new do
26
+ block.call(stream)
27
+ @fiber = nil
28
+ end
38
29
  end
39
30
 
40
31
  def write(chunk)
41
- @block.call(chunk)
32
+ Fiber.yield(chunk)
42
33
  end
43
34
 
44
35
  def close
45
- @block = nil
36
+ @fiber = nil
46
37
  end
47
38
 
48
- def empty?
49
- true
39
+ def read
40
+ @fiber&.resume
50
41
  end
51
42
  end
43
+
44
+ # Invokes the block in a fiber which yields chunks when they are available.
45
+ def read
46
+ @output ||= Output.new(@input, @block)
47
+ return @output.read
48
+ end
49
+
50
+ def stream?
51
+ true
52
+ end
53
+
54
+ def call(stream)
55
+ raise "Streaming body has already been read!" if @output
56
+ @block.call(stream)
57
+ end
52
58
  end
53
59
  end
54
60
  end
@@ -5,6 +5,6 @@
5
5
 
6
6
  module Protocol
7
7
  module Rack
8
- VERSION = "0.2.1"
8
+ VERSION = "0.2.4"
9
9
  end
10
10
  end
data.tar.gz.sig CHANGED
@@ -1,4 +1,3 @@
1
-
2
- �˹�3"�E�H �=�8>��L&[�H�7"`������P#l�s��T|�,���
3
- H7��0�x|?���@Q1���e�WC���py���r@�Ej<(b��z
4
- �������s5�$p�Λ%?M����Ҍ�m,��bp�A�!���J�G.���.�!�B�����[)��K�V �).�����k�� }D|F��4'���z$�t��S�x������&��[d���@8rd́��Z�[ѿ]���U9lK�
1
+
2
+ &�s+u�Я�`�-ɮ087T���a��R���E�B#�O�.����U�*�'_�����#�5����CQ{x���8rb����AE�
3
+ vunG�$�X��<�)5��~^��-��V����du��r0{�RZ����P� RS����aC���â��:�䍟,�-\�z��(�^^��:W��'��qj�aӟ��~0�k1!�b}�k}���[p�43t�:b^����WS}
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.2.1
4
+ version: 0.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
@@ -37,7 +37,7 @@ cert_chain:
37
37
  Q2K9NVun/S785AP05vKkXZEFYxqG6EW012U4oLcFl5MySFajYXRYbuUpH6AY+HP8
38
38
  voD0MPg1DssDLKwXyt1eKD/+Fq0bFWhwVM/1XiAXL7lyYUyOq24KHgQ2Csg=
39
39
  -----END CERTIFICATE-----
40
- date: 2022-08-27 00:00:00.000000000 Z
40
+ date: 2022-09-06 00:00:00.000000000 Z
41
41
  dependencies:
42
42
  - !ruby/object:Gem::Dependency
43
43
  name: protocol-http
@@ -45,14 +45,14 @@ dependencies:
45
45
  requirements:
46
46
  - - "~>"
47
47
  - !ruby/object:Gem::Version
48
- version: 0.23.4
48
+ version: '0.23'
49
49
  type: :runtime
50
50
  prerelease: false
51
51
  version_requirements: !ruby/object:Gem::Requirement
52
52
  requirements:
53
53
  - - "~>"
54
54
  - !ruby/object:Gem::Version
55
- version: 0.23.4
55
+ version: '0.23'
56
56
  - !ruby/object:Gem::Dependency
57
57
  name: rack
58
58
  requirement: !ruby/object:Gem::Requirement
@@ -85,72 +85,72 @@ dependencies:
85
85
  name: bake-test
86
86
  requirement: !ruby/object:Gem::Requirement
87
87
  requirements:
88
- - - ">="
88
+ - - "~>"
89
89
  - !ruby/object:Gem::Version
90
- version: '0'
90
+ version: '0.1'
91
91
  type: :development
92
92
  prerelease: false
93
93
  version_requirements: !ruby/object:Gem::Requirement
94
94
  requirements:
95
- - - ">="
95
+ - - "~>"
96
96
  - !ruby/object:Gem::Version
97
- version: '0'
97
+ version: '0.1'
98
98
  - !ruby/object:Gem::Dependency
99
99
  name: bake-test-external
100
100
  requirement: !ruby/object:Gem::Requirement
101
101
  requirements:
102
- - - ">="
102
+ - - "~>"
103
103
  - !ruby/object:Gem::Version
104
- version: '0'
104
+ version: '0.1'
105
105
  type: :development
106
106
  prerelease: false
107
107
  version_requirements: !ruby/object:Gem::Requirement
108
108
  requirements:
109
- - - ">="
109
+ - - "~>"
110
110
  - !ruby/object:Gem::Version
111
- version: '0'
111
+ version: '0.1'
112
112
  - !ruby/object:Gem::Dependency
113
113
  name: covered
114
114
  requirement: !ruby/object:Gem::Requirement
115
115
  requirements:
116
- - - ">="
116
+ - - "~>"
117
117
  - !ruby/object:Gem::Version
118
- version: '0'
118
+ version: '0.16'
119
119
  type: :development
120
120
  prerelease: false
121
121
  version_requirements: !ruby/object:Gem::Requirement
122
122
  requirements:
123
- - - ">="
123
+ - - "~>"
124
124
  - !ruby/object:Gem::Version
125
- version: '0'
125
+ version: '0.16'
126
126
  - !ruby/object:Gem::Dependency
127
127
  name: sus
128
128
  requirement: !ruby/object:Gem::Requirement
129
129
  requirements:
130
130
  - - "~>"
131
131
  - !ruby/object:Gem::Version
132
- version: 0.11.0
132
+ version: '0.12'
133
133
  type: :development
134
134
  prerelease: false
135
135
  version_requirements: !ruby/object:Gem::Requirement
136
136
  requirements:
137
137
  - - "~>"
138
138
  - !ruby/object:Gem::Version
139
- version: 0.11.0
139
+ version: '0.12'
140
140
  - !ruby/object:Gem::Dependency
141
141
  name: sus-fixtures-async-http
142
142
  requirement: !ruby/object:Gem::Requirement
143
143
  requirements:
144
144
  - - "~>"
145
145
  - !ruby/object:Gem::Version
146
- version: 0.1.1
146
+ version: '0.1'
147
147
  type: :development
148
148
  prerelease: false
149
149
  version_requirements: !ruby/object:Gem::Requirement
150
150
  requirements:
151
151
  - - "~>"
152
152
  - !ruby/object:Gem::Version
153
- version: 0.1.1
153
+ version: '0.1'
154
154
  description:
155
155
  email:
156
156
  executables: []
metadata.gz.sig CHANGED
Binary file