Class: HTTPClient::SSLSocketWrap

Inherits:
Object
  • Object
show all
Defined in:
lib/httpclient.rb

Overview

HTTPClient::SSLSocketWrap

Instance Method Summary collapse

Constructor Details

#initialize(socket, context, debug_dev = nil) ⇒ SSLSocketWrap

Returns a new instance of SSLSocketWrap.



938
939
940
941
942
943
944
945
946
947
# File 'lib/httpclient.rb', line 938

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



1002
1003
1004
1005
1006
# File 'lib/httpclient.rb', line 1002

def <<(str)
  rv = @ssl_socket.write(str)
  @debug_dev << str if @debug_dev
  rv
end

#addrObject



973
974
975
# File 'lib/httpclient.rb', line 973

def addr
  @socket.addr
end

#closeObject



977
978
979
980
# File 'lib/httpclient.rb', line 977

def close
  @ssl_socket.close
  @socket.close
end

#closed?Boolean

Returns:

  • (Boolean)


982
983
984
# File 'lib/httpclient.rb', line 982

def closed?
  @socket.closed?
end

#eof?Boolean

Returns:

  • (Boolean)


986
987
988
# File 'lib/httpclient.rb', line 986

def eof?
  @ssl_socket.eof?
end

#flushObject



1008
1009
1010
# File 'lib/httpclient.rb', line 1008

def flush
  @ssl_socket.flush
end

#gets(*args) ⇒ Object



990
991
992
993
994
# File 'lib/httpclient.rb', line 990

def gets(*args)
  str = @ssl_socket.gets(*args)
  @debug_dev << str if @debug_dev
  str
end

#peer_certObject



969
970
971
# File 'lib/httpclient.rb', line 969

def peer_cert
  @ssl_socket.peer_cert
end

#post_connection_check(host) ⇒ Object



953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
# File 'lib/httpclient.rb', line 953

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)
    @ssl_socket.post_connection_check(hostname)
  else
    @context.post_connection_check(@ssl_socket.peer_cert, hostname)
  end
end

#read(*args) ⇒ Object



996
997
998
999
1000
# File 'lib/httpclient.rb', line 996

def read(*args)
  str = @ssl_socket.read(*args)
  @debug_dev << str if @debug_dev
  str
end

#ssl_connectObject



949
950
951
# File 'lib/httpclient.rb', line 949

def ssl_connect
  @ssl_socket.connect
end

#syncObject



1012
1013
1014
# File 'lib/httpclient.rb', line 1012

def sync
  @ssl_socket.sync
end

#sync=(sync) ⇒ Object



1016
1017
1018
# File 'lib/httpclient.rb', line 1016

def sync=(sync)
  @ssl_socket.sync = sync
end