protocol-rack 0.5.0 → 0.6.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: e9ac7ef853c3b25a46b06d630fc29921d76e8ee0213554d94afa19efdb9ccd87
4
- data.tar.gz: ce65dd607e37ee33c6f20ecd4b0fa5976634be40869ac9d0add4e197d43d8cd7
3
+ metadata.gz: 63abbb92ce268dc594b9464a931bb846808788db40a11a5c5aae81b64552eb30
4
+ data.tar.gz: bd369d97c603d06cce3088f6d2f785c12fb20c52cc038d31d860d107cabd301c
5
5
  SHA512:
6
- metadata.gz: 7ea217d520678401acc7d89d5a592e958bc47bcffc07439c02f4f52e2df89c0cf0391e2f6fbb6c6a94be7e2f31a0b2757d2ccc389a7ae72311e3f7a30f388c47
7
- data.tar.gz: a9e4587094746830e41a449892bc19c9fb43c7d5625529f321f8e5e72e0422908703719b0bdd983f96ea18f1a13f6697dbd06e254aa62e554cabf3356d97ba61
6
+ metadata.gz: d7058394c8f576c1cbff70179dcde738d6c31036c01ef264178056281dac28195e2dc19a14c21242b22c00f8db695fd73a8836c0125e9e60c4f37010ed537c15
7
+ data.tar.gz: 8c73f392e0bb354693eb2a5063f5add1d5feccf13d5155991870b9d216f59dad31ae4831b5825cd0a47871799b4433eedc36e64b01d6656cefe157eb519882d4
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, 2022-2023, by Samuel Williams.
4
+ # Copyright, 2022-2024, by Samuel Williams.
5
5
 
6
6
  require 'console'
7
7
 
@@ -45,7 +45,11 @@ module Protocol
45
45
  http_key = "HTTP_#{key.upcase.tr('-', '_')}"
46
46
 
47
47
  if current_value = env[http_key]
48
- env[http_key] = "#{current_value};#{value}"
48
+ if http_key == CGI::HTTP_COOKIE
49
+ env[http_key] = "#{current_value};#{value}"
50
+ else
51
+ env[http_key] = "#{current_value},#{value}"
52
+ end
49
53
  else
50
54
  env[http_key] = value
51
55
  end
@@ -138,6 +142,20 @@ module Protocol
138
142
  def failure_response(exception)
139
143
  Protocol::HTTP::Response.for_exception(exception)
140
144
  end
145
+
146
+ def self.extract_protocol(env, response, headers)
147
+ if protocol = response.protocol
148
+ # This is the newer mechanism for protocol upgrade:
149
+ if env['rack.protocol']
150
+ headers['rack.protocol'] = protocol
151
+
152
+ # Older mechanism for protocol upgrade:
153
+ elsif env[CGI::HTTP_UPGRADE]
154
+ headers['upgrade'] = protocol
155
+ headers['connection'] = 'upgrade'
156
+ end
157
+ end
158
+ end
141
159
  end
142
160
  end
143
161
  end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2022-2023, by Samuel Williams.
4
+ # Copyright, 2022-2024, by Samuel Williams.
5
5
 
6
6
  require 'console'
7
7
 
@@ -11,7 +11,7 @@ require_relative '../rewindable'
11
11
  module Protocol
12
12
  module Rack
13
13
  module Adapter
14
- class Rack2 < Generic
14
+ class Rack2 < Generic
15
15
  RACK_VERSION = 'rack.version'
16
16
  RACK_MULTITHREAD = 'rack.multithread'
17
17
  RACK_MULTIPROCESS = 'rack.multiprocess'
@@ -121,9 +121,7 @@ module Protocol
121
121
  # These interfaces should be largely compatible:
122
122
  headers = response.headers.to_h
123
123
 
124
- if protocol = response.protocol
125
- headers['rack.protocol'] = protocol
126
- end
124
+ self.extract_protocol(env, response, headers)
127
125
 
128
126
  if body = response.body and body.stream?
129
127
  if env[RACK_IS_HIJACK]
@@ -1,7 +1,7 @@
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
6
  require 'console'
7
7
 
@@ -92,9 +92,8 @@ module Protocol
92
92
  def self.make_response(env, response)
