blob: 2c4adfcd73bc42f87d4b63beb4a00a3e4da4a470 [file] [log] [blame]
require 'thrift/transport'
require 'net/http'
require 'uri'
require 'stringio'
## Very simple HTTP client
module Thrift
class HTTPClient < Transport
def initialize(url)
@url = URI url
@outbuf = ""
end
def open?; true end
def read(sz); @inbuf.read sz end
def write(buf); @outbuf << buf end
def flush
http = Net::HTTP.new @url.host, @url.port
resp, data = http.post(@url.path, @outbuf)
@inbuf = StringIO.new data
@outbuf = ""
end
end
deprecate_class! :THttpClient => HTTPClient
end