#NEWLINE# def test_HTTP11_Timeout_after_request( self ) : #NEWLINE# #INDENT# if ( cherrypy . server . protocol_version != 'HTTP/1.1' ) : #NEWLINE# #INDENT# return self . skip ( ) #NEWLINE# #UNINDENT# self . PROTOCOL = 'HTTP/1.1' #NEWLINE# self . persistent = True #NEWLINE# conn = self . HTTP_CONN #NEWLINE# conn . putrequest ( 'GET' , ( '/timeout?t=%s' % timeout ) , skip_host = True ) #NEWLINE# conn . putheader ( 'Host' , self . HOST ) #NEWLINE# conn . endheaders ( ) #NEWLINE# response = conn . response_class ( conn . sock , method = 'GET' ) #NEWLINE# response . begin ( ) #NEWLINE# self . assertEqual ( response . status , 200 ) #NEWLINE# self . body = response . read ( ) #NEWLINE# self . assertBody ( str ( timeout ) ) #NEWLINE# conn . _output ( ntob ( 'GET /hello HTTP/1.1' ) ) #NEWLINE# conn . _output ( ntob ( ( 'Host: %s' % self . HOST ) , 'ascii' ) ) #NEWLINE# conn . _send_output ( ) #NEWLINE# response = conn . response_class ( conn . sock , method = 'GET' ) #NEWLINE# response . begin ( ) #NEWLINE# self . assertEqual ( response . status , 200 ) #NEWLINE# self . body = response . read ( ) #NEWLINE# self . assertBody ( 'Hello, world!' ) #NEWLINE# time . sleep ( ( timeout * 2 ) ) #NEWLINE# conn . _output ( ntob ( 'GET /hello HTTP/1.1' ) ) #NEWLINE# conn . _output ( ntob ( ( 'Host: %s' % self . HOST ) , 'ascii' ) ) #NEWLINE# conn . _send_output ( ) #NEWLINE# response = conn . response_class ( conn . sock , method = 'GET' ) #NEWLINE# try : #NEWLINE# #INDENT# response . begin ( ) #NEWLINE# #UNINDENT# except : #NEWLINE# #INDENT# if ( not isinstance ( sys . exc_info ( ) [ 1 ] , ( socket . error , BadStatusLine ) ) ) : #NEWLINE# #INDENT# self . fail ( ( "Writing to timed out socket didn't fail as it should have: %s" % sys . exc_info ( ) [ 1 ] ) ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if ( response . status != 408 ) : #NEWLINE# #INDENT# self . fail ( ( "Writing to timed out socket didn't fail as it should have: %s" % response . read ( ) ) ) #NEWLINE# #UNINDENT# #UNINDENT# conn . close ( ) #NEWLINE# self . persistent = True #NEWLINE# conn = self . HTTP_CONN #NEWLINE# conn . putrequest ( 'GET' , '/' , skip_host = True ) #NEWLINE# conn . putheader ( 'Host' , self . HOST ) #NEWLINE# conn . endheaders ( ) #NEWLINE# response = conn . response_class ( conn . sock , method = 'GET' ) #NEWLINE# response . begin ( ) #NEWLINE# self . assertEqual ( response . status , 200 ) #NEWLINE# self . body = response . read ( ) #NEWLINE# self . assertBody ( pov ) #NEWLINE# conn . send ( ntob ( 'GET /hello HTTP/1.1' ) ) #NEWLINE# time . sleep ( ( timeout * 2 ) ) #NEWLINE# response = conn . response_class ( conn . sock , method = 'GET' ) #NEWLINE# try : #NEWLINE# #INDENT# response . begin ( ) #NEWLINE# #UNINDENT# except : #NEWLINE# #INDENT# if ( not isinstance ( sys . exc_info ( ) [ 1 ] , ( socket . error , BadStatusLine ) ) ) : #NEWLINE# #INDENT# self . fail ( ( "Writing to timed out socket didn't fail as it should have: %s" % sys . exc_info ( ) [ 1 ] ) ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# self . fail ( ( "Writing to timed out socket didn't fail as it should have: %s" % response . read ( ) ) ) #NEWLINE# #UNINDENT# conn . close ( ) #NEWLINE# self . persistent = True #NEWLINE# conn = self . HTTP_CONN #NEWLINE# conn . putrequest ( 'GET' , '/' , skip_host = True ) #NEWLINE# conn . putheader ( 'Host' , self . HOST ) #NEWLINE# conn . endheaders ( ) #NEWLINE# response = conn . response_class ( conn . sock , method = 'GET' ) #NEWLINE# response . begin ( ) #NEWLINE# self . assertEqual ( response . status , 200 ) #NEWLINE# self . body = response . read ( ) #NEWLINE# self . assertBody ( pov ) #NEWLINE# conn . close ( )