Class: ThreadedProxy::HTTP

Inherits:
Net::HTTP
  • Object
show all
Defined in:
lib/threaded_proxy/http.rb

Instance Method Summary collapse

Instance Method Details

#copy_to(dest_socket) ⇒ Object



14
15
16
# File 'lib/threaded_proxy/http.rb', line 14

def copy_to(dest_socket)
  IO.copy_stream(@socket.io, dest_socket)
end

#flush_existing_buffer_to(dest_socket) ⇒ Object



5
6
7
8
9
10
11
12
# File 'lib/threaded_proxy/http.rb', line 5

def flush_existing_buffer_to(dest_socket)
  while (data = @socket.send(:rbuf_consume))
    break if data.empty?
    dest_socket.write data
  end

  dest_socket.flush
end

#request(*args) ⇒ Object



18
19
20
21
22
23
24
# File 'lib/threaded_proxy/http.rb', line 18

def request(*args)
  if block_given?
    super { |res| yield hijack_response(res) }
  else
    hijack_response(super)
  end
end