Class: Net::HTTP

Inherits:
Protocol
  • Object
show all
Defined in:
lib/loggr-rb/http.rb

Instance Method Summary collapse

Instance Method Details

#read_response(req, body = nil, &block) ⇒ Object

second half of HTTP.request that yields or returns the response



20
21
22
23
24
25
26
27
28
29
30
# File 'lib/loggr-rb/http.rb', line 20

def read_response(req, body = nil, &block)  # :yield: +response+
  begin
    res = HTTPResponse.read_new(@socket)
  end while res.kind_of?(HTTPContinue)
  res.reading_body(@socket, req.response_body_permitted?) {
    yield res if block_given?
  }
  end_transport req, res

  res
end

#request_async(req, body = nil) ⇒ Object

pasted first half of HTTP.request that writes the request to the server, does not return HTTPResponse and does not take a block



7
8
9
10
11
12
13
14
15
16
17
# File 'lib/loggr-rb/http.rb', line 7

def request_async(req, body = nil)
  if proxy_user()
    unless use_ssl?
      req.proxy_basic_auth proxy_user(), proxy_pass()
    end
  end

  req.set_body_internal body
  begin_transport req
  req.exec @socket, @curr_http_version, edit_path(req.path)
end