protocol-rack 0.10.1 → 0.11.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 10a0c5ad45e5da6659b4b3bef87ba9f2161727e4e465694421bf9d3b1ba3d37a
4
- data.tar.gz: 7f87087ac4cec6a2d58c3b0a30066f00b3b43e14c513813aad780c581dec3651
3
+ metadata.gz: 30e960af55f8f9e0c401657bd0e245c448f46315ef97cdd3d25aeeb8f41ef99c
4
+ data.tar.gz: 1d4f9d858799b04e909776e120f4f376aa54ad4a956bd077e109edc704f3a2ff
5
5
  SHA512:
6
- metadata.gz: aec78a45bb3c5287841286308a61063910a26384768da2f9aba370b46c9604321253491d488b05aecffa57e194955dc6910a1b2af5bf46e550bf23a03dd0fc0c
7
- data.tar.gz: c83dcd78e675d363d40002a666642a1e4a0a897ebf70815ee9eab0523da6845ea65cff5f1bfef20c4e9f703e1409076a471a26d04e85273488164c0638c065aa
6
+ metadata.gz: c71e270584bfe6e4da54ce6b175664880180ddf5ba2cb5fec1fb4ef3b67aa93af2ef78ecc0d74869f477caed03e5caf4e072758fef7f831fcb8e249ccea60e5f
7
+ data.tar.gz: 9af0d3f0bbd79784f9f8464a1cffdfc76f55e9d49e386a9c770b43af85da2a2d1a0dfd0bbb624d2465d99f79ae1ef2663848d38195a2816aa57ebb9a9588a926
checksums.yaml.gz.sig CHANGED
Binary file
@@ -90,10 +90,8 @@ module Protocol
90
90
  # HTTP/2 prefers `:authority` over `host`, so we do this for backwards compatibility.
91
91
  env[CGI::HTTP_HOST] ||= request.authority
92
92
 
93
- if request.respond_to?(:remote_address)
94
- if remote_address = request.remote_address
95
- env[CGI::REMOTE_ADDR] = remote_address.ip_address if remote_address.ip?
96
- end
93
+ if peer = request.peer
94
+ env[CGI::REMOTE_ADDR] = peer.ip_address
97
95
  end
98
96
  end
99
97
 
@@ -0,0 +1,70 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Released under the MIT License.
4
+ # Copyright, 2022-2024, by Samuel Williams.
5
+
6
+ require "console"
7
+
8
+ require_relative "rack3"
9
+
10
+ module Protocol
11
+ module Rack
12
+ module Adapter
13
+ class Rack31 < Rack3
14
+ def make_environment(request)
15
+ request_path, query_string = request.path.split("?", 2)
16
+ server_name, server_port = (request.authority || "").split(":", 2)
17
+
18
+ env = {
19
+ PROTOCOL_HTTP_REQUEST => request,
20
+
21
+ RACK_ERRORS => $stderr,
22
+ RACK_LOGGER => self.logger,
23
+
24
+ # The request protocol, either from the upgrade header or the HTTP/2 pseudo header of the same name.
25
+ RACK_PROTOCOL => request.protocol,
26
+
27
+ # The response finished callbacks:
28
+ RACK_RESPONSE_FINISHED => [],
29
+
30
+ # The HTTP request method, such as “GET” or “POST”. This cannot ever be an empty string, and so is always required.
31
+ CGI::REQUEST_METHOD => request.method,
32
+
33
+ # 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.
34
+ CGI::SCRIPT_NAME => "",
35
+
36
+ # 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.
37
+ CGI::PATH_INFO => request_path,
38
+ CGI::REQUEST_PATH => request_path,
39
+ CGI::REQUEST_URI => request.path,
40
+
41
+ # The portion of the request URL that follows the ?, if any. May be empty, but is always required!
42
+ CGI::QUERY_STRING => query_string || "",
43
+
44
+ # The server protocol (e.g. HTTP/1.1):
45
+ CGI::SERVER_PROTOCOL => request.version,
46
+
47
+ # The request scheme:
48
+ RACK_URL_SCHEME => request.scheme,
49
+
50
+ # I'm not sure what sane defaults should be here:
51
+ CGI::SERVER_NAME => server_name,
52
+ CGI::SERVER_PORT => server_port,
53
+ }
54
+
55
+ if body = request.body
56
+ if body.empty?
57
+ body.close
58
+ else
59
+ env[RACK_INPUT] = Input.new(body)
60
+ end
61
+ end
62
+
63
+ self.unwrap_request(request, env)
64
+
65
+ return env
66
+ end
67
+ end
68
+ end
69
+ end
70
+ end
@@ -5,15 +5,19 @@
5
5
 
6
6
  require "rack"
7
7
 
8
- require_relative "adapter/rack2"
9
- require_relative "adapter/rack3"
10
-
11
8
  module Protocol
12
9
  module Rack
13
10
  module Adapter
14
- if ::Rack.release >= "3"
11
+ VERSION = ENV.fetch("PROTOCOL_RACK_ADAPTER_VERSION", ::Rack.release)
12
+
13
+ if VERSION >= "3.1"
14
+ require_relative "adapter/rack31"
15
+ IMPLEMENTATION = Rack31
16
+ elsif VERSION >= "3"
17
+ require_relative "adapter/rack3"
15
18
  IMPLEMENTATION = Rack3
16
19
  else
20
+ require_relative "adapter/rack2"
17
21
  IMPLEMENTATION = Rack2
18
22
  end
19
23
 
@@ -5,6 +5,6 @@
5
5
 
6
6
  module Protocol
7
7
  module Rack
8
- VERSION = "0.10.1"
8
+ VERSION = "0.11.0"
9
9
  end
10
10
  end
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.10.1
4
+ version: 0.11.0
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-10-11 00:00:00.000000000 Z
41
+ date: 2024-11-09 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.37'
49
+ version: '0.43'
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.37'
56
+ version: '0.43'
57
57
  - !ruby/object:Gem::Dependency
58
58
  name: rack
59
59
  requirement: !ruby/object:Gem::Requirement
@@ -79,6 +79,7 @@ files:
79
79
  - lib/protocol/rack/adapter/generic.rb
80
80
  - lib/protocol/rack/adapter/rack2.rb
81
81
  - lib/protocol/rack/adapter/rack3.rb
82
+ - lib/protocol/rack/adapter/rack31.rb
82
83
  - lib/protocol/rack/body.rb
83
84
  - lib/protocol/rack/body/enumerable.rb
84
85
  - lib/protocol/rack/body/input_wrapper.rb
@@ -112,7 +113,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
112
113
  - !ruby/object:Gem::Version
113
114
  version: '0'
114
115
  requirements: []
115
- rubygems_version: 3.5.11
116
+ rubygems_version: 3.5.22
116
117
  signing_key:
117
118
  specification_version: 4
118
119
  summary: An implementation of the Rack protocol/specification.
metadata.gz.sig CHANGED
Binary file