<s> import urllib2 <EOL> import httplib <EOL> import ssl <EOL> import socket <EOL> import os <EOL> import sys <EOL> try : <EOL> main_file = os . path . abspath ( sys . modules [ '<STR_LIT:__main__>' ] . __file__ ) <EOL> except AttributeError : <EOL> main_file = sys . executable <EOL> CERT_FILE = os . path . join ( os . path . dirname ( main_file ) , '<STR_LIT>' ) <EOL> class ValidHTTPSConnection ( httplib . HTTPConnection ) : <EOL> "<STR_LIT>" <EOL> default_port = httplib . HTTPS_PORT <EOL> def __init__ ( self , * args , ** kwargs ) : <EOL> httplib . HTTPConnection . __init__ ( self , * args , ** kwargs ) <EOL> def connect ( self ) : <EOL> "<STR_LIT>" <EOL> sock = socket . create_connection ( ( self . host , self . port ) , <EOL> self . timeout , self . source_address ) <EOL> if self . _tunnel_host : <EOL> self . sock = sock <EOL> self . _tunnel ( ) <EOL> self . sock = ssl . wrap_socket ( sock , <EOL> ca_certs = CERT_FILE , <EOL> cert_reqs = ssl . CERT_REQUIRED ) <EOL> class ValidHTTPSHandler ( urllib2 . HTTPSHandler ) : <EOL> def https_open ( self , req ) : <EOL> return self . do_open ( ValidHTTPSConnection , req ) <EOL> urllib2 . install_opener ( urllib2 . build_opener ( ValidHTTPSHandler ) ) <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> def test_access ( url ) : <EOL> print "<STR_LIT>" , url <EOL> page = urllib2 . urlopen ( url ) <EOL> print page . info ( ) <EOL> data = page . read ( ) <EOL> print "<STR_LIT>" , data [ <NUM_LIT:0> : <NUM_LIT:100> ] <EOL> print "<STR_LIT>" , url <EOL> print "<STR_LIT>" <EOL> test_access ( "<STR_LIT>" ) <EOL> test_access ( "<STR_LIT>" ) <EOL> test_access ( "<STR_LIT>" ) </s>
