public void CanIterateOverResponseTrailers() { var responseTrailers = new HttpResponseTrailers { ContentLength = 9, HeaderETag = "ETag!" }; responseTrailers.Append("Name1", "Value1"); responseTrailers.Append("Name2", "Value2-1"); responseTrailers.Append("Name2", "Value2-2"); responseTrailers.Append("Name3", "Value3"); var e = new Http2HeadersEnumerator(); e.Initialize(responseTrailers); var headers = GetNormalizedHeaders(e); Assert.Equal(new[] { CreateHeaderResult(H2StaticTable.ETag, "ETag", "ETag!"), CreateHeaderResult(-1, "Name1", "Value1"), CreateHeaderResult(-1, "Name2", "Value2-1"), CreateHeaderResult(-1, "Name2", "Value2-2"), CreateHeaderResult(-1, "Name3", "Value3"), }, headers); }
public void Initialize_ChangeHeadersSource_EnumeratorUsesNewSource() { var responseHeaders = new HttpResponseHeaders(); responseHeaders.Append("Name1", "Value1"); responseHeaders.Append("Name2", "Value2-1"); responseHeaders.Append("Name2", "Value2-2"); var e = new Http2HeadersEnumerator(); e.Initialize(responseHeaders); Assert.True(e.MoveNext()); Assert.Equal("Name1", e.Current.Key); Assert.Equal("Value1", e.Current.Value); Assert.Equal(-1, e.HPackStaticTableId); Assert.True(e.MoveNext()); Assert.Equal("Name2", e.Current.Key); Assert.Equal("Value2-1", e.Current.Value); Assert.Equal(-1, e.HPackStaticTableId); Assert.True(e.MoveNext()); Assert.Equal("Name2", e.Current.Key); Assert.Equal("Value2-2", e.Current.Value); Assert.Equal(-1, e.HPackStaticTableId); var responseTrailers = new HttpResponseTrailers { HeaderGrpcStatus = "1" }; responseTrailers.Append("Name1", "Value1"); responseTrailers.Append("Name2", "Value2-1"); responseTrailers.Append("Name2", "Value2-2"); e.Initialize(responseTrailers); Assert.True(e.MoveNext()); Assert.Equal("Grpc-Status", e.Current.Key); Assert.Equal("1", e.Current.Value); Assert.Equal(-1, e.HPackStaticTableId); Assert.True(e.MoveNext()); Assert.Equal("Name1", e.Current.Key); Assert.Equal("Value1", e.Current.Value); Assert.Equal(-1, e.HPackStaticTableId); Assert.True(e.MoveNext()); Assert.Equal("Name2", e.Current.Key); Assert.Equal("Value2-1", e.Current.Value); Assert.Equal(-1, e.HPackStaticTableId); Assert.True(e.MoveNext()); Assert.Equal("Name2", e.Current.Key); Assert.Equal("Value2-2", e.Current.Value); Assert.Equal(-1, e.HPackStaticTableId); Assert.False(e.MoveNext()); }
public void CanIterateOverResponseTrailers() { var responseTrailers = new HttpResponseTrailers { ContentLength = 9, HeaderETag = "ETag!" }; responseTrailers.Append("Name1", "Value1"); responseTrailers.Append("Name2", "Value2-1"); responseTrailers.Append("Name2", "Value2-2"); responseTrailers.Append("Name3", "Value3"); var e = new Http2HeadersEnumerator(); e.Initialize(responseTrailers); var headers = GetNormalizedHeaders(e); Assert.Equal(new[] { new KeyValuePair <string, string>("ETag", "ETag!"), new KeyValuePair <string, string>("Name1", "Value1"), new KeyValuePair <string, string>("Name2", "Value2-1"), new KeyValuePair <string, string>("Name2", "Value2-2"), new KeyValuePair <string, string>("Name3", "Value3"), }, headers); }