class Thrift::HTTPClientTransport
Public Class Methods
Source
# File lib/thrift/transport/http_client_transport.rb 30 def initialize(url, opts = {}) 31 @url = URI url 32 @headers = {"Content-Type" => "application/x-thrift"} 33 @outbuf = Bytes.empty_byte_buffer 34 @ssl_verify_mode = opts.fetch(:ssl_verify_mode, OpenSSL::SSL::VERIFY_PEER) 35 @ssl_ca_file = opts[:ssl_ca_file] 36 end
Public Instance Methods
Source
# File lib/thrift/transport/http_client_transport.rb 49 def add_headers(headers) 50 @headers = @headers.merge(headers) 51 end
Source
# File lib/thrift/transport/http_client_transport.rb 53 def flush 54 http = Net::HTTP.new @url.host, @url.port 55 http.use_ssl = @url.scheme == "https" 56 if @url.scheme == "https" 57 http.verify_mode = @ssl_verify_mode 58 http.ca_file = @ssl_ca_file if @ssl_ca_file 59 end 60 resp = http.post(@url.request_uri, @outbuf, @headers) 61 response_code = resp.code.to_i 62 raise TransportException.new(TransportException::UNKNOWN, "#{self.class.name} Could not connect to #{self}, HTTP status code #{response_code}") unless (200..299).cover?(response_code) 63 64 @response_code = response_code 65 data = Bytes.force_binary_encoding(resp.body || Bytes.empty_byte_buffer) 66 @inbuf = StringIO.new data 67 ensure 68 @outbuf = Bytes.empty_byte_buffer 69 end
Source
# File lib/thrift/transport/http_client_transport.rb 40 def read(sz) 41 data = @inbuf.read sz 42 return data unless data.nil? 43 44 raise TransportException.new(TransportException::END_OF_FILE, "#{self.class.name} reached EOF reading response from #{self}, HTTP status code #{@response_code}") 45 end
Source
# File lib/thrift/transport/http_client_transport.rb 71 def to_s 72 path = @url.path.to_s 73 path = "/" if path.empty? 74 "#{@url.scheme}(#{@url.host}:#{@url.port}#{path})" 75 end
Source
# File lib/thrift/transport/http_client_transport.rb 47 def write(buf); @outbuf << Bytes.force_binary_encoding(buf) end