protocol-http 0.49.0 → 0.50.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: f32acdbabe7e68c2dac1c6ceb3f697936a6000b23f884e91268578594d710af9
4
- data.tar.gz: 711a823f045bd93c1de05331937c05847ab37de5765f309689d9fcfa9c4d13d2
3
+ metadata.gz: 38991af57b4ea197e5eebf1650490f4d52d52f6bc8e17d3a101d97b0a9fd5bda
4
+ data.tar.gz: d00e1f54aa78732dbd390cb3b6b59fe4dee4604acfc9fdbb2c7ec93aea56327d
5
5
  SHA512:
6
- metadata.gz: a6f90cc72dc0262c7555cdc9cb06b04869ec2d1c161a4f394d339e509b2c940f2b0b28150054c7509a3b54b829442d44838d3ff1bab2a6f849d01c269d462b08
7
- data.tar.gz: 75cc72a22d04106c14e74df1aab2cb48343eb5e9b7032fd13b0671bd15a02f8b9aeb7d9963141d0c078ad070c49923c485e4537363fa31b2d646d707afceddc3
6
+ metadata.gz: 4a6d9ce75c94602ee50ae9666a9e20ce55385681651ae09d50b0b7485b67d682e91916939595ec78d2920d1bd51713225937f03879d7cdac3ebfeed47df6d140
7
+ data.tar.gz: c921f21ca8c833280e9eb70d6ef7c6ffe3b61b9e772205e06b5e8ecb3bf60722cda228887924826a4b045fc6a54bbf7bf1c27d96066fe8316eba4f4c01eb59d5
checksums.yaml.gz.sig CHANGED
Binary file
@@ -1,15 +1,16 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2019-2024, by Samuel Williams.
4
+ # Copyright, 2019-2025, by Samuel Williams.
5
5
  # Copyright, 2020, by Bryan Powell.
6
+ # Copyright, 2025, by William T. Nelson.
6
7
 
7
8
  require_relative "readable"
8
9
 
9
10
  module Protocol
10
11
  module HTTP
11
12
  module Body
12
- # A body which buffers all it's contents.
13
+ # A body which buffers all its contents.
13
14
  class Buffered < Readable
14
15
  # Tries to wrap an object in a {Buffered} instance.
15
16
  #
@@ -2,6 +2,7 @@
2
2
 
3
3
  # Released under the MIT License.
4
4
  # Copyright, 2020-2025, by Samuel Williams.
5
+ # Copyright, 2025, by William T. Nelson.
5
6
 
6
7
  require_relative "readable"
7
8
 
@@ -10,7 +11,7 @@ module Protocol
10
11
  module Body
11
12
  # Represents a body suitable for HEAD requests, in other words, a body that is empty and has a known length.
12
13
  class Head < Readable
13
- # Create a head body for the given body, capturing it's length and then closing it.
14
+ # Create a head body for the given body, capturing its length and then closing it.
14
15
  def self.for(body)
15
16
  head = self.new(body.length)
16
17
 
@@ -1,7 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2019-2024, by Samuel Williams.
4
+ # Copyright, 2019-2025, by Samuel Williams.
5
+ # Copyright, 2025, by William T. Nelson.
5
6
 
6
7
  require_relative "wrapper"
7
8
  require_relative "buffered"
@@ -9,7 +10,7 @@ require_relative "buffered"
9
10
  module Protocol
10
11
  module HTTP
11
12
  module Body
12
- # A body which buffers all it's contents as it is read.
13
+ # A body which buffers all its contents as it is read.
13
14
  #
14
15
  # As the body is buffered in memory, you may want to ensure your server has sufficient (virtual) memory available to buffer the entire body.
15
16
  class Rewindable < Wrapper
@@ -263,7 +263,12 @@ module Protocol
263
263
  buffer = @buffer
264
264
  @buffer = nil
265
265
 
266
- return @buffer
266
+ # Return nil for empty buffers, otherwise return the content:
267
+ if buffer && !buffer.empty?
268
+ return buffer
269
+ else
270
+ return nil
271
+ end
267
272
  end
268
273
  end
269
274
 
@@ -46,14 +46,16 @@ module Protocol
46
46
  # https://lists.w3.org/Archives/Public/ietf-http-wg/2014JanMar/1179.html
47
47
  return response if response.partial?
48
48
 
49
+ body = response.body
50
+
51
+ # If there is no response body, there is nothing to encode:
52
+ return response if body.nil? or body.empty?
53
+
49
54
  # Ensure that caches are aware we are varying the response based on the accept-encoding request header:
50
55
  response.headers.add("vary", "accept-encoding")
51
56
 
52
- # TODO use http-accept and sort by priority
53
- if !response.body.empty? and accept_encoding = request.headers["accept-encoding"]
57
+ if accept_encoding = request.headers["accept-encoding"]
54
58
  if content_type = response.headers["content-type"] and @content_types =~ content_type
55
- body = response.body
56
-
57
59
  accept_encoding.each do |name|
58
60
  if wrapper = @wrappers[name]
59
61
  response.headers["content-encoding"] = name
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2018-2024, by Samuel Williams.
4
+ # Copyright, 2018-2025, by Samuel Williams.
5
5
 
6
6
  module Protocol
7
7
  module HTTP
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2019-2024, by Samuel Williams.
4
+ # Copyright, 2019-2025, by Samuel Williams.
5
5
 
6
6
  require_relative "body/buffered"
7
7
  require_relative "body/reader"
@@ -1,10 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2018-2024, by Samuel Williams.
4
+ # Copyright, 2018-2025, by Samuel Williams.
5
5
 
6
6
  module Protocol
7
7
  module HTTP
8
- VERSION = "0.49.0"
8
+ VERSION = "0.50.1"
9
9
  end
10
10
  end
data/license.md CHANGED
@@ -11,6 +11,7 @@ Copyright, 2023, by Genki Takiuchi.
11
11
  Copyright, 2023-2024, by Thomas Morgan.
12
12
  Copyright, 2023, by Marcelo Junior.
13
13
  Copyright, 2024, by Earlopain.
14
+ Copyright, 2025, by William T. Nelson.
14
15
 
15
16
  Permission is hereby granted, free of charge, to any person obtaining a copy
16
17
  of this software and associated documentation files (the "Software"), to deal
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: protocol-http
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.49.0
4
+ version: 0.50.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
@@ -14,6 +14,7 @@ authors:
14
14
  - Genki Takiuchi
15
15
  - Marcelo Junior
16
16
  - Olle Jonsson
17
+ - William T. Nelson
17
18
  - Yuta Iwama
18
19
  bindir: bin
19
20
  cert_chain:
@@ -46,7 +47,7 @@ cert_chain:
46
47
  Q2K9NVun/S785AP05vKkXZEFYxqG6EW012U4oLcFl5MySFajYXRYbuUpH6AY+HP8
47
48
  voD0MPg1DssDLKwXyt1eKD/+Fq0bFWhwVM/1XiAXL7lyYUyOq24KHgQ2Csg=
48
49
  -----END CERTIFICATE-----
49
- date: 2025-01-29 00:00:00.000000000 Z
50
+ date: 2025-04-29 00:00:00.000000000 Z
50
51
  dependencies: []
51
52
  executables: []
52
53
  extensions: []
@@ -114,7 +115,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
114
115
  requirements:
115
116
  - - ">="
116
117
  - !ruby/object:Gem::Version
117
- version: '3.1'
118
+ version: '3.2'
118
119
  required_rubygems_version: !ruby/object:Gem::Requirement
119
120
  requirements:
120
121
  - - ">="
metadata.gz.sig CHANGED
Binary file