async-http-cache 0.1.3 → 0.1.4

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: 835bedef1b242fc89e416ac99d2a410896262c18eaa985e6eea715b01e9a9f37
4
- data.tar.gz: 36a5a86d671ab98e8531926a2d3ea56340820c729426d6d8dd55c6145f6b0158
3
+ metadata.gz: b7a0767f1441dbbd35aaeb13647f55630a876b45a4d88d1a298df0ee4f5fafb6
4
+ data.tar.gz: dcaba9874a9fc9d784b86969a1f844e67acb11677c19afa70b8dce9d2481169a
5
5
  SHA512:
6
- metadata.gz: 3b006e0e15afc6c7f506d7f6ff1fc97f4036690786ce72741f28ee1570e4eed238afc719ac62a8880b1ce2d9acee6542e9129b2cb21cfc30a38ae005d78f62f1
7
- data.tar.gz: 02ae7fb372c4952541c061c91476352684fb2be0f9cd1c4d56f9d9a7b4dfa459d371a03b2b44cdbc12bc46b1c8d808ae5c13a62072b60c80f911048859735fe4
6
+ metadata.gz: 9628112d985f1a9fafbcf55d988f8f3aa43185372194685df8b0746366dba14be491a5341773fd94710f349b3f391074d5a6c4ef0a027c805a217b800bc6a8ba
7
+ data.tar.gz: f5a667a2361eec9e8773599eb743390bca93da29e73109aebf843e6470b9205debb72424df9b00424b4f89b2c57bbbca38820c354a953c028f35414a73edb483
@@ -29,18 +29,23 @@ module Async
29
29
  module Body
30
30
  def self.wrap(message, &block)
31
31
  if body = message.body
32
- # Create a rewindable body wrapping the message body:
33
- rewindable = ::Protocol::HTTP::Body::Rewindable.new(body)
34
-
35
- # Set the message body to the rewindable body:
36
- message.body = rewindable
37
-
38
- # Wrap the message with the callback:
39
- ::Protocol::HTTP::Body::Streamable.wrap(message) do |error|
40
- if error
41
- Async.logger.error(self) {error}
42
- else
43
- yield message, rewindable.buffered
32
+ if body.empty?
33
+ # A body that is empty? at the outset, is immutable. This generally only applies to HEAD requests.
34
+ yield message, body
35
+ else
36
+ # Create a rewindable body wrapping the message body:
37
+ rewindable = ::Protocol::HTTP::Body::Rewindable.new(body)
38
+
39
+ # Set the message body to the rewindable body:
40
+ message.body = rewindable
41
+
42
+ # Wrap the message with the callback:
43
+ ::Protocol::HTTP::Body::Streamable.wrap(message) do |error|
44
+ if error
45
+ Async.logger.error(self) {error}
46
+ else
47
+ yield message, rewindable.buffered
48
+ end
44
49
  end
45
50
  end
46
51
  else
@@ -23,7 +23,7 @@
23
23
  module Async
24
24
  module HTTP
25
25
  module Cache
26
- VERSION = "0.1.3"
26
+ VERSION = "0.1.4"
27
27
  end
28
28
  end
29
29
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: async-http-cache
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-03-21 00:00:00.000000000 Z
11
+ date: 2020-03-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: async-http