blob: 2c4adfcd73bc42f87d4b63beb4a00a3e4da4a470 [file] [log] [blame]
Kevin Clark74df0bf2008-06-18 01:00:33 +00001require 'thrift/transport'
2
3require 'net/http'
4require 'uri'
5require 'stringio'
6
7## Very simple HTTP client
8module Thrift
9 class HTTPClient < Transport
10 def initialize(url)
11 @url = URI url
12 @outbuf = ""
13 end
14
15 def open?; true end
16 def read(sz); @inbuf.read sz end
17 def write(buf); @outbuf << buf end
18 def flush
19 http = Net::HTTP.new @url.host, @url.port
20 resp, data = http.post(@url.path, @outbuf)
21 @inbuf = StringIO.new data
22 @outbuf = ""
23 end
24 end
25 deprecate_class! :THttpClient => HTTPClient
26end