Class: Net::HTTP
- Inherits:
-
Object
- Object
- Net::HTTP
- Defined in:
- lib/appengine-apis/urlfetch.rb
Overview
Monkey patch Net::HTTP to makes requests using Google App Engine’s URLFetch Service.
Instance Method Summary collapse
Instance Method Details
#request(req, body = nil, &block) ⇒ Object
190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 |
# File 'lib/appengine-apis/urlfetch.rb', line 190 def request(req, body=nil, &block) begin proto = use_ssl? ? 'https' : 'http' url = "#{proto}://#{addr_port}#{req.path}" = { :payload => body, :follow_redirects => false, :allow_truncated => true, :method => req.method, :headers => req } res = AppEngine::URLFetch.fetch(url, ) end while res.kind_of?(Net::HTTPContinue) res.reading_body(nil, req.response_body_permitted?) { yield res if block_given? } return res end |