protocol-http 0.24.7 → 0.26.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/http/body/stream.rb +5 -1
- data/lib/protocol/http/header/cache_control.rb +36 -2
- data/lib/protocol/http/header/connection.rb +1 -1
- data/lib/protocol/http/header/date.rb +1 -1
- data/lib/protocol/http/header/etags.rb +22 -1
- data/lib/protocol/http/response.rb +21 -0
- data/lib/protocol/http/version.rb +1 -1
- data/license.md +3 -1
- data/readme.md +5 -8
- data.tar.gz.sig +0 -0
- metadata +23 -6
- 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: 6401497cd3f38196e5a3144d558cf78de63f078910be38a62424178d9602fe16
|
4
|
+
data.tar.gz: b8c117fc812d042322c0dec7cf40e3d6e52b0920935ab1ddde954ac7caed94f0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7fe7771ac9a21b2724b6f037dcce2eeb4bcae573d61634aabfa631304a70bbc661635221cf10371c755fa06d6d4ab1dac926a3ca342422aa380b529954ad941f
|
7
|
+
data.tar.gz: 05cd0d1cf17525d9c525158e76687440f607fc34c23e25a055e4f97f1fe20b4af0c8b0e4bedd91ef8bd705c3a1711ee365bdc3cc539fa9f85638cc66040c2ea9
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
@@ -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, 2023, by Genki Takiuchi.
|
6
6
|
|
7
7
|
require_relative 'buffered'
|
@@ -98,6 +98,10 @@ module Protocol
|
|
98
98
|
return buffer
|
99
99
|
end
|
100
100
|
|
101
|
+
def readpartial(length)
|
102
|
+
read_partial(length) or raise EOFError, "End of file reached!"
|
103
|
+
end
|
104
|
+
|
101
105
|
def read_nonblock(length, buffer = nil)
|
102
106
|
@buffer ||= read_next
|
103
107
|
chunk = nil
|
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
# Released under the MIT License.
|
4
4
|
# Copyright, 2020-2023, by Samuel Williams.
|
5
|
+
# Copyright, 2023, by Thomas Morgan.
|
5
6
|
|
6
7
|
require_relative 'split'
|
7
8
|
|
@@ -14,11 +15,15 @@ module Protocol
|
|
14
15
|
NO_CACHE = 'no-cache'
|
15
16
|
NO_STORE = 'no-store'
|
16
17
|
MAX_AGE = 'max-age'
|
18
|
+
S_MAXAGE = 's-maxage'
|
17
19
|
|
18
20
|
STATIC = 'static'
|
19
21
|
DYNAMIC = 'dynamic'
|
20
22
|
STREAMING = 'streaming'
|
21
23
|
|
24
|
+
MUST_REVALIDATE = 'must-revalidate'
|
25
|
+
PROXY_REVALIDATE = 'proxy-revalidate'
|
26
|
+
|
22
27
|
def initialize(value = nil)
|
23
28
|
super(value&.downcase)
|
24
29
|
end
|
@@ -55,11 +60,40 @@ module Protocol
|
|
55
60
|
self.include?(NO_STORE)
|
56
61
|
end
|
57
62
|
|
63
|
+
# Indicates that a response must not be used once it is stale.
|
64
|
+
# See https://www.rfc-editor.org/rfc/rfc9111.html#name-must-revalidate
|
65
|
+
def must_revalidate?
|
66
|
+
self.include?(MUST_REVALIDATE)
|
67
|
+
end
|
68
|
+
|
69
|
+
# Like must-revalidate, but for shared caches only.
|
70
|
+
# See https://www.rfc-editor.org/rfc/rfc9111.html#name-proxy-revalidate
|
71
|
+
def proxy_revalidate?
|
72
|
+
self.include?(PROXY_REVALIDATE)
|
73
|
+
end
|
74
|
+
|
75
|
+
# The maximum time, in seconds, a response should be considered fresh.
|
76
|
+
# See https://www.rfc-editor.org/rfc/rfc9111.html#name-max-age-2
|
58
77
|
def max_age
|
59
|
-
|
78
|
+
find_integer_value(MAX_AGE)
|
79
|
+
end
|
80
|
+
|
81
|
+
# Like max-age, but for shared caches only, which should use it before
|
82
|
+
# max-age when present.
|
83
|
+
# See https://www.rfc-editor.org/rfc/rfc9111.html#name-s-maxage
|
84
|
+
def s_maxage
|
85
|
+
find_integer_value(S_MAXAGE)
|
86
|
+
end
|
87
|
+
|
88
|
+
private
|
89
|
+
|
90
|
+
def find_integer_value(value_name)
|
91
|
+
if value = self.find{|value| value.start_with?(value_name)}
|
60
92
|
_, age = value.split('=', 2)
|
61
93
|
|
62
|
-
|
94
|
+
if age =~ /\A[0-9]+\z/
|
95
|
+
return Integer(age)
|
96
|
+
end
|
63
97
|
end
|
64
98
|
end
|
65
99
|
end
|
@@ -2,21 +2,42 @@
|
|
2
2
|
|
3
3
|
# Released under the MIT License.
|
4
4
|
# Copyright, 2020-2023, by Samuel Williams.
|
5
|
+
# Copyright, 2023, by Thomas Morgan.
|
5
6
|
|
6
7
|
require_relative 'split'
|
7
8
|
|
8
9
|
module Protocol
|
9
10
|
module HTTP
|
10
11
|
module Header
|
11
|
-
# This implementation is not strictly correct according to the RFC-specified format.
|
12
12
|
class ETags < Split
|
13
13
|
def wildcard?
|
14
14
|
self.include?('*')
|
15
15
|
end
|
16
16
|
|
17
|
+
# This implementation is not strictly correct according to the RFC-specified format.
|
17
18
|
def match?(etag)
|
18
19
|
wildcard? || self.include?(etag)
|
19
20
|
end
|
21
|
+
|
22
|
+
# Useful with If-Match
|
23
|
+
def strong_match?(etag)
|
24
|
+
wildcard? || (!weak_tag?(etag) && self.include?(etag))
|
25
|
+
end
|
26
|
+
|
27
|
+
# Useful with If-None-Match
|
28
|
+
def weak_match?(etag)
|
29
|
+
wildcard? || self.include?(etag) || self.include?(opposite_tag(etag))
|
30
|
+
end
|
31
|
+
|
32
|
+
private
|
33
|
+
|
34
|
+
def opposite_tag(etag)
|
35
|
+
weak_tag?(etag) ? etag[2..-1] : "W/#{etag}"
|
36
|
+
end
|
37
|
+
|
38
|
+
def weak_tag?(tag)
|
39
|
+
tag&.start_with? 'W/'
|
40
|
+
end
|
20
41
|
end
|
21
42
|
end
|
22
43
|
end
|
@@ -29,42 +29,63 @@ module Protocol
|
|
29
29
|
false
|
30
30
|
end
|
31
31
|
|
32
|
+
# Whether the status is 100 (continue).
|
32
33
|
def continue?
|
33
34
|
@status == 100
|
34
35
|
end
|
35
36
|
|
37
|
+
# Whether the status is considered informational.
|
38
|
+
def informational?
|
39
|
+
@status and @status >= 100 && @status < 200
|
40
|
+
end
|
41
|
+
|
42
|
+
# Whether the status is considered final. Note that 101 is considered final.
|
43
|
+
def final?
|
44
|
+
# 101 is effectively a final status.
|
45
|
+
@status and @status >= 200 || @status == 101
|
46
|
+
end
|
47
|
+
|
48
|
+
# Whether the status is 200 (ok).
|
36
49
|
def ok?
|
37
50
|
@status == 200
|
38
51
|
end
|
39
52
|
|
53
|
+
# Whether the status is considered successful.
|
40
54
|
def success?
|
41
55
|
@status and @status >= 200 && @status < 300
|
42
56
|
end
|
43
57
|
|
58
|
+
# Whether the status is 206 (partial content).
|
44
59
|
def partial?
|
45
60
|
@status == 206
|
46
61
|
end
|
47
62
|
|
63
|
+
# Whether the status is considered a redirection.
|
48
64
|
def redirection?
|
49
65
|
@status and @status >= 300 && @status < 400
|
50
66
|
end
|
51
67
|
|
68
|
+
# Whether the status is 304 (not modified).
|
52
69
|
def not_modified?
|
53
70
|
@status == 304
|
54
71
|
end
|
55
72
|
|
73
|
+
# Whether the status is 307 (temporary redirect) and should preserve the method of the request when following the redirect.
|
56
74
|
def preserve_method?
|
57
75
|
@status == 307 || @status == 308
|
58
76
|
end
|
59
77
|
|
78
|
+
# Whether the status is considered a failure.
|
60
79
|
def failure?
|
61
80
|
@status and @status >= 400 && @status < 600
|
62
81
|
end
|
63
82
|
|
83
|
+
# Whether the status is 400 (bad request).
|
64
84
|
def bad_request?
|
65
85
|
@status == 400
|
66
86
|
end
|
67
87
|
|
88
|
+
# Whether the status is 500 (internal server error).
|
68
89
|
def internal_server_error?
|
69
90
|
@status == 500
|
70
91
|
end
|
data/license.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# MIT License
|
2
2
|
|
3
|
-
Copyright, 2018-
|
3
|
+
Copyright, 2018-2024, by Samuel Williams.
|
4
4
|
Copyright, 2019, by Yuta Iwama.
|
5
5
|
Copyright, 2020, by Olle Jonsson.
|
6
6
|
Copyright, 2020, by Bryan Powell.
|
@@ -8,6 +8,8 @@ Copyright, 2020-2023, by Bruno Sutic.
|
|
8
8
|
Copyright, 2022, by Herrick Fang.
|
9
9
|
Copyright, 2022, by Dan Olson.
|
10
10
|
Copyright, 2023, by Genki Takiuchi.
|
11
|
+
Copyright, 2023, by Thomas Morgan.
|
12
|
+
Copyright, 2023, by Marcelo Junior.
|
11
13
|
|
12
14
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
13
15
|
of this software and associated documentation files (the "Software"), to deal
|
data/readme.md
CHANGED
@@ -8,18 +8,15 @@ Provides abstractions for working with the HTTP protocol.
|
|
8
8
|
|
9
9
|
- General abstractions for HTTP requests and responses.
|
10
10
|
- Symmetrical interfaces for client and server.
|
11
|
-
- Light-weight
|
11
|
+
- Light-weight middleware model for building applications.
|
12
12
|
|
13
13
|
## Usage
|
14
14
|
|
15
|
-
Please see the [project documentation](https://github.
|
15
|
+
Please see the [project documentation](https://socketry.github.io/protocol-http/) for more details.
|
16
16
|
|
17
|
-
- [Getting Started](https://github.
|
18
|
-
to use `protocol-http` for building abstract HTTP interfaces.
|
17
|
+
- [Getting Started](https://socketry.github.io/protocol-http/guides/getting-started/index) - This guide explains how to use `protocol-http` for building abstract HTTP interfaces.
|
19
18
|
|
20
|
-
- [Design Overview](https://github.
|
21
|
-
by <code class="language-ruby">Protocol::HTTP</code> underpin all downstream implementations. Therefore, we provide
|
22
|
-
some justification for the design choices.
|
19
|
+
- [Design Overview](https://socketry.github.io/protocol-http/guides/design-overview/index) - This guide explains the high level design of `protocol-http` in the context of wider design patterns that can be used to implement HTTP clients and servers.
|
23
20
|
|
24
21
|
## Contributing
|
25
22
|
|
@@ -37,7 +34,7 @@ This project uses the [Developer Certificate of Origin](https://developercertifi
|
|
37
34
|
|
38
35
|
### Contributor Covenant
|
39
36
|
|
40
|
-
This project is governed by [Contributor Covenant](https://www.contributor-covenant.org/). All contributors and participants agree to abide by its terms.
|
37
|
+
This project is governed by the [Contributor Covenant](https://www.contributor-covenant.org/). All contributors and participants agree to abide by its terms.
|
41
38
|
|
42
39
|
## See Also
|
43
40
|
|
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,15 +1,17 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: protocol-http
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.26.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
8
8
|
- Bruno Sutic
|
9
9
|
- Herrick Fang
|
10
|
+
- Thomas Morgan
|
10
11
|
- Bryan Powell
|
11
12
|
- Dan Olson
|
12
13
|
- Genki Takiuchi
|
14
|
+
- Marcelo Junior
|
13
15
|
- Olle Jonsson
|
14
16
|
- Yuta Iwama
|
15
17
|
autorequire:
|
@@ -44,8 +46,22 @@ cert_chain:
|
|
44
46
|
Q2K9NVun/S785AP05vKkXZEFYxqG6EW012U4oLcFl5MySFajYXRYbuUpH6AY+HP8
|
45
47
|
voD0MPg1DssDLKwXyt1eKD/+Fq0bFWhwVM/1XiAXL7lyYUyOq24KHgQ2Csg=
|
46
48
|
-----END CERTIFICATE-----
|
47
|
-
date:
|
48
|
-
dependencies:
|
49
|
+
date: 2024-01-26 00:00:00.000000000 Z
|
50
|
+
dependencies:
|
51
|
+
- !ruby/object:Gem::Dependency
|
52
|
+
name: base64
|
53
|
+
requirement: !ruby/object:Gem::Requirement
|
54
|
+
requirements:
|
55
|
+
- - ">="
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: '0'
|
58
|
+
type: :runtime
|
59
|
+
prerelease: false
|
60
|
+
version_requirements: !ruby/object:Gem::Requirement
|
61
|
+
requirements:
|
62
|
+
- - ">="
|
63
|
+
- !ruby/object:Gem::Version
|
64
|
+
version: '0'
|
49
65
|
description:
|
50
66
|
email:
|
51
67
|
executables: []
|
@@ -94,7 +110,8 @@ files:
|
|
94
110
|
homepage: https://github.com/socketry/protocol-http
|
95
111
|
licenses:
|
96
112
|
- MIT
|
97
|
-
metadata:
|
113
|
+
metadata:
|
114
|
+
documentation_uri: https://socketry.github.io/protocol-http/
|
98
115
|
post_install_message:
|
99
116
|
rdoc_options: []
|
100
117
|
require_paths:
|
@@ -103,14 +120,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
103
120
|
requirements:
|
104
121
|
- - ">="
|
105
122
|
- !ruby/object:Gem::Version
|
106
|
-
version:
|
123
|
+
version: '3.0'
|
107
124
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
108
125
|
requirements:
|
109
126
|
- - ">="
|
110
127
|
- !ruby/object:Gem::Version
|
111
128
|
version: '0'
|
112
129
|
requirements: []
|
113
|
-
rubygems_version: 3.
|
130
|
+
rubygems_version: 3.5.3
|
114
131
|
signing_key:
|
115
132
|
specification_version: 4
|
116
133
|
summary: Provides abstractions to handle HTTP protocols.
|
metadata.gz.sig
CHANGED
Binary file
|