protocol-http 0.14.2 → 0.14.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/protocol/http/version.rb +1 -1
- metadata +2 -3
- data/lib/protocol/http/body/cacheable.rb +0 -53
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 86bcb17655f18236f837f878f14ac61127c7438a55c74d5a59faa9328d91de39
|
4
|
+
data.tar.gz: 142aeadbe21f997d06dbcbb713dc05fa64bb08edf3243a3da286e5a4d25c186a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e6a7e0a1440e402f4283af52d1df3c451e0a8e9b38ed85f317bb7f419e6590d4d05f5877c540f38629e7dce53506d8017c59cd6fec59dfd48ae90741dd72aefa
|
7
|
+
data.tar.gz: a7f7e12ba0220591f688582334fd03dac02416611112915af639ab983c289aef2c5100841c502c4eb1a783330e0cc98adef0f524c88bcc03b810ae679a9c8d68
|
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.14.
|
4
|
+
version: 0.14.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
@@ -83,7 +83,6 @@ files:
|
|
83
83
|
- lib/protocol/http.rb
|
84
84
|
- lib/protocol/http/accept_encoding.rb
|
85
85
|
- lib/protocol/http/body/buffered.rb
|
86
|
-
- lib/protocol/http/body/cacheable.rb
|
87
86
|
- lib/protocol/http/body/deflate.rb
|
88
87
|
- lib/protocol/http/body/file.rb
|
89
88
|
- lib/protocol/http/body/inflate.rb
|
@@ -132,7 +131,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
132
131
|
- !ruby/object:Gem::Version
|
133
132
|
version: '0'
|
134
133
|
requirements: []
|
135
|
-
rubygems_version: 3.
|
134
|
+
rubygems_version: 3.0.6
|
136
135
|
signing_key:
|
137
136
|
specification_version: 4
|
138
137
|
summary: Provides abstractions to handle HTTP protocols.
|
@@ -1,53 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
#
|
3
|
-
# Copyright, 2020, by Samuel G. D. Williams. <http://www.codeotaku.com>
|
4
|
-
#
|
5
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
-
# of this software and associated documentation files (the "Software"), to deal
|
7
|
-
# in the Software without restriction, including without limitation the rights
|
8
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
-
# copies of the Software, and to permit persons to whom the Software is
|
10
|
-
# furnished to do so, subject to the following conditions:
|
11
|
-
#
|
12
|
-
# The above copyright notice and this permission notice shall be included in
|
13
|
-
# all copies or substantial portions of the Software.
|
14
|
-
#
|
15
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
-
# THE SOFTWARE.
|
22
|
-
|
23
|
-
require_relative 'rewindable'
|
24
|
-
require_relative 'streamable'
|
25
|
-
|
26
|
-
module Protocol
|
27
|
-
module HTTP
|
28
|
-
module Body
|
29
|
-
class Cacheable < Rewindable
|
30
|
-
def self.wrap(message, &block)
|
31
|
-
if body = message.body
|
32
|
-
# Create a rewindable body wrapping the message body:
|
33
|
-
rewindable = 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
|
-
Streamable.wrap(message) do |error|
|
40
|
-
unless error
|
41
|
-
yield message, rewindable.buffered
|
42
|
-
end
|
43
|
-
end
|
44
|
-
else
|
45
|
-
yield message, nil
|
46
|
-
end
|
47
|
-
|
48
|
-
return message
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
53
|
-
end
|