Class: HTTPClient::SSLSocket
- Inherits:
-
Object
- Object
- HTTPClient::SSLSocket
- Defined in:
- lib/httpclient/ssl_socket.rb
Overview
Wraps up OpenSSL::SSL::SSLSocket and offers debugging features.
Class Method Summary collapse
Instance Method Summary collapse
- #<<(str) ⇒ Object
- #close ⇒ Object
- #closed? ⇒ Boolean
- #eof? ⇒ Boolean
- #flush ⇒ Object
- #gets(rs) ⇒ Object
-
#initialize(socket, dest, config, opts = {}) ⇒ SSLSocket
constructor
A new instance of SSLSocket.
- #peer_cert ⇒ Object
- #read(size, buf = nil) ⇒ Object
- #readpartial(size, buf = nil) ⇒ Object
- #sync ⇒ Object
- #sync=(sync) ⇒ Object
Constructor Details
#initialize(socket, dest, config, opts = {}) ⇒ SSLSocket
Returns a new instance of SSLSocket.
33 34 35 36 37 38 39 40 41 42 |
# File 'lib/httpclient/ssl_socket.rb', line 33 def initialize(socket, dest, config, opts = {}) unless SSLEnabled raise ConfigurationError.new('Ruby/OpenSSL module is required') end @socket = socket @config = config @ssl_socket = create_openssl_socket(@socket) @debug_dev = opts[:debug_dev] ssl_connect(dest.host) end |
Class Method Details
.create_socket(session) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/httpclient/ssl_socket.rb', line 16 def self.create_socket(session) opts = { :debug_dev => session.debug_dev } site = session.proxy || session.dest socket = session.create_socket(site.host, site.port) begin if session.proxy session.connect_ssl_proxy(socket, Util.urify(session.dest.to_s)) end new(socket, session.dest, session.ssl_config, opts) rescue socket.close raise end end |
Instance Method Details
#<<(str) ⇒ Object
79 80 81 82 83 |
# File 'lib/httpclient/ssl_socket.rb', line 79 def <<(str) rv = @ssl_socket.write(str) debug(str) rv end |
#close ⇒ Object
48 49 50 51 |
# File 'lib/httpclient/ssl_socket.rb', line 48 def close @ssl_socket.close @socket.close end |
#closed? ⇒ Boolean
53 54 55 |
# File 'lib/httpclient/ssl_socket.rb', line 53 def closed? @socket.closed? end |
#eof? ⇒ Boolean
57 58 59 |
# File 'lib/httpclient/ssl_socket.rb', line 57 def eof? @ssl_socket.eof? end |
#flush ⇒ Object
85 86 87 |
# File 'lib/httpclient/ssl_socket.rb', line 85 def flush @ssl_socket.flush end |
#gets(rs) ⇒ Object
61 62 63 64 65 |
# File 'lib/httpclient/ssl_socket.rb', line 61 def gets(rs) str = @ssl_socket.gets(rs) debug(str) str end |
#peer_cert ⇒ Object
44 45 46 |
# File 'lib/httpclient/ssl_socket.rb', line 44 def peer_cert @ssl_socket.peer_cert end |
#read(size, buf = nil) ⇒ Object
67 68 69 70 71 |
# File 'lib/httpclient/ssl_socket.rb', line 67 def read(size, buf = nil) str = @ssl_socket.read(size, buf) debug(str) str end |
#readpartial(size, buf = nil) ⇒ Object
73 74 75 76 77 |
# File 'lib/httpclient/ssl_socket.rb', line 73 def readpartial(size, buf = nil) str = @ssl_socket.readpartial(size, buf) debug(str) str end |
#sync ⇒ Object
89 90 91 |
# File 'lib/httpclient/ssl_socket.rb', line 89 def sync @ssl_socket.sync end |
#sync=(sync) ⇒ Object
93 94 95 |
# File 'lib/httpclient/ssl_socket.rb', line 93 def sync=(sync) @ssl_socket.sync = sync end |