<s> """<STR_LIT>""" <EOL> from tornado . web import asynchronous <EOL> from . . import proto <EOL> from . import streamingbase <EOL> HTMLFILE_HEAD = r'''<STR_LIT>''' . strip ( ) <EOL> HTMLFILE_HEAD += '<STR_LIT:U+0020>' * ( <NUM_LIT> - len ( HTMLFILE_HEAD ) + <NUM_LIT> ) <EOL> HTMLFILE_HEAD += '<STR_LIT>' <EOL> class HtmlFileTransport ( streamingbase . StreamingTransportBase ) : <EOL> name = '<STR_LIT>' <EOL> def initialize ( self , server ) : <EOL> super ( HtmlFileTransport , self ) . initialize ( server ) <EOL> @ asynchronous <EOL> def get ( self , session_id ) : <EOL> self . preflight ( ) <EOL> self . handle_session_cookie ( ) <EOL> self . disable_cache ( ) <EOL> self . set_header ( '<STR_LIT:Content-Type>' , '<STR_LIT>' ) <EOL> callback = self . get_argument ( '<STR_LIT:c>' , None ) <EOL> if not callback : <EOL> self . write ( '<STR_LIT>' ) <EOL> self . set_status ( <NUM_LIT> ) <EOL> self . finish ( ) <EOL> return <EOL> self . write ( HTMLFILE_HEAD % callback ) <EOL> self . flush ( ) <EOL> if not self . _attach_session ( session_id ) : <EOL> self . finish ( ) <EOL> return <EOL> if self . session : <EOL> self . session . flush ( ) <EOL> def send_pack ( self , message , binary = False ) : <EOL> if binary : <EOL> raise Exception ( '<STR_LIT>' ) <EOL> msg = '<STR_LIT>' % proto . json_encode ( message ) <EOL> self . active = False <EOL> try : <EOL> self . notify_sent ( len ( message ) ) <EOL> self . write ( msg ) <EOL> self . flush ( callback = self . send_complete ) <EOL> except IOError : <EOL> self . session . delayed_close ( ) <EOL> self . _detach ( ) </s>
