Module: RAWS::HTTP::HT2P

Defined in:
lib/raws/http/ht2p.rb

Defined Under Namespace

Classes: Request, Response

Class Method Summary collapse

Class Method Details

.connect(uri, &block) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/raws/http/ht2p.rb', line 4

def self.connect(uri, &block)
  response = nil
  begin
    HT2P::Client.new uri do |request|
      response = block.call(Request.new(request))
    end
  rescue RAWS::HTTP::Redirect => e
    r = e.response
    uri = r.header['location'] || r.doc['Error']['Endpoint']
    retry
  end
  response
end