protocol-rack 0.11.0 → 0.11.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 30e960af55f8f9e0c401657bd0e245c448f46315ef97cdd3d25aeeb8f41ef99c
4
- data.tar.gz: 1d4f9d858799b04e909776e120f4f376aa54ad4a956bd077e109edc704f3a2ff
3
+ metadata.gz: ab3e913313df25d3592761df42df6f1926fd901b3363ad7347db464599d1964e
4
+ data.tar.gz: a4610f7973026ecce482e3c97ee1622466a5f65f969f4b6378108fd6c98a4f33
5
5
  SHA512:
6
- metadata.gz: c71e270584bfe6e4da54ce6b175664880180ddf5ba2cb5fec1fb4ef3b67aa93af2ef78ecc0d74869f477caed03e5caf4e072758fef7f831fcb8e249ccea60e5f
7
- data.tar.gz: 9af0d3f0bbd79784f9f8464a1cffdfc76f55e9d49e386a9c770b43af85da2a2d1a0dfd0bbb624d2465d99f79ae1ef2663848d38195a2816aa57ebb9a9588a926
6
+ metadata.gz: 0a08d73c2dd4e1621693404a3b74c504981b42cd81a6e1bbaae0f44b1ab1bf7b47515f509d1a700afa4bdaa31edcb9b238007e24e7b5c398ea12cddf01430f79
7
+ data.tar.gz: 6e948ed04abe9047f51623ffd7a93846050088328696e75fefc2c3f358b5cf4f5333a410963af2f2a8a9e17948baecdd07d7c3c6ea2245557c39f60d35bb3ce5
checksums.yaml.gz.sig CHANGED
Binary file
@@ -34,9 +34,17 @@ module Protocol
34
34
  Console
35
35
  end
36
36
 
37
- # Unwrap raw HTTP headers into the CGI-style expected by Rack middleware.
37
+ # Unwrap HTTP headers into the CGI-style expected by Rack middleware, and add them to the rack `env`.
38
38
  #
39
- # Rack separates multiple headers with the same key, into a single field with multiple lines.
39
+ # e.g. `accept-encoding` becomes `HTTP_ACCEPT_ENCODING`.
40
+ #
41
+ # Headers keys with underscores will generate the same CGI-style header key as headers with dashes.
42
+ #
43
+ # e.g `accept_encoding` becomes `HTTP_ACCEPT_ENCODING` too.
44
+ #
45
+ # You should not implicitly trust the `HTTP_` headers for security purposes, as they are generated by the client.
46
+ #
47
+ # Multiple headers are combined with a comma, with one exception: `HTTP_COOKIE` headers are combined with a semicolon.
40
48
  #
41
49
  # @parameter headers [Protocol::HTTP::Headers] The raw HTTP request headers.
42
50
  # @parameter env [Hash] The rack request `env`.
@@ -66,6 +74,11 @@ module Protocol
66
74
  # @parameter request [Protocol::HTTP::Request] The incoming request.
67
75
  # @parameter env [Hash] The rack `env`.
68
76
  def unwrap_request(request, env)
77
+ # The request protocol, either from the upgrade header or the HTTP/2 pseudo header of the same name.
78
+ if protocol = request.protocol
79
+ env[RACK_PROTOCOL] = protocol
80
+ end
81
+
69
82
  if content_type = request.headers.delete("content-type")
70
83
  env[CGI::CONTENT_TYPE] = content_type
71
84
  end
@@ -1,7 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2022-2024, by Samuel Williams.
4
+ # Copyright, 2022-2025, by Samuel Williams.
5
+ # Copyright, 2025, by Francisco Mejia.
5
6
 
6
7
  require "console"
7
8
 
@@ -37,9 +38,6 @@ module Protocol
37
38
  RACK_ERRORS => $stderr,
38
39
  RACK_LOGGER => self.logger,
39
40
 
40
- # The request protocol, either from the upgrade header or the HTTP/2 pseudo header of the same name.
41
- RACK_PROTOCOL => request.protocol,
42
-
43
41
  # The HTTP request method, such as “GET” or “POST”. This cannot ever be an empty string, and so is always required.
44
42
  CGI::REQUEST_METHOD => request.method,
45
43
 
@@ -62,8 +60,12 @@ module Protocol
62
60
 
63
61
  # I'm not sure what sane defaults should be here:
64
62
  CGI::SERVER_NAME => server_name,
65
- CGI::SERVER_PORT => server_port,
66
63
  }
64
+
65
+ # SERVER_PORT is optional but must not be set if it is not present.
66
+ if server_port
67
+ env[CGI::SERVER_PORT] = server_port
68
+ end
67
69
 
68
70
  self.unwrap_request(request, env)
69
71
 
@@ -1,7 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2022-2024, by Samuel Williams.
4
+ # Copyright, 2022-2025, by Samuel Williams.
5
+ # Copyright, 2025, by Francisco Mejia.
5
6
 
6
7
  require "console"
7
8
 
@@ -30,9 +31,6 @@ module Protocol
30
31
  RACK_ERRORS => $stderr,
31
32
  RACK_LOGGER => self.logger,
32
33
 
33
- # The request protocol, either from the upgrade header or the HTTP/2 pseudo header of the same name.
34
- RACK_PROTOCOL => request.protocol,
35
-
36
34
  # The response finished callbacks:
37
35
  RACK_RESPONSE_FINISHED => [],
38
36
 
@@ -58,8 +56,12 @@ module Protocol
58
56
 
59
57
  # I'm not sure what sane defaults should be here:
60
58
  CGI::SERVER_NAME => server_name,
61
- CGI::SERVER_PORT => server_port,
62
59
  }
