Class: Thrift::HTTPClientTransport
- Inherits:
-
BaseTransport
show all
- Defined in:
- lib/thrift.rb,
lib/thrift/transport/http_client_transport.rb
Instance Method Summary
collapse
#close, #open, #read_all, #read_byte, #read_into_buffer
Constructor Details
#initialize(url, proxy_addr = nil, proxy_port = nil) ⇒ HTTPClientTransport
Returns a new instance of HTTPClientTransport.
29
30
31
32
33
34
35
36
|
# File 'lib/thrift/transport/http_client_transport.rb', line 29
def initialize(url, proxy_addr = nil, proxy_port = nil)
@url = URI url
=
@ssl_attributes = default_ssl_attributes
@outbuf = Bytes.empty_byte_buffer
@proxy_addr = proxy_addr
@proxy_port = proxy_port
end
|
Instance Method Details
42
43
44
|
# File 'lib/thrift/transport/http_client_transport.rb', line 42
def ()
= .merge()
end
|
#add_ssl_attributes(attributes) ⇒ Object
Add ssl attributes for underlying Net::HTTP instance.
attributes - Hash of Symbols to values where keys correspond to ssl
attributes of Net::HTTP like ca_file, verify_mode, etc.
50
51
52
|
# File 'lib/thrift/transport/http_client_transport.rb', line 50
def add_ssl_attributes(attributes)
@ssl_attributes = @ssl_attributes.merge(attributes)
end
|
#flush ⇒ Object
54
55
56
57
58
59
60
61
62
63
|
# File 'lib/thrift/transport/http_client_transport.rb', line 54
def flush
http = Net::HTTP.new @url.host, @url.port, @proxy_addr, @proxy_port
apply_ssl_attributes(http) if @url.scheme == "https"
resp = http.post(@url.request_uri, @outbuf, )
data = resp.body
data = Bytes.force_binary_encoding(data)
@inbuf = StringIO.new data
@outbuf = Bytes.empty_byte_buffer
end
|
#open? ⇒ Boolean
38
|
# File 'lib/thrift/transport/http_client_transport.rb', line 38
def open?; true end
|
#read(sz) ⇒ Object
39
|
# File 'lib/thrift/transport/http_client_transport.rb', line 39
def read(sz); @inbuf.read sz end
|
#write(buf) ⇒ Object
40
|
# File 'lib/thrift/transport/http_client_transport.rb', line 40
def write(buf); @outbuf << Bytes.force_binary_encoding(buf) end
|