#NEWLINE# def test_receiving_trailers( self ) : #NEWLINE# #INDENT# self . set_up ( ) #NEWLINE# recv_event = threading . Event ( ) #NEWLINE# def socket_handler( listener ) : #NEWLINE# #INDENT# sock = listener . accept ( ) [ 0 ] #NEWLINE# e = Encoder ( ) #NEWLINE# receive_preamble ( sock ) #NEWLINE# sock . recv ( 65535 ) #NEWLINE# f = build_headers_frame ( [ ( ':status' , '200' ) , ( 'content-length' , '14' ) ] , e ) #NEWLINE# f . stream_id = 1 #NEWLINE# sock . send ( f . serialize ( ) ) #NEWLINE# f = DataFrame ( 1 ) #NEWLINE# f . data = b'have some data' #NEWLINE# sock . send ( f . serialize ( ) ) #NEWLINE# f = build_headers_frame ( [ ( 'trialing' , 'no' ) , ( 'trailing' , 'sure' ) ] , e ) #NEWLINE# f . flags . add ( 'END_STREAM' ) #NEWLINE# f . stream_id = 1 #NEWLINE# sock . send ( f . serialize ( ) ) #NEWLINE# recv_event . set ( ) #NEWLINE# sock . close ( ) #NEWLINE# #UNINDENT# self . _start_server ( socket_handler ) #NEWLINE# conn = self . get_connection ( ) #NEWLINE# conn . request ( 'GET' , '/' ) #NEWLINE# resp = conn . get_response ( ) #NEWLINE# assert ( resp . status == 200 ) #NEWLINE# assert ( resp . read ( ) == b'have some data' ) #NEWLINE# assert ( resp . _stream . _in_window_manager . document_size == 14 ) #NEWLINE# assert ( resp . trailers [ 'trailing' ] == [ b'sure' ] ) #NEWLINE# assert ( resp . trailers [ 'trialing' ] == [ b'no' ] ) #NEWLINE# assert ( resp . trailers . get ( ':res' ) is None ) #NEWLINE# assert ( len ( resp . headers ) == 1 ) #NEWLINE# assert ( len ( resp . trailers ) == 2 ) #NEWLINE# recv_event . wait ( 5 ) #NEWLINE# self . tear_down ( )