#NEWLINE# def __call__( self , f ) : #NEWLINE# #INDENT# def func( environ , start_response ) : #NEWLINE# #INDENT# content = f ( environ , start_response ) #NEWLINE# if ( 'gzip' in environ . get ( 'HTTP_ACCEPT_ENCODING' , '' ) ) : #NEWLINE# #INDENT# if ( type ( content ) is list ) : #NEWLINE# #INDENT# content = '' . join ( content ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# content = content . read ( ) #NEWLINE# #UNINDENT# sio = StringIO . StringIO ( ) #NEWLINE# comp_file = gzip . GzipFile ( mode = 'wb' , compresslevel = 6 , fileobj = sio ) #NEWLINE# comp_file . write ( content ) #NEWLINE# comp_file . close ( ) #NEWLINE# start_response . add_header ( 'Content-Encoding' , 'gzip' ) #NEWLINE# res = sio . getvalue ( ) #NEWLINE# start_response . add_header ( 'Content-Length' , len ( res ) ) #NEWLINE# return [ res ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# return content #NEWLINE# #UNINDENT# #UNINDENT# return f