#NEWLINE# def _get_request_path( self , request , scenario ) : #NEWLINE# #INDENT# parsed_url = parse . urlparse ( request . url ) #NEWLINE# if ( not self . _target . get ( 'scheme' ) ) : #NEWLINE# #INDENT# self . _target [ 'scheme' ] = parsed_url . scheme #NEWLINE# #UNINDENT# if ( not self . _target . get ( 'netloc' ) ) : #NEWLINE# #INDENT# self . _target [ 'netloc' ] = parsed_url . netloc #NEWLINE# #UNINDENT# if ( ( parsed_url . scheme != self . _target [ 'scheme' ] ) or ( parsed_url . netloc != self . _target [ 'netloc' ] ) ) : #NEWLINE# #INDENT# raise ValueError ( 'Address port and host must be the same' ) #NEWLINE# #UNINDENT# path = parsed_url . path #NEWLINE# if parsed_url . query : #NEWLINE# #INDENT# path += ( '?' + parsed_url . query ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( ( request . method == 'GET' ) and isinstance ( request . body , dict ) ) : #NEWLINE# #INDENT# path += ( '?' + urlencode ( request . body ) ) #NEWLINE# #UNINDENT# #UNINDENT# if ( not parsed_url . netloc ) : #NEWLINE# #INDENT# parsed_url = parse . urlparse ( scenario . get ( 'default-address' , '' ) ) #NEWLINE# #UNINDENT# self . hostname = ( parsed_url . netloc . split ( ':' ) [ 0 ] if ( ':' in parsed_url . netloc ) else parsed_url . netloc ) #NEWLINE# self . use_ssl = ( parsed_url . scheme == 'https' ) #NEWLINE# if parsed_url . port : #NEWLINE# #INDENT# self . port = parsed_url . port #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# self . port = ( 443 if self . use_ssl else 80 ) #NEWLINE# #UNINDENT# return ( path if len ( path ) else '/' )