http 4.0.4 → 4.0.5
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 +4 -4
- data/CHANGES.md +7 -0
- data/lib/http/request/body.rb +25 -1
- data/lib/http/version.rb +1 -1
- data/spec/lib/http/request/body_spec.rb +22 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 94fd7f54004fd45a400c1e9befb46ea80d4bcdebae70929330355a5ea9056cf2
|
4
|
+
data.tar.gz: 3bbd9c1f0a29267bff2b6682ddaeaa53832eb896ec471d6ab3db62d5cbd08be2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5863fb462013166b6f76ff40929768f5a87ca86c02bd23c882bf5db1aefa6bed5be2a21785a45edecf66f6a6ac3418d86042b5c24f998e1f01489a661a1d9cae
|
7
|
+
data.tar.gz: 04726c6858928f553380fbb221cc1164cc51917ae2122cd9b7424ef3f1ff072c7b32ae2231cb32569a4411487f6c805acee54ec09e309e6eba4675a783df8306
|
data/CHANGES.md
CHANGED
data/lib/http/request/body.rb
CHANGED
@@ -35,10 +35,12 @@ module HTTP
|
|
35
35
|
yield @source
|
36
36
|
elsif @source.respond_to?(:read)
|
37
37
|
IO.copy_stream(@source, ProcIO.new(block))
|
38
|
-
|
38
|
+
rewind(@source)
|
39
39
|
elsif @source.is_a?(Enumerable)
|
40
40
|
@source.each(&block)
|
41
41
|
end
|
42
|
+
|
43
|
+
self
|
42
44
|
end
|
43
45
|
|
44
46
|
# Request bodies are equivalent when they have the same source.
|
@@ -48,6 +50,28 @@ module HTTP
|
|
48
50
|
|
49
51
|
private
|
50
52
|
|
53
|
+
def rewind(io)
|
54
|
+
io.rewind if io.respond_to? :rewind
|
55
|
+
rescue Errno::ESPIPE, Errno::EPIPE
|
56
|
+
# Pipe IOs respond to `:rewind` but fail when you call it.
|
57
|
+
#
|
58
|
+
# Calling `IO#rewind` on a pipe, fails with *ESPIPE* on MRI,
|
59
|
+
# but *EPIPE* on jRuby.
|
60
|
+
#
|
61
|
+
# - **ESPIPE** -- "Illegal seek."
|
62
|
+
# Invalid seek operation (such as on a pipe).
|
63
|
+
#
|
64
|
+
# - **EPIPE** -- "Broken pipe."
|
65
|
+
# There is no process reading from the other end of a pipe. Every
|
66
|
+
# library function that returns this error code also generates
|
67
|
+
# a SIGPIPE signal; this signal terminates the program if not handled
|
68
|
+
# or blocked. Thus, your program will never actually see EPIPE unless
|
69
|
+
# it has handled or blocked SIGPIPE.
|
70
|
+
#
|
71
|
+
# See: https://www.gnu.org/software/libc/manual/html_node/Error-Codes.html
|
72
|
+
nil
|
73
|
+
end
|
74
|
+
|
51
75
|
def validate_source_type!
|
52
76
|
return if @source.is_a?(String)
|
53
77
|
return if @source.respond_to?(:read)
|
data/lib/http/version.rb
CHANGED
@@ -125,6 +125,28 @@ RSpec.describe HTTP::Request::Body do
|
|
125
125
|
end
|
126
126
|
end
|
127
127
|
|
128
|
+
context "when body is a pipe" do
|
129
|
+
let(:ios) { IO.pipe }
|
130
|
+
let(:body) { ios[0] }
|
131
|
+
|
132
|
+
around do |example|
|
133
|
+
writer = Thread.new(ios[1]) do |io|
|
134
|
+
io << "abcdef"
|
135
|
+
io.close
|
136
|
+
end
|
137
|
+
|
138
|
+
begin
|
139
|
+
example.run
|
140
|
+
ensure
|
141
|
+
writer.join
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
145
|
+
it "yields chunks of content" do
|
146
|
+
expect(chunks.inject("", :+)).to eq("abcdef")
|
147
|
+
end
|
148
|
+
end
|
149
|
+
|
128
150
|
context "when body is an Enumerable IO" do
|
129
151
|
let(:data) { "a" * 16 * 1024 + "b" * 10 * 1024 }
|
130
152
|
let(:body) { StringIO.new data }
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: http
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.0.
|
4
|
+
version: 4.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tony Arcieri
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2019-02-
|
14
|
+
date: 2019-02-15 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: http_parser.rb
|