protocol-http 0.26.6 → 0.26.8
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/http/body/buffered.rb +1 -1
- data/lib/protocol/http/body/readable.rb +11 -10
- data/lib/protocol/http/methods.rb +1 -1
- data/lib/protocol/http/url.rb +12 -2
- data/lib/protocol/http/version.rb +1 -1
- data/lib/protocol/http.rb +1 -1
- data/readme.md +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: 20eddc2f7e87cb40659f99174fe456008413fdaf61841c1c366b17ded34a8dc6
|
4
|
+
data.tar.gz: 5f7b795b609e434534d1910aeb84fc7ba77dc46e1157add3e40ea2a053e1ae3c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5b8a17aab9953fcefefea89da1913ce0fa8ce96d27dd91aad38690a21165abf42cf0b46f3f49f4b469c9af5409bffa733b69728acf0f55526b4a6bef8be041be
|
7
|
+
data.tar.gz: 2264dbd29fdbc90a82f37d503c237092f559ec42093be5b57027976aa5c1d6f7019573e8b65a3d7f2d85f7de7de307c2c71e7104be449a2835e086c1ede8fdd9
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
@@ -7,17 +7,11 @@
|
|
7
7
|
module Protocol
|
8
8
|
module HTTP
|
9
9
|
module Body
|
10
|
-
#
|
11
|
-
#
|
12
|
-
#
|
13
|
-
# def read -> String | nil
|
14
|
-
# def join -> String
|
15
|
-
|
16
|
-
# def finish -> buffer the stream and close it.
|
17
|
-
# def close(error = nil) -> close the stream immediately.
|
18
|
-
# end
|
10
|
+
# An interface for reading data from a body.
|
11
|
+
#
|
12
|
+
# Typically, you'd override `#read` to return chunks of data.
|
19
13
|
class Readable
|
20
|
-
#
|
14
|
+
# Close the stream immediately.
|
21
15
|
def close(error = nil)
|
22
16
|
end
|
23
17
|
|
@@ -40,6 +34,7 @@ module Protocol
|
|
40
34
|
end
|
41
35
|
|
42
36
|
# Read the next available chunk.
|
37
|
+
# @returns [String | Nil] The chunk of data, or `nil` if the stream has finished.
|
43
38
|
def read
|
44
39
|
nil
|
45
40
|
end
|
@@ -60,12 +55,16 @@ module Protocol
|
|
60
55
|
end
|
61
56
|
|
62
57
|
# Read all remaining chunks into a buffered body and close the underlying input.
|
58
|
+
# @returns [Buffered] The buffered body.
|
63
59
|
def finish
|
64
60
|
# Internally, this invokes `self.each` which then invokes `self.close`.
|
65
61
|
Buffered.for(self)
|
66
62
|
end
|
67
63
|
|
68
64
|
# Enumerate all chunks until finished, then invoke `#close`.
|
65
|
+
#
|
66
|
+
# @yields {|chunk| ...} The block to call with each chunk of data.
|
67
|
+
# @parameter chunk [String | Nil] The chunk of data, or `nil` if the stream has finished.
|
69
68
|
def each
|
70
69
|
return to_enum(:each) unless block_given?
|
71
70
|
|
@@ -79,6 +78,8 @@ module Protocol
|
|
79
78
|
end
|
80
79
|
|
81
80
|
# Read all remaining chunks into a single binary string using `#each`.
|
81
|
+
#
|
82
|
+
# @returns [String | Nil] The binary string containing all chunks of data, or `nil` if the stream has finished (or did not contain any data).
|
82
83
|
def join
|
83
84
|
buffer = String.new.force_encoding(Encoding::BINARY)
|
84
85
|
|
data/lib/protocol/http/url.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
|
# Copyright, 2022, by Herrick Fang.
|
6
6
|
|
7
7
|
module Protocol
|
@@ -58,6 +58,8 @@ module Protocol
|
|
58
58
|
# @parameter value [String] The unescaped key.
|
59
59
|
def self.scan(string)
|
60
60
|
string.split('&') do |assignment|
|
61
|
+
next if assignment.empty?
|
62
|
+
|
61
63
|
key, value = assignment.split('=', 2)
|
62
64
|
|
63
65
|
yield unescape(key), value.nil? ? value : unescape(value)
|
@@ -65,9 +67,13 @@ module Protocol
|
|
65
67
|
end
|
66
68
|
|
67
69
|
def self.split(name)
|
68
|
-
name.scan(/([^\[]+)|(?:\[(.*?)\])/)
|
70
|
+
name.scan(/([^\[]+)|(?:\[(.*?)\])/)&.tap do |parts|
|
71
|
+
parts.flatten!
|
72
|
+
parts.compact!
|
73
|
+
end
|
69
74
|
end
|
70
75
|
|
76
|
+
# Assign a value to a nested hash.
|
71
77
|
def self.assign(keys, value, parent)
|
72
78
|
top, *middle = keys
|
73
79
|
|
@@ -95,6 +101,10 @@ module Protocol
|
|
95
101
|
self.scan(string) do |name, value|
|
96
102
|
keys = self.split(name)
|
97
103
|
|
104
|
+
if keys.empty?
|
105
|
+
raise ArgumentError, "Invalid key path: #{name.inspect}!"
|
106
|
+
end
|
107
|
+
|
98
108
|
if keys.size > maximum
|
99
109
|
raise ArgumentError, "Key length exceeded limit!"
|
100
110
|
end
|
data/lib/protocol/http.rb
CHANGED
data/readme.md
CHANGED
@@ -30,11 +30,11 @@ We welcome contributions to this project.
|
|
30
30
|
|
31
31
|
### Developer Certificate of Origin
|
32
32
|
|
33
|
-
|
33
|
+
In order to protect users of this project, we require all contributors to comply with the [Developer Certificate of Origin](https://developercertificate.org/). This ensures that all contributions are properly licensed and attributed.
|
34
34
|
|
35
|
-
###
|
35
|
+
### Community Guidelines
|
36
36
|
|
37
|
-
This project is
|
37
|
+
This project is best served by a collaborative and respectful environment. Treat each other professionally, respect differing viewpoints, and engage constructively. Harassment, discrimination, or harmful behavior is not tolerated. Communicate clearly, listen actively, and support one another. If any issues arise, please inform the project maintainers.
|
38
38
|
|
39
39
|
## See Also
|
40
40
|
|
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: protocol-http
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.26.
|
4
|
+
version: 0.26.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
@@ -47,7 +47,7 @@ cert_chain:
|
|
47
47
|
Q2K9NVun/S785AP05vKkXZEFYxqG6EW012U4oLcFl5MySFajYXRYbuUpH6AY+HP8
|
48
48
|
voD0MPg1DssDLKwXyt1eKD/+Fq0bFWhwVM/1XiAXL7lyYUyOq24KHgQ2Csg=
|
49
49
|
-----END CERTIFICATE-----
|
50
|
-
date: 2024-
|
50
|
+
date: 2024-07-07 00:00:00.000000000 Z
|
51
51
|
dependencies: []
|
52
52
|
description:
|
53
53
|
email:
|
metadata.gz.sig
CHANGED
Binary file
|