protocol-rack 0.2.0 → 0.2.1

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: 0f7becb7e22562224a7b79eeaa6776b2132f5b5261a51aba1ac9e75e56dcc038
4
- data.tar.gz: 333f072f05e98e6e52662294e41387cfdf1e59b9217990d42bb6694c241ed427
3
+ metadata.gz: c5cd531684b517c9695d07dfaa9f4301e3e77fcf52389b471f1f89aaa2227227
4
+ data.tar.gz: aa8f85b68326ca7f646d4c9e15bbdf0f6165bb969fad7345e933a8232e5263fb
5
5
  SHA512:
6
- metadata.gz: 881510d4b665e3d9b6ef041eedeb27732601294a8d0e45c43900a8ef8cc11556fcff164c900aa0444272ba6e81cca1716a619b1520996ee411b842d166c5065f
7
- data.tar.gz: e64f1f3c7ce42aa4a829bce8e1d9c4c270bb4fe5ecc99f6d01ae69222d3a18440f1e3ce83b2b50e842e7fd49b9c28d74383e6b9df8f9d6aa01e6afe564fe6019
6
+ metadata.gz: 27afe33758a33782b67f9f569e65a828304296c63f21f892b9f27413c71c7021fceb2e57e02c21ce3f7e9f9abcac444626d64aaf73743d7be3b4119cea4c7893
7
+ data.tar.gz: 72089305ac61d33065352316385def71c940d1578c7739df08a4ea27704b494576d8830703b462c078ebb0e5a1f61a39be381e2a34496868c1057d8281f511f9
checksums.yaml.gz.sig CHANGED
Binary file
@@ -33,6 +33,7 @@ module Protocol
33
33
  RACK_MULTITHREAD => false,
34
34
  RACK_MULTIPROCESS => true,
35
35
  RACK_RUN_ONCE => false,
36
+ RACK_IS_HIJACK => true,
36
37
 
37
38
  PROTOCOL_HTTP_REQUEST => request,
38
39
 
@@ -73,6 +74,29 @@ module Protocol
73
74
  return env
74
75
  end
75
76
 
77
+ # Build a rack `env` from the incoming request and apply it to the rack middleware.
78
+ #
79
+ # @parameter request [Protocol::HTTP::Request] The incoming request.
80
+ def call(request)
81
+ env = self.make_environment(request)
82
+
83
+ status, headers, body = @app.call(env)
84
+
85
+ headers, meta = self.wrap_headers(headers)
86
+
87
+ if hijack_body = meta[RACK_HIJACK]
88
+ body = hijack_body
89
+ end
90
+
91
+ return Response.wrap(env, status, headers, meta, body, request)
92
+ rescue => exception
93
+ Console.logger.error(self) {exception}
94
+
95
+ body&.close if body.respond_to?(:close)
96
+
97
+ return failure_response(exception)
98
+ end
99
+
76
100
  # Process the rack response headers into into a {Protocol::HTTP::Headers} instance, along with any extra `rack.` metadata.
77
101
  # @returns [Tuple(Protocol::HTTP::Headers, Hash)]
78
102
  def wrap_headers(fields)
@@ -46,6 +46,10 @@ module Protocol
46
46
  Console.logger.warn(self, "Ignoring protocol-level headers: #{ignored.inspect}")
47
47
  end
48
48
 
49
+ if hijack_body = meta['rack.hijack']
50
+ body = hijack_body
51
+ end
52
+
49
53
  body = Body.wrap(env, status, headers, body, request&.body)
50
54
 
51
55
  if request&.head?
@@ -5,6 +5,6 @@
5
5
 
6
6
  module Protocol
7
7
  module Rack
8
- VERSION = "0.2.0"
8
+ VERSION = "0.2.1"
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.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
metadata.gz.sig CHANGED
Binary file