Class: HTTPClient::SSLSocketWrap
- Inherits:
-
Object
- Object
- HTTPClient::SSLSocketWrap
- Defined in:
- lib/httpclient.rb
Overview
HTTPClient::SSLSocketWrap
Instance Method Summary collapse
- #<<(str) ⇒ Object
- #addr ⇒ Object
- #close ⇒ Object
- #closed? ⇒ Boolean
- #eof? ⇒ Boolean
- #flush ⇒ Object
- #gets(*args) ⇒ Object
-
#initialize(socket, context, debug_dev = nil) ⇒ SSLSocketWrap
constructor
A new instance of SSLSocketWrap.
- #peer_cert ⇒ Object
- #post_connection_check(host) ⇒ Object
- #read(*args) ⇒ Object
- #ssl_connect ⇒ Object
- #sync ⇒ Object
- #sync=(sync) ⇒ Object
Constructor Details
#initialize(socket, context, debug_dev = nil) ⇒ SSLSocketWrap
Returns a new instance of SSLSocketWrap.
1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 |
# File 'lib/httpclient.rb', line 1027 def initialize(socket, context, debug_dev = nil) unless SSLEnabled raise RuntimeError.new( "Ruby/OpenSSL module is required for https access.") end @context = context @socket = socket @ssl_socket = create_ssl_socket(@socket) @debug_dev = debug_dev end |
Instance Method Details
#<<(str) ⇒ Object
1091 1092 1093 1094 1095 |
# File 'lib/httpclient.rb', line 1091 def <<(str) rv = @ssl_socket.write(str) @debug_dev << str if @debug_dev rv end |
#addr ⇒ Object
1062 1063 1064 |
# File 'lib/httpclient.rb', line 1062 def addr @socket.addr end |
#close ⇒ Object
1066 1067 1068 1069 |
# File 'lib/httpclient.rb', line 1066 def close @ssl_socket.close @socket.close end |
#closed? ⇒ Boolean
1071 1072 1073 |
# File 'lib/httpclient.rb', line 1071 def closed? @socket.closed? end |
#eof? ⇒ Boolean
1075 1076 1077 |
# File 'lib/httpclient.rb', line 1075 def eof? @ssl_socket.eof? end |
#flush ⇒ Object
1097 1098 1099 |
# File 'lib/httpclient.rb', line 1097 def flush @ssl_socket.flush end |
#gets(*args) ⇒ Object
1079 1080 1081 1082 1083 |
# File 'lib/httpclient.rb', line 1079 def gets(*args) str = @ssl_socket.gets(*args) @debug_dev << str if @debug_dev str end |
#peer_cert ⇒ Object
1058 1059 1060 |
# File 'lib/httpclient.rb', line 1058 def peer_cert @ssl_socket.peer_cert end |
#post_connection_check(host) ⇒ Object
1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 |
# File 'lib/httpclient.rb', line 1042 def post_connection_check(host) verify_mode = @context.verify_mode || OpenSSL::SSL::VERIFY_NONE if verify_mode == OpenSSL::SSL::VERIFY_NONE return elsif @ssl_socket.peer_cert.nil? and check_mask(verify_mode, OpenSSL::SSL::VERIFY_FAIL_IF_NO_PEER_CERT) raise OpenSSL::SSL::SSLError, "no peer cert" end hostname = host.host if @ssl_socket.respond_to?(:post_connection_check) and RUBY_VERSION > "1.8.4" @ssl_socket.post_connection_check(hostname) else @context.post_connection_check(@ssl_socket.peer_cert, hostname) end end |
#read(*args) ⇒ Object
1085 1086 1087 1088 1089 |
# File 'lib/httpclient.rb', line 1085 def read(*args) str = @ssl_socket.read(*args) @debug_dev << str if @debug_dev str end |
#ssl_connect ⇒ Object
1038 1039 1040 |
# File 'lib/httpclient.rb', line 1038 def ssl_connect @ssl_socket.connect end |
#sync ⇒ Object
1101 1102 1103 |
# File 'lib/httpclient.rb', line 1101 def sync @ssl_socket.sync end |
#sync=(sync) ⇒ Object
1105 1106 1107 |
# File 'lib/httpclient.rb', line 1105 def sync=(sync) @ssl_socket.sync = sync end |