Class: Net::HTTP

Inherits:
Object
  • Object
show all
Defined in:
lib/net_http_hacked.rb

Instance Method Summary collapse

Instance Method Details

#begin_request_hacked(req) ⇒ Object

Original #request with block semantics.

def request(req, body = nil, &block)

unless started?
  start {
    req['connection'] ||= 'close'
    return request(req, body, &block)
  }
end
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)
  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



49
50
51
52
53
54
55
56
57
58
# File 'lib/net_http_hacked.rb', line 49

def begin_request_hacked(req)
  begin_transport req
  req.exec @socket, @curr_http_version, edit_path(req.path)
  begin
    res = Net::HTTPResponse.read_new(@socket)
  end while res.kind_of?(Net::HTTPContinue)
  res.begin_reading_body_hacked(@socket, req.response_body_permitted?)
  @req_hacked, @res_hacked = req, res
  @res_hacked
end

#end_request_hackedObject



60
61
62
63
64
# File 'lib/net_http_hacked.rb', line 60

def end_request_hacked
  @res_hacked.end_reading_body_hacked
  end_transport @req_hacked, @res_hacked
  @res_hacked
end