Class: Net::BufferedIO
- Inherits:
-
Object
- Object
- Net::BufferedIO
- Defined in:
- lib/web/ext/net_http.rb
Instance Method Summary collapse
-
#initialize_with_web(io, debug_output = nil) ⇒ Object
(also: #initialize)
Catch the socket This method was largely influenced by FakeWeb.
Instance Method Details
#initialize_with_web(io, debug_output = nil) ⇒ Object Also known as: initialize
Catch the socket This method was largely influenced by FakeWeb
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/web/ext/net_http.rb', line 14 def initialize_with_web(io, debug_output = nil) @read_timeout = 60 @rbuf = '' @debug_output = debug_output # If io is a socket, use it directly # If io is a string that represents a file path, open the file # Otherwise, open a StringIO so we can stream @io = case io when Socket, OpenSSL::SSL::SSLSocket, IO io when String if !io.include?("\0") && File.exists?(io) && !File.directory?(io) File.open(io, 'r') else StringIO.new(io) end end # make sure we have the stream open raise 'Unable to create local socket' unless @io end |