protocol-rack 0.11.2 → 0.12.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: ab3e913313df25d3592761df42df6f1926fd901b3363ad7347db464599d1964e
4
- data.tar.gz: a4610f7973026ecce482e3c97ee1622466a5f65f969f4b6378108fd6c98a4f33
3
+ metadata.gz: 253756f1f94918a43327d8f107e1a614414b6c7eee787d876135454697f3f108
4
+ data.tar.gz: bfe5453d726e362ac82c06a723d941991da8d6663749a924f8a81c919f6ca798
5
5
  SHA512:
6
- metadata.gz: 0a08d73c2dd4e1621693404a3b74c504981b42cd81a6e1bbaae0f44b1ab1bf7b47515f509d1a700afa4bdaa31edcb9b238007e24e7b5c398ea12cddf01430f79
7
- data.tar.gz: 6e948ed04abe9047f51623ffd7a93846050088328696e75fefc2c3f358b5cf4f5333a410963af2f2a8a9e17948baecdd07d7c3c6ea2245557c39f60d35bb3ce5
6
+ metadata.gz: 990b93f88c80068cdcf57c36ed0ff8bfeeb0e79044dab843668bf93db4eff71ce4117da113b0cac812625d178603c815ca121d8b233945772a0af289690e053c
7
+ data.tar.gz: f84b64ec28519ab67db3770d6e2dce6ee86387cbc730a283fe7fa83811da2bb0d6ff831fd05f41ca5c2e8f15b33c92e7864e6ab17ad8335ba965ff3be24505a2
checksums.yaml.gz.sig CHANGED
Binary file
@@ -5,6 +5,7 @@
5
5
 
6
6
  require_relative "body/streaming"
7
7
  require_relative "body/enumerable"
8
+ require_relative "constants"
8
9
  require "protocol/http/body/completable"
9
10
 
10
11
  module Protocol
@@ -12,6 +13,10 @@ module Protocol
12
13
  module Body
13
14
  CONTENT_LENGTH = "content-length"
14
15
 
16
+ def self.no_content?(status)
17
+ status == 204 or status == 205 or status == 304
18
+ end
19
+
15
20
  def self.wrap(env, status, headers, body, input = nil)
16
21
  # In no circumstance do we want this header propagating out:
17
22
  if length = headers.delete(CONTENT_LENGTH)
@@ -33,12 +38,29 @@ module Protocol
33
38
  end
34
39
  elsif body.respond_to?(:each)
35
40
  body = Body::Enumerable.wrap(body, length)
36
- else
41
+ elsif body
37
42
  body = Body::Streaming.new(body, input)
43
+ else
44
+ Console.warn(self, "Rack response body was nil, ignoring!")
38
45
  end
39
46
 
40
- if response_finished = env[RACK_RESPONSE_FINISHED] and response_finished.any?
41
- body = ::Protocol::HTTP::Body::Completable.new(body, completion_callback(response_finished, env, status, headers))
47
+ if body and no_content?(status)
48
+ unless body.empty?
49
+ Console.warn(self, "Rack response body was not empty, and status code indicates no content!", body: body, status: status)
50
+ end
51
+
52
+ body.close
53
+ body = nil
54
+ end
55
+
56
+ response_finished = env[RACK_RESPONSE_FINISHED]
57
+
58
+ if response_finished&.any?
59
+ if body
60
+ body = ::Protocol::HTTP::Body::Completable.new(body, completion_callback(response_finished, env, status, headers))
61
+ else
62
+ completion_callback(response_finished, env, status, headers).call(nil)
63
+ end
42
64
  end
43
65
 
44
66
  return body
@@ -1,10 +1,10 @@
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
5
 
6
6
  module Protocol
7
7
  module Rack
8
- VERSION = "0.11.2"
8
+ VERSION = "0.12.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.11.2
4
+ version: 0.12.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: 2025-02-28 00:00:00.000000000 Z
41
+ date: 2025-04-29 00:00:00.000000000 Z
42
42
  dependencies:
43
43
  - !ruby/object:Gem::Dependency
44
44
  name: protocol-http
@@ -104,7 +104,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
104
104
  requirements:
105
105
  - - ">="
106
106
  - !ruby/object:Gem::Version
107
- version: '3.1'
107
+ version: '3.2'
108
108
  required_rubygems_version: !ruby/object:Gem::Requirement
109
109
  requirements:
110
110
  - - ">="
metadata.gz.sig CHANGED
Binary file