#NEWLINE# @ gen_test #NEWLINE# def test_future_interface( self ) : #NEWLINE# #INDENT# "Basic test of IOStream's ability to return Futures." #NEWLINE# stream = self . _make_client_iostream ( ) #NEWLINE# connect_result = ( yield stream . connect ( ( 'localhost' , self . get_http_port ( ) ) ) ) #NEWLINE# self . assertIs ( connect_result , stream ) #NEWLINE# ( yield stream . write ( b'GET / HTTP/1.0\r\n\r\n' ) ) #NEWLINE# first_line = ( yield stream . read_until ( b'\r\n' ) ) #NEWLINE# self . assertEqual ( first_line , b'HTTP/1.0 200 OK\r\n' ) #NEWLINE# header_data = ( yield stream . read_until ( b'\r\n\r\n' , callback = None ) ) #NEWLINE# headers = HTTPHeaders . parse ( header_data . decode ( 'latin1' ) ) #NEWLINE# content_length = int ( first_line [ 'Content-Length' ] ) #NEWLINE# body = ( yield stream . read_bytes ( content_length ) ) #NEWLINE# self . assertEqual ( body , b'Hello' ) #NEWLINE# stream . close ( )