93
93
  # These interfaces should be largely compatible:
94
94
  headers = response.headers.to_h
95
- if protocol = response.protocol
96
- headers['rack.protocol'] = protocol
97
- end
95
+
96
+ self.extract_protocol(env, response, headers)
98
97
 
99
98
  if body = response.body and body.stream?
100
99
  # Force streaming response:
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2022-2023, by Samuel Williams.
4
+ # Copyright, 2022-2024, by Samuel Williams.
5
5
 
6
6
  require 'rack'
7
7
 
@@ -1,7 +1,7 @@
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
6
  module Protocol
7
7
  module Rack
@@ -25,6 +25,8 @@ module Protocol
25
25
  CONTENT_TYPE = 'CONTENT_TYPE'
26
26
  CONTENT_LENGTH = 'CONTENT_LENGTH'
27
27
 
28
+ HTTP_COOKIE = 'HTTP_COOKIE'
29
+
28
30
  # Header constants:
29
31
  HTTP_X_FORWARDED_PROTO = 'HTTP_X_FORWARDED_PROTO'
30
32
  end
@@ -1,10 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2022-2023, by Samuel Williams.
4
+ # Copyright, 2022-2024, by Samuel Williams.
5
5
  # Copyright, 2023, by Genki Takiuchi.
6
6
 
7
- require 'async/io/buffer'
8
7
  require 'protocol/http/body/stream'
9
8
 
10
9
  module Protocol
@@ -1,7 +1,7 @@
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
6
  require_relative 'body'
7
7
  require_relative 'constants'
@@ -1,10 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2022-2023, by Samuel Williams.
4
+ # Copyright, 2022-2024, by Samuel Williams.
5
5
 
6
6
  module Protocol
7
7
  module Rack
8
- VERSION = "0.5.0"
8
+ VERSION = "0.6.0"
9
9
  end
10
10
  end
data/license.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # MIT License
2
2
 
3
- Copyright, 2022-2023, by Samuel Williams.
3
+ Copyright, 2022-2024, by Samuel Williams.
4
4
  Copyright, 2023, by Genki Takiuchi.
5
5
 
6
6
  Permission is hereby granted, free of charge, to any person obtaining a copy
data/readme.md CHANGED
@@ -77,7 +77,7 @@ This project uses the [Developer Certificate of Origin](https://developercertifi
77
77
 
78
78
  ### Contributor Covenant
79
79
 
80
- This project is governed by [Contributor Covenant](https://www.contributor-covenant.org/). All contributors and participants agree to abide by its terms.
80
+ This project is governed by the [Contributor Covenant](https://www.contributor-covenant.org/). All contributors and participants agree to abide by its terms.
81
81
 
82
82
  ## See Also
83
83
 
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.5.0
4
+ version: 0.6.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-04-03 00:00:00.000000000 Z
41
+ date: 2024-06-14 00:00:00.000000000 Z
42
42
  dependencies:
43
43
  - !ruby/object:Gem::Dependency
44
44
  name: protocol-http
@@ -94,7 +94,9 @@ files:
94
94
  homepage: https://github.com/socketry/protocol-rack
95
95
  licenses:
96
96
  - MIT
97
- metadata: {}
97
+ metadata:
98
+ documentation_uri: https://socketry.github.io/protocol-rack/
99
+ source_code_uri: https://github.com/socketry/protocol-rack.git
98
100
  post_install_message:
99
101
  rdoc_options: []
100
102
  require_paths:
@@ -103,14 +105,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
103
105
  requirements:
104
106
  - - ">="
105
107
  - !ruby/object:Gem::Version
106
- version: '3.0'
108
+ version: '3.1'
107
109
  required_rubygems_version: !ruby/object:Gem::Requirement
108
110
  requirements:
109
111
  - - ">="
110
112
  - !ruby/object:Gem::Version
111
113
  version: '0'
112
114
  requirements: []
113
- rubygems_version: 3.5.3
115
+ rubygems_version: 3.5.9
114
116
  signing_key:
115
117
  specification_version: 4
116
118
  summary: An implementation of the Rack protocol/specification.
metadata.gz.sig CHANGED
Binary file