Spade
Mini Shell
| Directory:~$ /proc/self/root/usr/lib/python2.7/site-packages/ndg/httpsclient/ |
| [Home] [System Details] [Kill Me] |
�
��Oc@s�dZdZdZdZdZdZdZddlZddlZdd l m
Z
dd
l mZddlm
Z
ddlmZdd
lmZeje�Zdefd��YZde
fd��YZdS(s�ndg_httpsclient
HTTPS module containing PyOpenSSL implementation of
httplib.HTTPSConnection
PyOpenSSL utility to make a httplib-like interface suitable for use with
urllib2
sP J Kershaw (STFC)s09/12/11s2(C) 2012 Science and Technology Facilities
Councils-BSD - see LICENSE file in top-level
directorysPhilip.Kershaw@stfc.ac.uks$Id$i����N(t
HTTPS_PORT(tHTTPConnection(tAbstractHTTPHandler(tSSL(t SSLSockettHTTPSConnectioncBsGeZdZeZejZdde j
dd�Zd�Zd�Z
RS(sTThis class allows communication via SSL
using PyOpenSSL.
It is based on httplib.HTTPSConnection, modified to use PyOpenSSL.
Note: This uses the constructor inherited from HTTPConnection to allow
it to
be used with httplib and HTTPSContextHandler. To use the class directly
with
an SSL context set ssl_context after construction.
@cvar default_port: default port for this class (443)
@type default_port: int
@cvar default_ssl_method: default SSL method used if no SSL context is
explicitly set - defaults to version 2/3.
@type default_ssl_method: int
cCsutj|||||�t|d�s4d|_n|dk rqt|tj�setd|��n||_ndS(Ntssl_contextsLExpecting
OpenSSL.SSL.Context type for "ssl_context" keyword; got %r
instead( Rt__init__thasattrtNoneRt
isinstanceRtContextt TypeError(tselfthosttporttstrictttimeoutR((s9/usr/lib/python2.7/site-packages/ndg/httpsclient/https.pyR,s
cCs�t|dd�rIt|jtj�s=td|j��n|j}ntj|jj�}t j
|j|jf|j
�}t|dd�r�||_|j�nt||�|_|jj�dS(s.Create
SSL socket and connect to peer
RsNExpecting OpenSSL.SSL.Context type for "ssl_context"
attribute; got %r insteadt_tunnel_hostN(tgetattrR R
RRRRt __class__tdefault_ssl_methodtsockettcreate_connectionRRRtsockt_tunnelRtset_connect_state(R
RR((s9/usr/lib/python2.7/site-packages/ndg/httpsclient/https.pytconnect:s!
cCs|jj�dS(s)Close
socket and shut down SSL
connectionN(Rtclose(R
((s9/usr/lib/python2.7/site-packages/ndg/httpsclient/https.pyRRsN(t__name__t
__module__t__doc__Rtdefault_portRt
SSLv23_METHODRR Rt_GLOBAL_DEFAULT_TIMEOUTRRR(((s9/usr/lib/python2.7/site-packages/ndg/httpsclient/https.pyRs
tHTTPSContextHandlercBs,eZdZejZdd�Zd�ZRS(sSHTTPS
handler that allows a SSL context to be set for the SSL
connections.
icCsftj||�|dk rMt|tj�sAtd|��n||_ntjtj�|_dS(s�
@param ssl_context:SSL context
@type ssl_context: OpenSSL.SSL.Context
@param debuglevel: debug level for HTTPSHandler
@type debuglevel: int
sLExpecting OpenSSL.SSL.Context type for "ssl_context"
keyword; got %r insteadN( RRR R
RRRRR!(R
Rt
debuglevel((s9/usr/lib/python2.7/site-packages/ndg/httpsclient/https.pyR]s
cCs2tdttfi|jd6�}|j||�S(scOpens
HTTPS request
@param req: HTTP request
@return: HTTP Response object
tCustomHTTPSContextConnectionR(ttypeRtobjectRtdo_open(R
treqtcustomHTTPSContextConnection((s9/usr/lib/python2.7/site-packages/ndg/httpsclient/https.pyt
https_openos (RRRRtdo_request_t
https_requestRR+(((s9/usr/lib/python2.7/site-packages/ndg/httpsclient/https.pyR#Ws (Rt
__author__t__date__t
__copyright__t__license__t__contact__t__revision__tloggingRthttplibRRturllib2RtOpenSSLRtndg.httpsclient.ssl_socketRt getLoggerRtlogRR#(((s9/usr/lib/python2.7/site-packages/ndg/httpsclient/https.pyt<module>s
<