protocol-rack 0.9.0 → 0.10.1
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/rack/adapter/generic.rb +10 -10
- data/lib/protocol/rack/adapter/rack2.rb +12 -12
- data/lib/protocol/rack/adapter/rack3.rb +7 -7
- data/lib/protocol/rack/adapter.rb +3 -3
- data/lib/protocol/rack/body/enumerable.rb +4 -4
- data/lib/protocol/rack/body/input_wrapper.rb +3 -3
- data/lib/protocol/rack/body/streaming.rb +2 -73
- data/lib/protocol/rack/body.rb +5 -5
- data/lib/protocol/rack/constants.rb +23 -23
- data/lib/protocol/rack/input.rb +8 -1
- data/lib/protocol/rack/request.rb +16 -16
- data/lib/protocol/rack/response.rb +11 -11
- data/lib/protocol/rack/rewindable.rb +5 -5
- data/lib/protocol/rack/version.rb +1 -1
- data/lib/protocol/rack.rb +5 -5
- data.tar.gz.sig +0 -0
- metadata +4 -4
- 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: 10a0c5ad45e5da6659b4b3bef87ba9f2161727e4e465694421bf9d3b1ba3d37a
|
4
|
+
data.tar.gz: 7f87087ac4cec6a2d58c3b0a30066f00b3b43e14c513813aad780c581dec3651
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aec78a45bb3c5287841286308a61063910a26384768da2f9aba370b46c9604321253491d488b05aecffa57e194955dc6910a1b2af5bf46e550bf23a03dd0fc0c
|
7
|
+
data.tar.gz: c83dcd78e675d363d40002a666642a1e4a0a897ebf70815ee9eab0523da6845ea65cff5f1bfef20c4e9f703e1409076a471a26d04e85273488164c0638c065aa
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
@@ -3,11 +3,11 @@
|
|
3
3
|
# Released under the MIT License.
|
4
4
|
# Copyright, 2022-2024, by Samuel Williams.
|
5
5
|
|
6
|
-
require
|
6
|
+
require "console"
|
7
7
|
|
8
|
-
require_relative
|
9
|
-
require_relative
|
10
|
-
require_relative
|
8
|
+
require_relative "../constants"
|
9
|
+
require_relative "../input"
|
10
|
+
require_relative "../response"
|
11
11
|
|
12
12
|
module Protocol
|
13
13
|
module Rack
|
@@ -66,7 +66,7 @@ module Protocol
|
|
66
66
|
# @parameter request [Protocol::HTTP::Request] The incoming request.
|
67
67
|
# @parameter env [Hash] The rack `env`.
|
68
68
|
def unwrap_request(request, env)
|
69
|
-
if content_type = request.headers.delete(
|
69
|
+
if content_type = request.headers.delete("content-type")
|
70
70
|
env[CGI::CONTENT_TYPE] = content_type
|
71
71
|
end
|
72
72
|
|
@@ -78,7 +78,7 @@ module Protocol
|
|
78
78
|
self.unwrap_headers(request.headers, env)
|
79
79
|
|
80
80
|
# For the sake of compatibility, we set the `HTTP_UPGRADE` header to the requested protocol.
|
81
|
-
if protocol = request.protocol and request.version.start_with?(
|
81
|
+
if protocol = request.protocol and request.version.start_with?("HTTP/1")
|
82
82
|
env[CGI::HTTP_UPGRADE] = Array(protocol).join(",")
|
83
83
|
end
|
84
84
|
|
@@ -146,13 +146,13 @@ module Protocol
|
|
146
146
|
def self.extract_protocol(env, response, headers)
|
147
147
|
if protocol = response.protocol
|
148
148
|
# This is the newer mechanism for protocol upgrade:
|
149
|
-
if env[
|
150
|
-
headers[
|
149
|
+
if env["rack.protocol"]
|
150
|
+
headers["rack.protocol"] = protocol
|
151
151
|
|
152
152
|
# Older mechanism for protocol upgrade:
|
153
153
|
elsif env[CGI::HTTP_UPGRADE]
|
154
|
-
headers[
|
155
|
-
headers[
|
154
|
+
headers["upgrade"] = protocol
|
155
|
+
headers["connection"] = "upgrade"
|
156
156
|
end
|
157
157
|
end
|
158
158
|
end
|
@@ -3,27 +3,27 @@
|
|
3
3
|
# Released under the MIT License.
|
4
4
|
# Copyright, 2022-2024, by Samuel Williams.
|
5
5
|
|
6
|
-
require
|
6
|
+
require "console"
|
7
7
|
|
8
|
-
require_relative
|
9
|
-
require_relative
|
8
|
+
require_relative "generic"
|
9
|
+
require_relative "../rewindable"
|
10
10
|
|
11
11
|
module Protocol
|
12
12
|
module Rack
|
13
13
|
module Adapter
|
14
14
|
class Rack2 < Generic
|
15
|
-
RACK_VERSION =
|
16
|
-
RACK_MULTITHREAD =
|
17
|
-
RACK_MULTIPROCESS =
|
18
|
-
RACK_RUN_ONCE =
|
15
|
+
RACK_VERSION = "rack.version"
|
16
|
+
RACK_MULTITHREAD = "rack.multithread"
|
17
|
+
RACK_MULTIPROCESS = "rack.multiprocess"
|
18
|
+
RACK_RUN_ONCE = "rack.run_once"
|
19
19
|
|
20
20
|
def self.wrap(app)
|
21
21
|
Rewindable.new(self.new(app))
|
22
22
|
end
|
23
23
|
|
24
24
|
def make_environment(request)
|
25
|
-
request_path, query_string = request.path.split(
|
26
|
-
server_name, server_port = (request.authority ||
|
25
|
+
request_path, query_string = request.path.split("?", 2)
|
26
|
+
server_name, server_port = (request.authority || "").split(":", 2)
|
27
27
|
|
28
28
|
env = {
|
29
29
|
RACK_VERSION => [2, 0],
|
@@ -44,7 +44,7 @@ module Protocol
|
|
44
44
|
CGI::REQUEST_METHOD => request.method,
|
45
45
|
|
46
46
|
# The initial portion of the request URL's “path” that corresponds to the application object, so that the application knows its virtual “location”. This may be an empty string, if the application corresponds to the “root” of the server.
|
47
|
-
CGI::SCRIPT_NAME =>
|
47
|
+
CGI::SCRIPT_NAME => "",
|
48
48
|
|
49
49
|
# The remainder of the request URL's “path”, designating the virtual “location” of the request's target within the application. This may be an empty string, if the request URL targets the application root and does not have a trailing slash. This value may be percent-encoded when originating from a URL.
|
50
50
|
CGI::PATH_INFO => request_path,
|
@@ -52,7 +52,7 @@ module Protocol
|
|
52
52
|
CGI::REQUEST_URI => request.path,
|
53
53
|
|
54
54
|
# The portion of the request URL that follows the ?, if any. May be empty, but is always required!
|
55
|
-
CGI::QUERY_STRING => query_string ||
|
55
|
+
CGI::QUERY_STRING => query_string || "",
|
56
56
|
|
57
57
|
# The server protocol (e.g. HTTP/1.1):
|
58
58
|
CGI::SERVER_PROTOCOL => request.version,
|
@@ -103,7 +103,7 @@ module Protocol
|
|
103
103
|
fields.each do |key, value|
|
104
104
|
key = key.downcase
|
105
105
|
|
106
|
-
if key.start_with?(
|
106
|
+
if key.start_with?("rack.")
|
107
107
|
meta[key] = value
|
108
108
|
elsif value.is_a?(String)
|
109
109
|
value.split("\n").each do |value|
|
@@ -3,9 +3,9 @@
|
|
3
3
|
# Released under the MIT License.
|
4
4
|
# Copyright, 2022-2024, by Samuel Williams.
|
5
5
|
|
6
|
-
require
|
6
|
+
require "console"
|
7
7
|
|
8
|
-
require_relative
|
8
|
+
require_relative "generic"
|
9
9
|
|
10
10
|
module Protocol
|
11
11
|
module Rack
|
@@ -20,8 +20,8 @@ module Protocol
|
|
20
20
|
end
|
21
21
|
|
22
22
|
def make_environment(request)
|
23
|
-
request_path, query_string = request.path.split(
|
24
|
-
server_name, server_port = (request.authority ||
|
23
|
+
request_path, query_string = request.path.split("?", 2)
|
24
|
+
server_name, server_port = (request.authority || "").split(":", 2)
|
25
25
|
|
26
26
|
env = {
|
27
27
|
PROTOCOL_HTTP_REQUEST => request,
|
@@ -40,7 +40,7 @@ module Protocol
|
|
40
40
|
CGI::REQUEST_METHOD => request.method,
|
41
41
|
|
42
42
|
# The initial portion of the request URL's “path” that corresponds to the application object, so that the application knows its virtual “location”. This may be an empty string, if the application corresponds to the “root” of the server.
|
43
|
-
CGI::SCRIPT_NAME =>
|
43
|
+
CGI::SCRIPT_NAME => "",
|
44
44
|
|
45
45
|
# The remainder of the request URL's “path”, designating the virtual “location” of the request's target within the application. This may be an empty string, if the request URL targets the application root and does not have a trailing slash. This value may be percent-encoded when originating from a URL.
|
46
46
|
CGI::PATH_INFO => request_path,
|
@@ -48,7 +48,7 @@ module Protocol
|
|
48
48
|
CGI::REQUEST_URI => request.path,
|
49
49
|
|
50
50
|
# The portion of the request URL that follows the ?, if any. May be empty, but is always required!
|
51
|
-
CGI::QUERY_STRING => query_string ||
|
51
|
+
CGI::QUERY_STRING => query_string || "",
|
52
52
|
|
53
53
|
# The server protocol (e.g. HTTP/1.1):
|
54
54
|
CGI::SERVER_PROTOCOL => request.version,
|
@@ -75,7 +75,7 @@ module Protocol
|
|
75
75
|
fields.each do |key, value|
|
76
76
|
key = key.downcase
|
77
77
|
|
78
|
-
if key.start_with?(
|
78
|
+
if key.start_with?("rack.")
|
79
79
|
meta[key] = value
|
80
80
|
elsif value.is_a?(Array)
|
81
81
|
value.each do |value|
|
@@ -3,10 +3,10 @@
|
|
3
3
|
# Released under the MIT License.
|
4
4
|
# Copyright, 2022-2024, by Samuel Williams.
|
5
5
|
|
6
|
-
require
|
6
|
+
require "rack"
|
7
7
|
|
8
|
-
require_relative
|
9
|
-
require_relative
|
8
|
+
require_relative "adapter/rack2"
|
9
|
+
require_relative "adapter/rack3"
|
10
10
|
|
11
11
|
module Protocol
|
12
12
|
module Rack
|
@@ -1,10 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
# Released under the MIT License.
|
4
|
-
# Copyright, 2022, by Samuel Williams.
|
4
|
+
# Copyright, 2022-2024, by Samuel Williams.
|
5
5
|
|
6
|
-
require
|
7
|
-
require
|
6
|
+
require "protocol/http/body/readable"
|
7
|
+
require "protocol/http/body/file"
|
8
8
|
|
9
9
|
module Protocol
|
10
10
|
module Rack
|
@@ -13,7 +13,7 @@ module Protocol
|
|
13
13
|
#
|
14
14
|
# The `rack` body must respond to `each` and must only yield `String` values. If the body responds to `close`, it will be called after iteration.
|
15
15
|
class Enumerable < ::Protocol::HTTP::Body::Readable
|
16
|
-
CONTENT_LENGTH =
|
16
|
+
CONTENT_LENGTH = "content-length".freeze
|
17
17
|
|
18
18
|
# Wraps an array into a buffered body.
|
19
19
|
# @parameter body [Object] The `rack` response body.
|
@@ -1,10 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
# Released under the MIT License.
|
4
|
-
# Copyright, 2022, by Samuel Williams.
|
4
|
+
# Copyright, 2022-2024, by Samuel Williams.
|
5
5
|
|
6
|
-
require
|
7
|
-
require
|
6
|
+
require "protocol/http/body/readable"
|
7
|
+
require "protocol/http/body/stream"
|
8
8
|
|
9
9
|
module Protocol
|
10
10
|
module Rack
|
@@ -3,83 +3,12 @@
|
|
3
3
|
# Released under the MIT License.
|
4
4
|
# Copyright, 2022-2024, by Samuel Williams.
|
5
5
|
|
6
|
-
require
|
7
|
-
require 'protocol/http/body/stream'
|
6
|
+
require "protocol/http/body/streamable"
|
8
7
|
|
9
8
|
module Protocol
|
10
9
|
module Rack
|
11
10
|
module Body
|
12
|
-
|
13
|
-
class Streaming < ::Protocol::HTTP::Body::Readable
|
14
|
-
def initialize(block, input = nil)
|
15
|
-
@block = block
|
16
|
-
@input = input
|
17
|
-
@output = nil
|
18
|
-
end
|
19
|
-
|
20
|
-
attr :block
|
21
|
-
|
22
|
-
class Output
|
23
|
-
def initialize(input, block)
|
24
|
-
stream = ::Protocol::HTTP::Body::Stream.new(input, self)
|
25
|
-
|
26
|
-
@from = nil
|
27
|
-
|
28
|
-
@fiber = Fiber.new do |from|
|
29
|
-
@from = from
|
30
|
-
block.call(stream)
|
31
|
-
@fiber = nil
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
def write(chunk)
|
36
|
-
if from = @from
|
37
|
-
@from = nil
|
38
|
-
@from = from.transfer(chunk)
|
39
|
-
else
|
40
|
-
raise RuntimeError, "Stream is not being read!"
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
def close(error = nil)
|
45
|
-
@fiber = nil
|
46
|
-
|
47
|
-
if from = @from
|
48
|
-
@from = nil
|
49
|
-
if error
|
50
|
-
from.raise(error)
|
51
|
-
else
|
52
|
-
from.transfer(nil)
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
def close_write(error = nil)
|
58
|
-
close(error)
|
59
|
-
end
|
60
|
-
|
61
|
-
def read
|
62
|
-
raise RuntimeError, "Stream is already being read!" if @from
|
63
|
-
|
64
|
-
@fiber&.transfer(Fiber.current)
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
# Invokes the block in a fiber which yields chunks when they are available.
|
69
|
-
def read
|
70
|
-
@output ||= Output.new(@input, @block)
|
71
|
-
return @output.read
|
72
|
-
end
|
73
|
-
|
74
|
-
def stream?
|
75
|
-
true
|
76
|
-
end
|
77
|
-
|
78
|
-
def call(stream)
|
79
|
-
raise "Streaming body has already been read!" if @output
|
80
|
-
@block.call(stream)
|
81
|
-
end
|
82
|
-
end
|
11
|
+
Streaming = ::Protocol::HTTP::Body::Streamable::ResponseBody
|
83
12
|
end
|
84
13
|
end
|
85
14
|
end
|
data/lib/protocol/rack/body.rb
CHANGED
@@ -1,16 +1,16 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
# Released under the MIT License.
|
4
|
-
# Copyright, 2022, by Samuel Williams.
|
4
|
+
# Copyright, 2022-2024, by Samuel Williams.
|
5
5
|
|
6
|
-
require_relative
|
7
|
-
require_relative
|
8
|
-
require
|
6
|
+
require_relative "body/streaming"
|
7
|
+
require_relative "body/enumerable"
|
8
|
+
require "protocol/http/body/completable"
|
9
9
|
|
10
10
|
module Protocol
|
11
11
|
module Rack
|
12
12
|
module Body
|
13
|
-
CONTENT_LENGTH =
|
13
|
+
CONTENT_LENGTH = "content-length"
|
14
14
|
|
15
15
|
def self.wrap(env, status, headers, body, input = nil)
|
16
16
|
# In no circumstance do we want this header propagating out:
|
@@ -10,37 +10,37 @@ module Protocol
|
|
10
10
|
|
11
11
|
# CGI keys <https://tools.ietf.org/html/rfc3875#section-4.1>:
|
12
12
|
module CGI
|
13
|
-
HTTP_HOST =
|
13
|
+
HTTP_HOST = "HTTP_HOST"
|
14
14
|
HTTP_UPGRADE = "HTTP_UPGRADE"
|
15
|
-
PATH_INFO =
|
16
|
-
REQUEST_METHOD =
|
17
|
-
REQUEST_PATH =
|
18
|
-
REQUEST_URI =
|
19
|
-
SCRIPT_NAME =
|
20
|
-
QUERY_STRING =
|
21
|
-
SERVER_PROTOCOL =
|
22
|
-
SERVER_NAME =
|
23
|
-
SERVER_PORT =
|
24
|
-
REMOTE_ADDR =
|
25
|
-
CONTENT_TYPE =
|
26
|
-
CONTENT_LENGTH =
|
15
|
+
PATH_INFO = "PATH_INFO"
|
16
|
+
REQUEST_METHOD = "REQUEST_METHOD"
|
17
|
+
REQUEST_PATH = "REQUEST_PATH"
|
18
|
+
REQUEST_URI = "REQUEST_URI"
|
19
|
+
SCRIPT_NAME = "SCRIPT_NAME"
|
20
|
+
QUERY_STRING = "QUERY_STRING"
|
21
|
+
SERVER_PROTOCOL = "SERVER_PROTOCOL"
|
22
|
+
SERVER_NAME = "SERVER_NAME"
|
23
|
+
SERVER_PORT = "SERVER_PORT"
|
24
|
+
REMOTE_ADDR = "REMOTE_ADDR"
|
25
|
+
CONTENT_TYPE = "CONTENT_TYPE"
|
26
|
+
CONTENT_LENGTH = "CONTENT_LENGTH"
|
27
27
|
|
28
|
-
HTTP_COOKIE =
|
28
|
+
HTTP_COOKIE = "HTTP_COOKIE"
|
29
29
|
|
30
30
|
# Header constants:
|
31
|
-
HTTP_X_FORWARDED_PROTO =
|
31
|
+
HTTP_X_FORWARDED_PROTO = "HTTP_X_FORWARDED_PROTO"
|
32
32
|
end
|
33
33
|
|
34
34
|
# Rack environment variables:
|
35
|
-
RACK_ERRORS =
|
36
|
-
RACK_LOGGER =
|
37
|
-
RACK_INPUT =
|
38
|
-
RACK_URL_SCHEME =
|
39
|
-
RACK_PROTOCOL =
|
40
|
-
RACK_RESPONSE_FINISHED =
|
35
|
+
RACK_ERRORS = "rack.errors"
|
36
|
+
RACK_LOGGER = "rack.logger"
|
37
|
+
RACK_INPUT = "rack.input"
|
38
|
+
RACK_URL_SCHEME = "rack.url_scheme"
|
39
|
+
RACK_PROTOCOL = "rack.protocol"
|
40
|
+
RACK_RESPONSE_FINISHED = "rack.response_finished"
|
41
41
|
|
42
42
|
# Rack hijack support:
|
43
|
-
RACK_IS_HIJACK =
|
44
|
-
RACK_HIJACK =
|
43
|
+
RACK_IS_HIJACK = "rack.hijack?"
|
44
|
+
RACK_HIJACK = "rack.hijack"
|
45
45
|
end
|
46
46
|
end
|
data/lib/protocol/rack/input.rb
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
# Copyright, 2022-2024, by Samuel Williams.
|
5
5
|
# Copyright, 2023, by Genki Takiuchi.
|
6
6
|
|
7
|
-
require
|
7
|
+
require "protocol/http/body/stream"
|
8
8
|
|
9
9
|
module Protocol
|
10
10
|
module Rack
|
@@ -89,6 +89,13 @@ module Protocol
|
|
89
89
|
if @body
|
90
90
|
# User's may forget to call #close...
|
91
91
|
if chunk = @body.read
|
92
|
+
# If the user reads exactly the content length, we close the stream automatically:
|
93
|
+
# https://github.com/socketry/async-http/issues/183
|
94
|
+
if @body.empty?
|
95
|
+
@body.close
|
96
|
+
@body = nil
|
97
|
+
end
|
98
|
+
|
92
99
|
return chunk
|
93
100
|
else
|
94
101
|
# So if we are at the end of the stream, we close it automatically:
|
@@ -1,38 +1,38 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
# Released under the MIT License.
|
4
|
-
# Copyright, 2022-
|
4
|
+
# Copyright, 2022-2024, by Samuel Williams.
|
5
5
|
|
6
|
-
require
|
7
|
-
require
|
6
|
+
require "protocol/http/request"
|
7
|
+
require "protocol/http/headers"
|
8
8
|
|
9
|
-
require_relative
|
10
|
-
require_relative
|
9
|
+
require_relative "constants"
|
10
|
+
require_relative "body/input_wrapper"
|
11
11
|
|
12
12
|
module Protocol
|
13
13
|
module Rack
|
14
14
|
class Request < ::Protocol::HTTP::Request
|
15
15
|
def self.[](env)
|
16
|
-
env[
|
16
|
+
env["protocol.http.request"] ||= new(env)
|
17
17
|
end
|
18
18
|
|
19
19
|
def initialize(env)
|
20
20
|
@env = env
|
21
21
|
|
22
22
|
super(
|
23
|
-
@env[
|
24
|
-
@env[
|
25
|
-
@env[
|
26
|
-
@env[
|
27
|
-
@env[
|
23
|
+
@env["rack.url_scheme"],
|
24
|
+
@env["HTTP_HOST"],
|
25
|
+
@env["REQUEST_METHOD"],
|
26
|
+
@env["PATH_INFO"],
|
27
|
+
@env["SERVER_PROTOCOL"],
|
28
28
|
self.class.headers(@env),
|
29
|
-
Body::InputWrapper.new(@env[
|
29
|
+
Body::InputWrapper.new(@env["rack.input"]),
|
30
30
|
self.class.protocol(@env)
|
31
31
|
)
|
32
32
|
end
|
33
33
|
|
34
34
|
def self.protocol(env)
|
35
|
-
if protocols = env[
|
35
|
+
if protocols = env["rack.protocol"]
|
36
36
|
return Array(protocols)
|
37
37
|
elsif protocols = env[CGI::HTTP_UPGRADE]
|
38
38
|
return protocols.split(/\s*,\s*/)
|
@@ -42,9 +42,9 @@ module Protocol
|
|
42
42
|
def self.headers(env)
|
43
43
|
headers = ::Protocol::HTTP::Headers.new
|
44
44
|
env.each do |key, value|
|
45
|
-
if key.start_with?(
|
46
|
-
next if key ==
|
47
|
-
headers[key[5..-1].gsub(
|
45
|
+
if key.start_with?("HTTP_")
|
46
|
+
next if key == "HTTP_HOST"
|
47
|
+
headers[key[5..-1].gsub("_", "-").downcase] = value
|
48
48
|
end
|
49
49
|
end
|
50
50
|
|
@@ -3,12 +3,12 @@
|
|
3
3
|
# Released under the MIT License.
|
4
4
|
# Copyright, 2022-2024, by Samuel Williams.
|
5
5
|
|
6
|
-
require_relative
|
7
|
-
require_relative
|
6
|
+
require_relative "body"
|
7
|
+
require_relative "constants"
|
8
8
|
# require 'time'
|
9
9
|
|
10
|
-
require
|
11
|
-
require
|
10
|
+
require "protocol/http/response"
|
11
|
+
require "protocol/http/headers"
|
12
12
|
|
13
13
|
module Protocol
|
14
14
|
module Rack
|
@@ -26,12 +26,12 @@ module Protocol
|
|
26
26
|
class Response < ::Protocol::HTTP::Response
|
27
27
|
# HTTP hop headers which *should* not be passed through the proxy.
|
28
28
|
HOP_HEADERS = [
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
29
|
+
"connection",
|
30
|
+
"keep-alive",
|
31
|
+
"public",
|
32
|
+
"proxy-authenticate",
|
33
|
+
"transfer-encoding",
|
34
|
+
"upgrade",
|
35
35
|
]
|
36
36
|
|
37
37
|
# Wrap a rack response.
|
@@ -46,7 +46,7 @@ module Protocol
|
|
46
46
|
Console.warn(self, "Ignoring hop headers!", ignored: ignored)
|
47
47
|
end
|
48
48
|
|
49
|
-
if hijack_body = meta[
|
49
|
+
if hijack_body = meta["rack.hijack"]
|
50
50
|
body = hijack_body
|
51
51
|
end
|
52
52
|
|
@@ -1,10 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
# Released under the MIT License.
|
4
|
-
# Copyright, 2022, by Samuel Williams.
|
4
|
+
# Copyright, 2022-2024, by Samuel Williams.
|
5
5
|
|
6
|
-
require
|
7
|
-
require
|
6
|
+
require "protocol/http/body/rewindable"
|
7
|
+
require "protocol/http/middleware"
|
8
8
|
|
9
9
|
module Protocol
|
10
10
|
module Rack
|
@@ -18,7 +18,7 @@ module Protocol
|
|
18
18
|
multipart/mixed
|
19
19
|
}x
|
20
20
|
|
21
|
-
POST =
|
21
|
+
POST = "POST"
|
22
22
|
|
23
23
|
# Initialize the rewindable middleware.
|
24
24
|
# @parameter app [Protocol::HTTP::Middleware] The middleware to wrap.
|
@@ -30,7 +30,7 @@ module Protocol
|
|
30
30
|
# @parameter request [Protocol::HTTP::Request]
|
31
31
|
# @returns [Boolean]
|
32
32
|
def needs_rewind?(request)
|
33
|
-
content_type = request.headers[
|
33
|
+
content_type = request.headers["content-type"]
|
34
34
|
|
35
35
|
if request.method == POST and content_type.nil?
|
36
36
|
return true
|
data/lib/protocol/rack.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
# Released under the MIT License.
|
4
|
-
# Copyright, 2022, by Samuel Williams.
|
4
|
+
# Copyright, 2022-2024, by Samuel Williams.
|
5
5
|
|
6
|
-
require_relative
|
7
|
-
require_relative
|
8
|
-
require_relative
|
9
|
-
require_relative
|
6
|
+
require_relative "rack/version"
|
7
|
+
require_relative "rack/adapter"
|
8
|
+
require_relative "rack/request"
|
9
|
+
require_relative "rack/response"
|
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: protocol-rack
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.10.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
@@ -38,7 +38,7 @@ cert_chain:
|
|
38
38
|
Q2K9NVun/S785AP05vKkXZEFYxqG6EW012U4oLcFl5MySFajYXRYbuUpH6AY+HP8
|
39
39
|
voD0MPg1DssDLKwXyt1eKD/+Fq0bFWhwVM/1XiAXL7lyYUyOq24KHgQ2Csg=
|
40
40
|
-----END CERTIFICATE-----
|
41
|
-
date: 2024-
|
41
|
+
date: 2024-10-11 00:00:00.000000000 Z
|
42
42
|
dependencies:
|
43
43
|
- !ruby/object:Gem::Dependency
|
44
44
|
name: protocol-http
|
@@ -46,14 +46,14 @@ dependencies:
|
|
46
46
|
requirements:
|
47
47
|
- - "~>"
|
48
48
|
- !ruby/object:Gem::Version
|
49
|
-
version: '0.
|
49
|
+
version: '0.37'
|
50
50
|
type: :runtime
|
51
51
|
prerelease: false
|
52
52
|
version_requirements: !ruby/object:Gem::Requirement
|
53
53
|
requirements:
|
54
54
|
- - "~>"
|
55
55
|
- !ruby/object:Gem::Version
|
56
|
-
version: '0.
|
56
|
+
version: '0.37'
|
57
57
|
- !ruby/object:Gem::Dependency
|
58
58
|
name: rack
|
59
59
|
requirement: !ruby/object:Gem::Requirement
|
metadata.gz.sig
CHANGED
Binary file
|