protocol-http 0.48.0 → 0.50.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/lib/protocol/http/body/buffered.rb +3 -2
- data/lib/protocol/http/body/head.rb +2 -1
- data/lib/protocol/http/body/rewindable.rb +3 -2
- data/lib/protocol/http/body/stream.rb +6 -1
- data/lib/protocol/http/header/accept.rb +10 -0
- data/lib/protocol/http/methods.rb +3 -3
- data/lib/protocol/http/request.rb +3 -2
- data/lib/protocol/http/version.rb +2 -2
- data/license.md +1 -0
- data.tar.gz.sig +0 -0
- metadata +4 -3
- 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: a149fe05f4aa029e53311afcde231a52bc3edb37ef6b7b1a8692ad810a8d09cf
|
4
|
+
data.tar.gz: d08125fb593047347be471daa72ee56b76bde776f23f6b23ce0e6e9d05da0339
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 12e43aeb55bafe83688f7e1385e0c948b419348f0da31baf44a772473ffffb4be57d66b13e511fcfcd906a0855f7fa5ba7ecf378da893b155a795e66ac5d19c0
|
7
|
+
data.tar.gz: c7a5118e4ca3b9a471f9850ec0497126e73638b2963b3379e252c0b69c8ea08f5bbccd5a91ab354a38d17d12eb3333d3698611abab354b2fc0f708e2f35186d1
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
@@ -1,15 +1,16 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
# Released under the MIT License.
|
4
|
-
# Copyright, 2019-
|
4
|
+
# Copyright, 2019-2025, by Samuel Williams.
|
5
5
|
# Copyright, 2020, by Bryan Powell.
|
6
|
+
# Copyright, 2025, by William T. Nelson.
|
6
7
|
|
7
8
|
require_relative "readable"
|
8
9
|
|
9
10
|
module Protocol
|
10
11
|
module HTTP
|
11
12
|
module Body
|
12
|
-
# A body which buffers all
|
13
|
+
# A body which buffers all its contents.
|
13
14
|
class Buffered < Readable
|
14
15
|
# Tries to wrap an object in a {Buffered} instance.
|
15
16
|
#
|
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
# Released under the MIT License.
|
4
4
|
# Copyright, 2020-2025, by Samuel Williams.
|
5
|
+
# Copyright, 2025, by William T. Nelson.
|
5
6
|
|
6
7
|
require_relative "readable"
|
7
8
|
|
@@ -10,7 +11,7 @@ module Protocol
|
|
10
11
|
module Body
|
11
12
|
# Represents a body suitable for HEAD requests, in other words, a body that is empty and has a known length.
|
12
13
|
class Head < Readable
|
13
|
-
# Create a head body for the given body, capturing
|
14
|
+
# Create a head body for the given body, capturing its length and then closing it.
|
14
15
|
def self.for(body)
|
15
16
|
head = self.new(body.length)
|
16
17
|
|
@@ -1,7 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
# Released under the MIT License.
|
4
|
-
# Copyright, 2019-
|
4
|
+
# Copyright, 2019-2025, by Samuel Williams.
|
5
|
+
# Copyright, 2025, by William T. Nelson.
|
5
6
|
|
6
7
|
require_relative "wrapper"
|
7
8
|
require_relative "buffered"
|
@@ -9,7 +10,7 @@ require_relative "buffered"
|
|
9
10
|
module Protocol
|
10
11
|
module HTTP
|
11
12
|
module Body
|
12
|
-
# A body which buffers all
|
13
|
+
# A body which buffers all its contents as it is read.
|
13
14
|
#
|
14
15
|
# As the body is buffered in memory, you may want to ensure your server has sufficient (virtual) memory available to buffer the entire body.
|
15
16
|
class Rewindable < Wrapper
|
@@ -263,7 +263,12 @@ module Protocol
|
|
263
263
|
buffer = @buffer
|
264
264
|
@buffer = nil
|
265
265
|
|
266
|
-
return
|
266
|
+
# Return nil for empty buffers, otherwise return the content:
|
267
|
+
if buffer && !buffer.empty?
|
268
|
+
return buffer
|
269
|
+
else
|
270
|
+
return nil
|
271
|
+
end
|
267
272
|
end
|
268
273
|
end
|
269
274
|
|
@@ -30,10 +30,16 @@ module Protocol
|
|
30
30
|
|
31
31
|
# A single entry in the Accept: header, which includes a mime type and associated parameters. A media range can include wild cards, but a media type is a specific type and subtype.
|
32
32
|
MediaRange = Struct.new(:type, :subtype, :parameters) do
|
33
|
+
# Create a new media range.
|
34
|
+
#
|
35
|
+
# @parameter type [String] the type of the media range.
|
36
|
+
# @parameter subtype [String] the subtype of the media range.
|
37
|
+
# @parameter parameters [Hash] the parameters associated with the media range.
|
33
38
|
def initialize(type, subtype = "*", parameters = {})
|
34
39
|
super(type, subtype, parameters)
|
35
40
|
end
|
36
41
|
|
42
|
+
# Compare the media range with another media range or a string, based on the quality factor.
|
37
43
|
def <=> other
|
38
44
|
other.quality_factor <=> self.quality_factor
|
39
45
|
end
|
@@ -46,12 +52,16 @@ module Protocol
|
|
46
52
|
end.join
|
47
53
|
end
|
48
54
|
|
55
|
+
# The string representation of the media range, including the type, subtype, and any parameters.
|
49
56
|
def to_s
|
50
57
|
"#{type}/#{subtype}#{parameters_string}"
|
51
58
|
end
|
52
59
|
|
53
60
|
alias to_str to_s
|
54
61
|
|
62
|
+
# The quality factor associated with the media range, which is used to determine the order of preference.
|
63
|
+
#
|
64
|
+
# @returns [Float] the quality factor, which defaults to 1.0 if not specified.
|
55
65
|
def quality_factor
|
56
66
|
parameters.fetch("q", 1.0).to_f
|
57
67
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
# Released under the MIT License.
|
4
|
-
# Copyright, 2018-
|
4
|
+
# Copyright, 2018-2025, by Samuel Williams.
|
5
5
|
|
6
6
|
module Protocol
|
7
7
|
module HTTP
|
@@ -75,9 +75,9 @@ module Protocol
|
|
75
75
|
end
|
76
76
|
|
77
77
|
self.each do |name, method|
|
78
|
-
define_method(name) do
|
78
|
+
define_method(name) do |*arguments, **options|
|
79
79
|
self.call(
|
80
|
-
Request[method,
|
80
|
+
Request[method, *arguments, **options]
|
81
81
|
)
|
82
82
|
end
|
83
83
|
end
|
@@ -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-2025, by Samuel Williams.
|
5
5
|
|
6
6
|
require_relative "body/buffered"
|
7
7
|
require_relative "body/reader"
|
@@ -124,7 +124,8 @@ module Protocol
|
|
124
124
|
# @parameter path [String] The path, e.g. `"/index.html"`, `"/search?q=hello"`, etc.
|
125
125
|
# @parameter headers [Hash] The headers, e.g. `{"accept" => "text/html"}`, etc.
|
126
126
|
# @parameter body [String | Array(String) | Body::Readable] The body, e.g. `"Hello, World!"`, etc. See {Body::Buffered.wrap} for more information about .
|
127
|
-
def self.[](method, path, _headers = nil, _body = nil, scheme: nil, authority: nil, headers: _headers, body: _body, protocol: nil, interim_response: nil)
|
127
|
+
def self.[](method, path = nil, _headers = nil, _body = nil, scheme: nil, authority: nil, headers: _headers, body: _body, protocol: nil, interim_response: nil)
|
128
|
+
path = path&.to_s
|
128
129
|
body = Body::Buffered.wrap(body)
|
129
130
|
headers = Headers[headers]
|
130
131
|
|
data/license.md
CHANGED
@@ -11,6 +11,7 @@ Copyright, 2023, by Genki Takiuchi.
|
|
11
11
|
Copyright, 2023-2024, by Thomas Morgan.
|
12
12
|
Copyright, 2023, by Marcelo Junior.
|
13
13
|
Copyright, 2024, by Earlopain.
|
14
|
+
Copyright, 2025, by William T. Nelson.
|
14
15
|
|
15
16
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
16
17
|
of this software and associated documentation files (the "Software"), to deal
|
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.
|
4
|
+
version: 0.50.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
@@ -14,6 +14,7 @@ authors:
|
|
14
14
|
- Genki Takiuchi
|
15
15
|
- Marcelo Junior
|
16
16
|
- Olle Jonsson
|
17
|
+
- William T. Nelson
|
17
18
|
- Yuta Iwama
|
18
19
|
bindir: bin
|
19
20
|
cert_chain:
|
@@ -46,7 +47,7 @@ cert_chain:
|
|
46
47
|
Q2K9NVun/S785AP05vKkXZEFYxqG6EW012U4oLcFl5MySFajYXRYbuUpH6AY+HP8
|
47
48
|
voD0MPg1DssDLKwXyt1eKD/+Fq0bFWhwVM/1XiAXL7lyYUyOq24KHgQ2Csg=
|
48
49
|
-----END CERTIFICATE-----
|
49
|
-
date: 2025-
|
50
|
+
date: 2025-04-28 00:00:00.000000000 Z
|
50
51
|
dependencies: []
|
51
52
|
executables: []
|
52
53
|
extensions: []
|
@@ -114,7 +115,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
114
115
|
requirements:
|
115
116
|
- - ">="
|
116
117
|
- !ruby/object:Gem::Version
|
117
|
-
version: '3.
|
118
|
+
version: '3.2'
|
118
119
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
119
120
|
requirements:
|
120
121
|
- - ">="
|
metadata.gz.sig
CHANGED
Binary file
|