module Rack::HttpPipe
Public Instance Methods
http_pipe(url, opts = {})
click to toggle source
# File lib/rack/http-pipe/pipe.rb, line 5 def http_pipe(url, opts = {}) st = opts.fetch(:status, 200) uri = URI(url) status st if opts[:headers] and opts[:headers].is_a? Hash headers opts[:headers] end stream do Net::HTTP.start(uri.host, uri.port) do |http| req = Net::HTTP::Get.new(uri.request_uri) req.basic_auth uri.user, uri.password http.request req do |res| res.read_body do |c| response.write c end end end end end