#NEWLINE# def __call__( self , env , start_response ) : #NEWLINE# #INDENT# '\n        Main hook into the WSGI paste.deploy filter/app pipeline.\n\n        :param env: The WSGI environment dict.\n        :param start_response: The WSGI start_response hook.\n        :returns: Response as per WSGI.\n        ' #NEWLINE# if ( env [ 'REQUEST_METHOD' ] == 'OPTIONS' ) : #NEWLINE# #INDENT# return self . app ( start_response , start_response ) #NEWLINE# #UNINDENT# info = self . _get_temp_url_info ( env ) #NEWLINE# ( temp_url_sig , temp_url_expires , filename , inline_disposition ) = info #NEWLINE# if ( ( temp_url_sig is None ) and ( temp_url_expires is None ) ) : #NEWLINE# #INDENT# return self . app ( env , start_response ) #NEWLINE# #UNINDENT# if ( ( not temp_url_sig ) or ( not temp_url_expires ) ) : #NEWLINE# #INDENT# return self . _invalid ( env , start_response ) #NEWLINE# #UNINDENT# ( account , container ) = self . _get_account_and_container ( env ) #NEWLINE# if ( not account ) : #NEWLINE# #INDENT# return self . _invalid ( env , start_response ) #NEWLINE# #UNINDENT# keys = self . _get_keys ( env ) #NEWLINE# if ( not keys ) : #NEWLINE# #INDENT# return self . _invalid ( env , start_response ) #NEWLINE# #UNINDENT# if ( env [ 'REQUEST_METHOD' ] == 'HEAD' ) : #NEWLINE# #INDENT# hmac_vals = ( ( ( self . _get_hmacs ( env , temp_url_expires , keys ) + self . _get_hmacs ( env , temp_url_expires , keys , request_method = 'GET' ) ) + self . _get_hmacs ( env , temp_url_expires , keys , request_method = 'POST' ) ) + self . _get_hmacs ( env , temp_url_expires , keys , request_method = 'PUT' ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# hmac_vals = self . _get_hmacs ( env , temp_url_expires , keys ) #NEWLINE# #UNINDENT# is_valid_hmac = False #NEWLINE# hmac_scope = None #NEWLINE# for ( hmac , scope ) in hmac_vals : #NEWLINE# #INDENT# if streq_const_time ( temp_url_sig , hmac ) : #NEWLINE# #INDENT# is_valid_hmac = True #NEWLINE# hmac_scope = scope #NEWLINE# break #NEWLINE# #UNINDENT# #UNINDENT# if ( not is_valid_hmac ) : #NEWLINE# #INDENT# return self . _invalid ( env , start_response ) #NEWLINE# #UNINDENT# resp = self . _clean_disallowed_headers ( env , start_response ) #NEWLINE# if resp : #NEWLINE# #INDENT# return resp #NEWLINE# #UNINDENT# self . _clean_incoming_headers ( env ) #NEWLINE# if ( hmac_scope == ACCOUNT_SCOPE ) : #NEWLINE# #INDENT# env [ 'swift.authorize' ] = authorize_same_account ( account ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# env [ 'swift.authorize' ] = authorize_same_container ( account , container ) #NEWLINE# #UNINDENT# env [ 'swift.authorize_override' ] = True #NEWLINE# env [ 'REMOTE_USER' ] = '.wsgi.tempurl' #NEWLINE# qs = { #NEWLINE# #INDENT# 'temp_url_sig' : temp_url_sig , #NEWLINE# 'temp_url_expires' : temp_url_expires , #NEWLINE# #UNINDENT# } #NEWLINE# if filename : #NEWLINE# #INDENT# qs [ 'filename' ] = filename #NEWLINE# #UNINDENT# env [ 'QUERY_STRING' ] = urlencode ( qs ) #NEWLINE# def _start_response( status , headers , exc_info = None ) : #NEWLINE# #INDENT# headers = self . _clean_outgoing_headers ( headers ) #NEWLINE# if ( ( env [ 'REQUEST_METHOD' ] in ( 'GET' , 'HEAD' ) ) and ( status [ 0 ] == '2' ) ) : #NEWLINE# #INDENT# out_headers = [ ] #NEWLINE# existing_disposition = None #NEWLINE# for ( h , v ) in headers : #NEWLINE# #INDENT# if ( h . lower ( ) != 'content-disposition' ) : #NEWLINE# #INDENT# out_headers . append ( ( h , v ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# existing_disposition = v #NEWLINE# #UNINDENT# #UNINDENT# if inline_disposition : #NEWLINE# #INDENT# disposition_value = 'inline' #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if filename : #NEWLINE# #INDENT# disposition_value = disposition_format ( filename ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if existing_disposition : #NEWLINE# #INDENT# disposition_value = existing_disposition #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# name = basename ( env [ 'PATH_INFO' ] . rstrip ( '/' ) ) #NEWLINE# disposition_value = disposition_format ( name ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# value = disposition_value . replace ( '\n' , '%0A' ) #NEWLINE# out_headers . append ( ( 'Content-Disposition' , value ) ) #NEWLINE# headers = out_headers #NEWLINE# #UNINDENT# return start_response ( status , headers , exc_info ) #NEWLINE# #UNINDENT# return self . app ( env , _start_response )