http-protocol 0.10.1 → 0.11.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.editorconfig +6 -0
- data/.travis.yml +2 -4
- data/http-protocol.gemspec +1 -1
- data/lib/http/protocol/http1/connection.rb +33 -42
- data/lib/http/protocol/version.rb +1 -1
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d0b91f0480849b41925cf0c8cc1e86b65da69903110b6e59649ac5101d94c0d2
|
4
|
+
data.tar.gz: 19d4d4c7078dc7e7f0561247cdcca4988a9cac781000cf0371dc5b8b1fedf063
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e068393e0004d7ecfdc41a5228a7a654f8383946c85556d0b17d98d28c338e6bce89c120cc12841b83d0c42004a179610920d1c1ce3288001d3605a0b5bff2ef
|
7
|
+
data.tar.gz: 508783a720213e14577771aedcb01431b2c22b0eca45454328106b01fef00eab961e52970d1c389b9026c508c7b021fb01f4a72b25c15707c2ac44d52992d138
|
data/.editorconfig
ADDED
data/.travis.yml
CHANGED
@@ -3,21 +3,19 @@ sudo: required
|
|
3
3
|
dist: xenial
|
4
4
|
cache: bundler
|
5
5
|
|
6
|
-
before_script:
|
7
|
-
- gem update --system
|
8
|
-
- gem install bundler
|
9
|
-
|
10
6
|
matrix:
|
11
7
|
include:
|
12
8
|
- rvm: 2.3
|
13
9
|
- rvm: 2.4
|
14
10
|
- rvm: 2.5
|
15
11
|
- rvm: 2.6
|
12
|
+
- rvm: truffleruby
|
16
13
|
- rvm: jruby-head
|
17
14
|
env: JRUBY_OPTS="--debug -X+O"
|
18
15
|
- rvm: ruby-head
|
19
16
|
- rvm: rbx-3
|
20
17
|
allow_failures:
|
18
|
+
- rvm: truffleruby
|
21
19
|
- rvm: ruby-head
|
22
20
|
- rvm: jruby-head
|
23
21
|
- rvm: rbx-3
|
data/http-protocol.gemspec
CHANGED
@@ -18,7 +18,7 @@ Gem::Specification.new do |spec|
|
|
18
18
|
|
19
19
|
spec.add_dependency "http-hpack", "~> 0.1.0"
|
20
20
|
|
21
|
-
spec.add_development_dependency "bundler", "
|
21
|
+
spec.add_development_dependency "bundler", ">= 1.16"
|
22
22
|
spec.add_development_dependency "rake", "~> 10.0"
|
23
23
|
spec.add_development_dependency "rspec", "~> 3.0"
|
24
24
|
end
|
@@ -99,14 +99,7 @@ module HTTP
|
|
99
99
|
|
100
100
|
write_headers(headers)
|
101
101
|
write_persistent_header(version)
|
102
|
-
|
103
|
-
if head
|
104
|
-
write_body_head(body)
|
105
|
-
else
|
106
|
-
write_body(body, version == HTTP11)
|
107
|
-
end
|
108
|
-
|
109
|
-
@stream.flush
|
102
|
+
write_body(body, version == HTTP11, head)
|
110
103
|
end
|
111
104
|
|
112
105
|
def write_headers(headers)
|
@@ -192,25 +185,23 @@ module HTTP
|
|
192
185
|
return chunk
|
193
186
|
end
|
194
187
|
|
195
|
-
def write_chunk(chunk)
|
196
|
-
if chunk.nil?
|
197
|
-
@stream.write("0\r\n\r\n")
|
198
|
-
elsif !chunk.empty?
|
199
|
-
@stream.write("#{chunk.bytesize.to_s(16).upcase}\r\n")
|
200
|
-
@stream.write(chunk)
|
201
|
-
@stream.write(CRLF)
|
202
|
-
@stream.flush
|
203
|
-
end
|
204
|
-
end
|
205
|
-
|
206
188
|
def write_empty_body(body)
|
207
189
|
@stream.write("content-length: 0\r\n\r\n")
|
208
|
-
|
190
|
+
|
191
|
+
if body
|
192
|
+
body.close if body.respond_to?(:close)
|
193
|
+
end
|
209
194
|
end
|
210
195
|
|
211
|
-
def write_fixed_length_body(body, length)
|
196
|
+
def write_fixed_length_body(body, length, head)
|
212
197
|
@stream.write("content-length: #{length}\r\n\r\n")
|
213
198
|
|
199
|
+
if head
|
200
|
+
body.close if body.respond_to?(:close)
|
201
|
+
|
202
|
+
return
|
203
|
+
end
|
204
|
+
|
214
205
|
chunk_length = 0
|
215
206
|
body.each do |chunk|
|
216
207
|
chunk_length += chunk.bytesize
|
@@ -229,9 +220,15 @@ module HTTP
|
|
229
220
|
end
|
230
221
|
end
|
231
222
|
|
232
|
-
def write_chunked_body(body)
|
223
|
+
def write_chunked_body(body, head)
|
233
224
|
@stream.write("transfer-encoding: chunked\r\n\r\n")
|
234
225
|
|
226
|
+
if head
|
227
|
+
body.close if body.respond_to?(:close)
|
228
|
+
|
229
|
+
return
|
230
|
+
end
|
231
|
+
|
235
232
|
body.each do |chunk|
|
236
233
|
next if chunk.size == 0
|
237
234
|
|
@@ -242,43 +239,37 @@ module HTTP
|
|
242
239
|
end
|
243
240
|
|
244
241
|
@stream.write("0\r\n\r\n")
|
245
|
-
@stream.flush
|
246
242
|
end
|
247
243
|
|
248
|
-
def write_body_and_close(body)
|
244
|
+
def write_body_and_close(body, head)
|
249
245
|
# We can't be persistent because we don't know the data length:
|
250
246
|
@persistent = false
|
251
|
-
|
252
247
|
@stream.write("\r\n")
|
253
248
|
|
254
|
-
|
255
|
-
|
256
|
-
|
249
|
+
if head
|
250
|
+
body.close if body.respond_to?(:close)
|
251
|
+
else
|
252
|
+
body.each do |chunk|
|
253
|
+
@stream.write(chunk)
|
254
|
+
@stream.flush
|
255
|
+
end
|
257
256
|
end
|
258
257
|
|
259
258
|
@stream.stream.close_write
|
260
259
|
end
|
261
260
|
|
262
|
-
def write_body(body, chunked = true)
|
261
|
+
def write_body(body, chunked = true, head = false)
|
263
262
|
if body.nil? or body.empty?
|
264
263
|
write_empty_body(body)
|
265
264
|
elsif length = body.length
|
266
|
-
write_fixed_length_body(body, length)
|
265
|
+
write_fixed_length_body(body, length, head)
|
267
266
|
elsif chunked
|
268
|
-
write_chunked_body(body)
|
269
|
-
else
|
270
|
-
write_body_and_close(body)
|
271
|
-
end
|
272
|
-
end
|
273
|
-
|
274
|
-
def write_body_head(body)
|
275
|
-
if body.nil? or body.empty?
|
276
|
-
@stream.write("content-length: 0\r\n\r\n")
|
277
|
-
elsif length = body.length
|
278
|
-
@stream.write("content-length: #{length}\r\n\r\n")
|
267
|
+
write_chunked_body(body, head)
|
279
268
|
else
|
280
|
-
|
269
|
+
write_body_and_close(body, head)
|
281
270
|
end
|
271
|
+
|
272
|
+
@stream.flush
|
282
273
|
end
|
283
274
|
|
284
275
|
def read_chunked_body
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: http-protocol
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.11.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-01-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: http-hpack
|
@@ -28,14 +28,14 @@ dependencies:
|
|
28
28
|
name: bundler
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '1.16'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - "
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '1.16'
|
41
41
|
- !ruby/object:Gem::Dependency
|
@@ -73,6 +73,7 @@ executables: []
|
|
73
73
|
extensions: []
|
74
74
|
extra_rdoc_files: []
|
75
75
|
files:
|
76
|
+
- ".editorconfig"
|
76
77
|
- ".gitignore"
|
77
78
|
- ".rspec"
|
78
79
|
- ".travis.yml"
|
@@ -127,8 +128,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
127
128
|
- !ruby/object:Gem::Version
|
128
129
|
version: '0'
|
129
130
|
requirements: []
|
130
|
-
|
131
|
-
rubygems_version: 2.7.7
|
131
|
+
rubygems_version: 3.0.2
|
132
132
|
signing_key:
|
133
133
|
specification_version: 4
|
134
134
|
summary: Provides abstractions to handle HTTP1 and HTTP2 protocols.
|