Class: Thrift::HTTPClientTransport

Inherits:
BaseTransport show all
Defined in:
lib/thrift/transport/http_client_transport.rb

Instance Method Summary collapse

Methods inherited from BaseTransport

#close, #open, #read_all

Constructor Details

#initialize(url) ⇒ HTTPClientTransport

Returns a new instance of HTTPClientTransport.



28
29
30
31
# File 'lib/thrift/transport/http_client_transport.rb', line 28

def initialize(url)
  @url = URI url
  @outbuf = ""
end

Instance Method Details

#flushObject



36
37
38
39
40
41
42
43
# File 'lib/thrift/transport/http_client_transport.rb', line 36

def flush
  http = Net::HTTP.new @url.host, @url.port
  http.use_ssl = @url.scheme == "https"
  headers = { 'Content-Type' => 'application/x-thrift' }
  resp, data = http.post(@url.path, @outbuf, headers)
  @inbuf = StringIO.new data
  @outbuf = ""
end

#open?Boolean

Returns:

  • (Boolean)


33
# File 'lib/thrift/transport/http_client_transport.rb', line 33

def open?; true end

#read(sz) ⇒ Object



34
# File 'lib/thrift/transport/http_client_transport.rb', line 34

def read(sz); @inbuf.read sz end

#write(buf) ⇒ Object



35
# File 'lib/thrift/transport/http_client_transport.rb', line 35

def write(buf); @outbuf << buf end