blob: 4c516633586fdd23a641348c931c37726ee5549c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
# -*- encoding: binary -*-
#
# This is a OS-level pipe that overrides IO#read to provide
# IO#readpartial-like semantics while remaining Rack::Lint-compatible
# for EOF, meaning we return nil on EOF instead of raising EOFError.
class HTTP_Spew::ChunkyPipe < Kgio::Pipe
# other threads may force an error to be raised in the +read+
# method
attr_accessor :error
# Override IO#read to behave like IO#readpartial, but still return +nil+
# on EOF instead of raising EOFError.
def read(*args)
check_err!
kgio_read(*args) || check_err! || close
end
def check_err!
if defined?(@error)
closed? or close
raise @error
end
nil
end
end
|