protocol-rack 0.16.0 → 0.17.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6d1c1680392355d0bf9a1aa9b6b76f2267f9d1f612e4ae194fe5933a95fb4486
4
- data.tar.gz: 8401fd53bbe49d9547f187f06a23ba334eae3814570f041b333c8c3c30aa317b
3
+ metadata.gz: fbf78ac425bc2df269ede6fc0f60d0d674f11d0e6d3fe5dc07f8c766d534bedb
4
+ data.tar.gz: e348d48975f98d10401e7198a7a0317483c5b2b42641a78e46e771623c804a8b
5
5
  SHA512:
6
- metadata.gz: 7e3194c1c3ae772b58d15126fa918150b3e04791bfcf24a25ef6314d573392c3b8fdfca9efd7bab47a17ab1fd99d2b9a32323699014c900840024368fdfcabcd
7
- data.tar.gz: ebbcaf7b1368633de01b261c1ad8c6f741f798b74d28070e33d4023887b306acb9a86df5b243f2b3bef737a148663c45a94bd981e6cf3d9757ce82048c4be830
6
+ metadata.gz: f3d717f59f06f4348fc44eba9b650cd8e99ca29ce731f5b2265e835fb95e71e1abaee47a65689903e6de48c23d1bace99c145405ad5a70de7054e2399ed202ce
7
+ data.tar.gz: b3fa66486f434892b3d076457d3a762fbbe1d76923c46c91e18466b00415767bded9625d13dd52cb88899b0d978915c9e3fb5c5926168ace1b1d4074d570e24e
checksums.yaml.gz.sig CHANGED
Binary file
@@ -116,6 +116,11 @@ module Protocol
116
116
 
117
117
  body&.close if body.respond_to?(:close)
118
118
 
119
+ # Rack 2 does not include `rack.response_finished` in the specification. However, if the application has set it, we will call the callbacks here as it would be extremely surprising to not do so.
120
+ env&.[](RACK_RESPONSE_FINISHED)&.each do |callback|
121
+ callback.call(env, status, headers, exception)
122
+ end
123
+
119
124
  return failure_response(exception)
120
125
  end
121
126
 
@@ -5,6 +5,6 @@
5
5
 
6
6
  module Protocol
7
7
  module Rack
8
- VERSION = "0.16.0"
8
+ VERSION = "0.17.0"
9
9
  end
10
10
  end
data/readme.md CHANGED
@@ -18,26 +18,26 @@ Please see the [project documentation](https://socketry.github.io/protocol-rack/
18
18
  Given a rack application, you can adapt it for use on `async-http`:
19
19
 
20
20
  ``` ruby
21
- require 'async'
22
- require 'async/http/server'
23
- require 'async/http/client'
24
- require 'async/http/endpoint'
25
- require 'protocol/rack/adapter'
21
+ require "async"
22
+ require "async/http/server"
23
+ require "async/http/client"
24
+ require "async/http/endpoint"
25
+ require "protocol/rack/adapter"
26
26
 
27
27
  app = proc{|env| [200, {}, ["Hello World"]]}
28
28
  middleware = Protocol::Rack::Adapter.new(app)
29
29
 
30
30
  Async do
31
- endpoint = Async::HTTP::Endpoint.parse("http://localhost:9292")
32
-
33
- server_task = Async(transient: true) do
34
- server = Async::HTTP::Server.new(middleware, endpoint)
35
- server.run
36
- end
37
-
38
- client = Async::HTTP::Client.new(endpoint)
39
- puts client.get("/").read
40
- # "Hello World"
31
+ endpoint = Async::HTTP::Endpoint.parse("http://localhost:9292")
32
+
33
+ server_task = Async(transient: true) do
34
+ server = Async::HTTP::Server.new(middleware, endpoint)
35
+ server.run
36
+ end
37
+
38
+ client = Async::HTTP::Client.new(endpoint)
39
+ puts client.get("/").read
40
+ # "Hello World"
41
41
  end
42
42
  ```
43
43
 
@@ -46,27 +46,31 @@ end
46
46
  While not tested, in theory any Rack compatible server can host `Protocol::HTTP` compatible middlewares.
47
47
 
48
48
  ``` ruby
49
- require 'protocol/http/middleware'
50
- require 'protocol/rack'
49
+ require "protocol/http/middleware"
50
+ require "protocol/rack"
51
51
 
52
52
  # Your native application:
53
53
  middleware = Protocol::HTTP::Middleware::HelloWorld
54
54
 
55
- run proc{|env|
56
- # Convert the rack request to a compatible rich request object:
57
- request = Protocol::Rack::Request[env]
58
-
59
- # Call your application
60
- response = middleware.call(request)
61
-
62
- Protocol::Rack::Adapter.make_response(env, response)
63
- }
55
+ run do |env|
56
+ # Convert the rack request to a compatible rich request object:
57
+ request = Protocol::Rack::Request[env]
58
+
59
+ # Call your application
60
+ response = middleware.call(request)
61
+
62
+ Protocol::Rack::Adapter.make_response(env, response)
63
+ end
64
64
  ```
65
65
 
66
66
  ## Releases
67
67
 
68
68
  Please see the [project releases](https://socketry.github.io/protocol-rack/releases/index) for all releases.
69
69
 
70
+ ### v0.17.0
71
+
72
+ - Support `rack.response_finished` in Rack 2 if it's present in the environment.
73
+
70
74
  ### v0.16.0
71
75
 
72
76
  - Hijacked IO is no longer duped, as it's not retained by the original connection, and `SSLSocket` does not support duping.
data/releases.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Releases
2
2
 
3
+ ## v0.17.0
4
+
5
+ - Support `rack.response_finished` in Rack 2 if it's present in the environment.
6
+
3
7
  ## v0.16.0
4
8
 
5
9
  - Hijacked IO is no longer duped, as it's not retained by the original connection, and `SSLSocket` does not support duping.
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.16.0
4
+ version: 0.17.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
@@ -125,7 +125,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
125
125
  - !ruby/object:Gem::Version
126
126
  version: '0'
127
127
  requirements: []
128
- rubygems_version: 3.6.7
128
+ rubygems_version: 3.6.9
129
129
  specification_version: 4
130
130
  summary: An implementation of the Rack protocol/specification.
131
131
  test_files: []
metadata.gz.sig CHANGED
Binary file