Class: Thrift::HTTPClientTransport
- Inherits:
-
BaseTransport
- Object
- BaseTransport
- Thrift::HTTPClientTransport
- Defined in:
- lib/thrift/transport/http_client_transport.rb
Instance Method Summary collapse
- #add_headers(headers) ⇒ Object
- #flush ⇒ Object
-
#initialize(url) ⇒ HTTPClientTransport
constructor
A new instance of HTTPClientTransport.
- #open? ⇒ Boolean
- #read(sz) ⇒ Object
- #write(buf) ⇒ Object
Methods inherited from BaseTransport
Constructor Details
#initialize(url) ⇒ HTTPClientTransport
Returns a new instance of HTTPClientTransport.
29 30 31 32 33 |
# File 'lib/thrift/transport/http_client_transport.rb', line 29 def initialize(url) @url = URI url @headers = {'Content-Type' => 'application/x-thrift'} @outbuf = "" end |
Instance Method Details
#add_headers(headers) ⇒ Object
39 40 41 |
# File 'lib/thrift/transport/http_client_transport.rb', line 39 def add_headers(headers) @headers = @headers.merge(headers) end |
#flush ⇒ Object
43 44 45 46 47 48 49 |
# File 'lib/thrift/transport/http_client_transport.rb', line 43 def flush http = Net::HTTP.new @url.host, @url.port http.use_ssl = @url.scheme == "https" resp, data = http.post(@url.request_uri, @outbuf, @headers) @inbuf = StringIO.new data @outbuf = "" end |
#open? ⇒ Boolean
35 |
# File 'lib/thrift/transport/http_client_transport.rb', line 35 def open?; true end |
#read(sz) ⇒ Object
36 |
# File 'lib/thrift/transport/http_client_transport.rb', line 36 def read(sz); @inbuf.read sz end |
#write(buf) ⇒ Object
37 |
# File 'lib/thrift/transport/http_client_transport.rb', line 37 def write(buf); @outbuf << buf end |