#NEWLINE# def get_wsgi_headers( self , environ ) : #NEWLINE# #INDENT# 'This is automatically called right before the response is started\n        and returns headers modified for the given environment.  It returns a\n        copy of the headers from the response with some modifications applied\n        if necessary.\n\n        For example the location header (if present) is joined with the root\n        URL of the environment.  Also the content length is automatically set\n        to zero here for certain status codes.\n\n        .. versionchanged:: 0.6\n           Previously that function was called `fix_headers` and modified\n           the response object in place.  Also since 0.6, IRIs in location\n           and content-location headers are handled properly.\n\n           Also starting with 0.6, Werkzeug will attempt to set the content\n           length if it is able to figure it out on its own.  This is the\n           case if all the strings in the response iterable are already\n           encoded and the iterable is buffered.\n\n        :param environ: the WSGI environment of the request.\n        :return: returns a new :class:`~werkzeug.datastructures.Headers`\n                 object.\n        ' #NEWLINE# headers = Headers ( self . headers ) #NEWLINE# location = None #NEWLINE# content_location = None #NEWLINE# content_length = None #NEWLINE# status = self . status_code #NEWLINE# for ( key , value ) in headers : #NEWLINE# #INDENT# ikey = key . lower ( ) #NEWLINE# if ( ikey == 'location' ) : #NEWLINE# #INDENT# location = value #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( ikey == 'content-location' ) : #NEWLINE# #INDENT# content_location = value #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( ikey == 'content-length' ) : #NEWLINE# #INDENT# content_length = value #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# if ( location is not None ) : #NEWLINE# #INDENT# old_location = location #NEWLINE# if isinstance ( location , text_type ) : #NEWLINE# #INDENT# location = iri_to_uri ( location ) #NEWLINE# #UNINDENT# if self . autocorrect_location_header : #NEWLINE# #INDENT# current_url = get_current_url ( environ , root_only = True ) #NEWLINE# if isinstance ( current_url , text_type ) : #NEWLINE# #INDENT# current_url = iri_to_uri ( current_url ) #NEWLINE# #UNINDENT# location = url_join ( current_url , location ) #NEWLINE# #UNINDENT# if ( location != old_location ) : #NEWLINE# #INDENT# headers [ 'Location' ] = environ #NEWLINE# #UNINDENT# #UNINDENT# if ( ( content_location is not None ) and isinstance ( content_location , text_type ) ) : #NEWLINE# #INDENT# headers [ 'Content-Location' ] = iri_to_uri ( content_location ) #NEWLINE# #UNINDENT# if ( ( 100 <= status < 200 ) or ( status == 204 ) ) : #NEWLINE# #INDENT# headers [ 'Content-Length' ] = content_length = '0' #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( status == 304 ) : #NEWLINE# #INDENT# remove_entity_headers ( headers ) #NEWLINE# #UNINDENT# #UNINDENT# if ( self . automatically_set_content_length and self . is_sequence and ( content_length is None ) and ( status != 304 ) ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# content_length = sum ( ( len ( to_bytes ( x , 'ascii' ) ) for x in self . response ) ) #NEWLINE# #UNINDENT# except UnicodeError : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# headers [ 'Content-Length' ] = str ( content_length ) #NEWLINE# #UNINDENT# #UNINDENT# return headers