#NEWLINE# def test_basic_http11_parsing( self ) : #NEWLINE# #INDENT# data = b'HTTP/1.1 200 OK\r\nServer: h2o\r\ncontent-length: 2\r\nVary: accept-encoding\r\n\r\nhi' #NEWLINE# m = memoryview ( data ) #NEWLINE# c = Parser ( ) #NEWLINE# r = c . parse_response ( m ) #NEWLINE# assert r #NEWLINE# assert ( m . status == 200 ) #NEWLINE# assert ( r . msg . tobytes ( ) == b'OK' ) #NEWLINE# assert ( r . minor_version == 1 ) #NEWLINE# expected_headers = [ ( b'Server' , b'h2o' ) , ( b'content-length' , b'2' ) , ( b'Vary' , b'accept-encoding' ) ] #NEWLINE# assert ( len ( expected_headers ) == len ( r . headers ) ) #NEWLINE# for ( ( n1 , v1 ) , ( n2 , v2 ) ) in zip ( r . headers , expected_headers ) : #NEWLINE# #INDENT# assert ( n1 . tobytes ( ) == n2 ) #NEWLINE# assert ( v1 . tobytes ( ) == v2 ) #NEWLINE# #UNINDENT# assert ( r . consumed == ( len ( data ) - 2 ) )