protocol-http1 0.22.0 → 0.23.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/http1/body/chunked.rb +22 -13
- data/lib/protocol/http1/body/fixed.rb +15 -12
- data/lib/protocol/http1/body/remainder.rb +8 -5
- data/lib/protocol/http1/connection.rb +16 -16
- data/lib/protocol/http1/error.rb +1 -1
- data/lib/protocol/http1/reason.rb +2 -2
- data/lib/protocol/http1/version.rb +1 -1
- data/lib/protocol/http1.rb +3 -3
- data.tar.gz.sig +0 -0
- metadata +2 -2
- 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: 5883f7878058a83c35d40fe91ea7e673a6abc1895d47e91dfefd57e1849861d5
|
4
|
+
data.tar.gz: f01fbad8aa91e32dddd541fa6a3ab184d8204a5761b6a0b2d5bd7eafd5aab717
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: de91d508479206879dfded7ef4aca6ec5b211372ae8aa9d938afb97c4cb5d1804e9aefbea42d021979ce3c67ad6cf96c28f661be62e6c191219204f9ba96267e
|
7
|
+
data.tar.gz: 3c556ecfd10f3b20424629898b4684e6f8d56ad7415c94e3fedcac7485d5fb389141fd2fb9a9bbadd67a20d05a51286e338fc656febe145551b491781c052776
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
@@ -4,7 +4,7 @@
|
|
4
4
|
# Copyright, 2019-2024, by Samuel Williams.
|
5
5
|
# Copyright, 2023, by Thomas Morgan.
|
6
6
|
|
7
|
-
require
|
7
|
+
require "protocol/http/body/readable"
|
8
8
|
|
9
9
|
module Protocol
|
10
10
|
module HTTP1
|
@@ -26,15 +26,19 @@ module Protocol
|
|
26
26
|
@stream.nil?
|
27
27
|
end
|
28
28
|
|
29
|
-
def
|
30
|
-
if @stream
|
29
|
+
def discard
|
30
|
+
if stream = @stream
|
31
|
+
@stream = nil
|
32
|
+
|
31
33
|
# We only close the connection if we haven't completed reading the entire body:
|
32
34
|
unless @finished
|
33
|
-
|
35
|
+
stream.close_read
|
34
36
|
end
|
35
|
-
|
36
|
-
@stream = nil
|
37
37
|
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def close(error = nil)
|
41
|
+
self.discard
|
38
42
|
|
39
43
|
super
|
40
44
|
end
|
@@ -67,13 +71,18 @@ module Protocol
|
|
67
71
|
# Read trailing CRLF:
|
68
72
|
chunk = @stream.read(length + 2)
|
69
73
|
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
74
|
+
if chunk.bytesize == length + 2
|
75
|
+
# ...and chomp it off:
|
76
|
+
chunk.chomp!(CRLF)
|
77
|
+
|
78
|
+
@length += length
|
79
|
+
@count += 1
|
80
|
+
|
81
|
+
return chunk
|
82
|
+
else
|
83
|
+
# The stream has been closed before we have read the requested length:
|
84
|
+
self.discard
|
85
|
+
end
|
77
86
|
end
|
78
87
|
|
79
88
|
# If the stream has been closed before we have read the final chunk, raise an error:
|
@@ -3,7 +3,7 @@
|
|
3
3
|
# Released under the MIT License.
|
4
4
|
# Copyright, 2019-2024, by Samuel Williams.
|
5
5
|
|
6
|
-
require
|
6
|
+
require "protocol/http/body/readable"
|
7
7
|
|
8
8
|
module Protocol
|
9
9
|
module HTTP1
|
@@ -23,15 +23,18 @@ module Protocol
|
|
23
23
|
@stream.nil? or @remaining == 0
|
24
24
|
end
|
25
25
|
|
26
|
-
def
|
27
|
-
if @stream
|
28
|
-
|
26
|
+
def discard
|
27
|
+
if stream = @stream
|
28
|
+
@stream = nil
|
29
|
+
|
29
30
|
if @remaining != 0
|
30
|
-
|
31
|
+
stream.close_read
|
31
32
|
end
|
32
|
-
|
33
|
-
@stream = nil
|
34
33
|
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def close(error = nil)
|
37
|
+
self.discard
|
35
38
|
|
36
39
|
super
|
37
40
|
end
|
@@ -41,11 +44,11 @@ module Protocol
|
|
41
44
|
if @remaining > 0
|
42
45
|
if @stream
|
43
46
|
# `readpartial` will raise `EOFError` if the stream is finished, or `IOError` if the stream is closed.
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
47
|
+
chunk = @stream.readpartial(@remaining)
|
48
|
+
|
49
|
+
@remaining -= chunk.bytesize
|
50
|
+
|
51
|
+
return chunk
|
49
52
|
end
|
50
53
|
|
51
54
|
# If the stream has been closed before we have read the expected length, raise an error:
|
@@ -3,7 +3,7 @@
|
|
3
3
|
# Released under the MIT License.
|
4
4
|
# Copyright, 2019-2024, by Samuel Williams.
|
5
5
|
|
6
|
-
require
|
6
|
+
require "protocol/http/body/readable"
|
7
7
|
|
8
8
|
module Protocol
|
9
9
|
module HTTP1
|
@@ -21,12 +21,15 @@ module Protocol
|
|
21
21
|
@stream.nil?
|
22
22
|
end
|
23
23
|
|
24
|
-
def
|
25
|
-
if @stream
|
26
|
-
# We can't really do anything in this case except close the connection.
|
27
|
-
@stream.close_read
|
24
|
+
def discard
|
25
|
+
if stream = @stream
|
28
26
|
@stream = nil
|
27
|
+
stream.close_read
|
29
28
|
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def close(error = nil)
|
32
|
+
self.discard
|
30
33
|
|
31
34
|
super
|
32
35
|
end
|
@@ -7,31 +7,31 @@
|
|
7
7
|
# Copyright, 2023-2024, by Thomas Morgan.
|
8
8
|
# Copyright, 2024, by Anton Zhuravsky.
|
9
9
|
|
10
|
-
require
|
10
|
+
require "protocol/http/headers"
|
11
11
|
|
12
|
-
require_relative
|
13
|
-
require_relative
|
12
|
+
require_relative "reason"
|
13
|
+
require_relative "error"
|
14
14
|
|
15
|
-
require_relative
|
16
|
-
require_relative
|
17
|
-
require_relative
|
18
|
-
require
|
15
|
+
require_relative "body/chunked"
|
16
|
+
require_relative "body/fixed"
|
17
|
+
require_relative "body/remainder"
|
18
|
+
require "protocol/http/body/head"
|
19
19
|
|
20
|
-
require
|
20
|
+
require "protocol/http/methods"
|
21
21
|
|
22
22
|
module Protocol
|
23
23
|
module HTTP1
|
24
|
-
CONTENT_LENGTH =
|
24
|
+
CONTENT_LENGTH = "content-length"
|
25
25
|
|
26
|
-
TRANSFER_ENCODING =
|
27
|
-
CHUNKED =
|
26
|
+
TRANSFER_ENCODING = "transfer-encoding"
|
27
|
+
CHUNKED = "chunked"
|
28
28
|
|
29
|
-
CONNECTION =
|
30
|
-
CLOSE =
|
31
|
-
KEEP_ALIVE =
|
29
|
+
CONNECTION = "connection"
|
30
|
+
CLOSE = "close"
|
31
|
+
KEEP_ALIVE = "keep-alive"
|
32
32
|
|
33
|
-
HOST =
|
34
|
-
UPGRADE =
|
33
|
+
HOST = "host"
|
34
|
+
UPGRADE = "upgrade"
|
35
35
|
|
36
36
|
# HTTP/1.x request line parser:
|
37
37
|
TOKEN = /[!#$%&'*+\-\.\^_`|~0-9a-zA-Z]+/.freeze
|
data/lib/protocol/http1/error.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
# Released under the MIT License.
|
4
|
-
# Copyright, 2019-
|
4
|
+
# Copyright, 2019-2024, by Samuel Williams.
|
5
5
|
|
6
|
-
require
|
6
|
+
require "protocol/http/error"
|
7
7
|
|
8
8
|
module Protocol
|
9
9
|
module HTTP1
|
data/lib/protocol/http1.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
# Released under the MIT License.
|
4
|
-
# Copyright, 2019-
|
4
|
+
# Copyright, 2019-2024, by Samuel Williams.
|
5
5
|
|
6
|
-
require_relative
|
7
|
-
require_relative
|
6
|
+
require_relative "http1/version"
|
7
|
+
require_relative "http1/connection"
|
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: protocol-http1
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.23.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
@@ -42,7 +42,7 @@ cert_chain:
|
|
42
42
|
Q2K9NVun/S785AP05vKkXZEFYxqG6EW012U4oLcFl5MySFajYXRYbuUpH6AY+HP8
|
43
43
|
voD0MPg1DssDLKwXyt1eKD/+Fq0bFWhwVM/1XiAXL7lyYUyOq24KHgQ2Csg=
|
44
44
|
-----END CERTIFICATE-----
|
45
|
-
date: 2024-09-
|
45
|
+
date: 2024-09-17 00:00:00.000000000 Z
|
46
46
|
dependencies:
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: protocol-http
|
metadata.gz.sig
CHANGED
Binary file
|