60
+
61
+ # SERVER_PORT is optional but must not be set if it is not present.
62
+ if server_port
63
+ env[CGI::SERVER_PORT] = server_port
64
+ end
63
65
 
64
66
  self.unwrap_request(request, env)
65
67
 
@@ -1,7 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2022-2024, by Samuel Williams.
4
+ # Copyright, 2024-2025, by Samuel Williams.
5
+ # Copyright, 2025, by Francisco Mejia.
5
6
 
6
7
  require "console"
7
8
 
@@ -21,9 +22,6 @@ module Protocol
21
22
  RACK_ERRORS => $stderr,
22
23
  RACK_LOGGER => self.logger,
23
24
 
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
25
  # The response finished callbacks:
28
26
  RACK_RESPONSE_FINISHED => [],
29
27
 
@@ -49,8 +47,17 @@ module Protocol
49
47
 
50
48
  # I'm not sure what sane defaults should be here:
51
49
  CGI::SERVER_NAME => server_name,
52
- CGI::SERVER_PORT => server_port,
53
50
  }
51
+
52
+ # SERVER_PORT is optional but must not be set if it is not present.
53
+ if server_port
54
+ env[CGI::SERVER_PORT] = server_port
55
+ end
56
+
57
+ # The request protocol, either from the upgrade header or the HTTP/2 pseudo header of the same name.
58
+ if protocol = request.protocol
59
+ env[RACK_PROTOCOL] = protocol
60
+ end
54
61
 
55
62
  if body = request.body
56
63
  if body.empty?
@@ -5,6 +5,6 @@
5
5
 
6
6
  module Protocol
7
7
  module Rack
8
- VERSION = "0.11.0"
8
+ VERSION = "0.11.2"
9
9
  end
10
10
  end
data/license.md CHANGED
@@ -1,7 +1,8 @@
1
1
  # MIT License
2
2
 
3
- Copyright, 2022-2024, by Samuel Williams.
3
+ Copyright, 2022-2025, by Samuel Williams.
4
4
  Copyright, 2023, by Genki Takiuchi.
5
+ Copyright, 2025, by Francisco Mejia.
5
6
 
6
7
  Permission is hereby granted, free of charge, to any person obtaining a copy
7
8
  of this software and associated documentation files (the "Software"), to deal
data/readme.md CHANGED
@@ -11,6 +11,8 @@ Provides abstractions for working with the Rack specification on top of [`Protoc
11
11
 
12
12
  ## Usage
13
13
 
14
+ Please see the [project documentation](https://socketry.github.io/protocol-rack/) for more details.
15
+
14
16
  ### Application Adapter
15
17
 
16
18
  Given a rack application, you can adapt it for use on `async-http`:
@@ -61,6 +63,14 @@ run proc{|env|
61
63
  }
62
64
  ```
63
65
 
66
+ ## Releases
67
+
68
+ Please see the [project releases](https://socketry.github.io/protocol-rack/releases/index) for all releases.
69
+
70
+ ### v0.11.2
71
+
72
+ - Stop setting `env["SERVER_PORT"]` to `nil` if not present.
73
+
64
74
  ## Contributing
65
75
 
66
76
  We welcome contributions to this project.
data/releases.md ADDED
@@ -0,0 +1,5 @@
1
+ # Releases
2
+
3
+ ## v0.11.2
4
+
5
+ - Stop setting `env["SERVER_PORT"]` to `nil` if not present.
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,12 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: protocol-rack
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.0
4
+ version: 0.11.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
8
+ - Francisco Mejia
8
9
  - Genki Takiuchi
9
- autorequire:
10
10
  bindir: bin
11
11
  cert_chain:
12
12
  - |
@@ -38,7 +38,7 @@ cert_chain:
38
38
  Q2K9NVun/S785AP05vKkXZEFYxqG6EW012U4oLcFl5MySFajYXRYbuUpH6AY+HP8
39
39
  voD0MPg1DssDLKwXyt1eKD/+Fq0bFWhwVM/1XiAXL7lyYUyOq24KHgQ2Csg=
40
40
  -----END CERTIFICATE-----
41
- date: 2024-11-09 00:00:00.000000000 Z
41
+ date: 2025-02-28 00:00:00.000000000 Z
42
42
  dependencies:
43
43
  - !ruby/object:Gem::Dependency
44
44
  name: protocol-http
@@ -68,8 +68,6 @@ dependencies:
68
68
  - - ">="
69
69
  - !ruby/object:Gem::Version
70
70
  version: '1.0'
71
- description:
72
- email:
73
71
  executables: []
74
72
  extensions: []
75
73
  extra_rdoc_files: []
@@ -92,13 +90,13 @@ files:
92
90
  - lib/protocol/rack/version.rb
93
91
  - license.md
94
92
  - readme.md
93
+ - releases.md
95
94
  homepage: https://github.com/socketry/protocol-rack
96
95
  licenses:
97
96
  - MIT
98
97
  metadata:
99
98
  documentation_uri: https://socketry.github.io/protocol-rack/
100
99
  source_code_uri: https://github.com/socketry/protocol-rack.git
101
- post_install_message:
102
100
  rdoc_options: []
103
101
  require_paths:
104
102
  - lib
@@ -113,8 +111,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
113
111
  - !ruby/object:Gem::Version
114
112
  version: '0'
115
113
  requirements: []
116
- rubygems_version: 3.5.22
117
- signing_key:
114
+ rubygems_version: 3.6.2
118
115
  specification_version: 4
119
116
  summary: An implementation of the Rack protocol/specification.
120
117
  test_files: []
metadata.gz.sig CHANGED
Binary file