public static async Task ResponseHeaders_ContainsHeadersAfterOperation() { var wc = new DerivedWebClient(); // verify we can use a derived type as well Assert.Null(wc.ResponseHeaders); await LoopbackServer.CreateServerAsync(async (server, url) => { Task<string> download = wc.DownloadStringTaskAsync(url.ToString()); Assert.Null(wc.ResponseHeaders); await server.AcceptConnectionSendResponseAndCloseAsync(additionalHeaders: "ArbitraryHeader: ArbitraryValue\r\n"); await download; }); Assert.NotNull(wc.ResponseHeaders); Assert.Equal("ArbitraryValue", wc.ResponseHeaders["ArbitraryHeader"]); }
public static async Task ResponseHeaders_ContainsHeadersAfterOperation() { var wc = new DerivedWebClient(); // verify we can use a derived type as well Assert.Null(wc.ResponseHeaders); await LoopbackServer.CreateServerAsync(async (server, url) => { Task <string> download = wc.DownloadStringTaskAsync(url.ToString()); Assert.Null(wc.ResponseHeaders); await LoopbackServer.ReadRequestAndSendResponseAsync(server, "HTTP/1.1 200 OK\r\n" + $"Date: {DateTimeOffset.UtcNow:R}\r\n" + $"Content-Length: 0\r\n" + "ArbitraryHeader: ArbitraryValue\r\n" + "\r\n"); await download; }); Assert.NotNull(wc.ResponseHeaders); Assert.Equal("ArbitraryValue", wc.ResponseHeaders["ArbitraryHeader"]); }
public static async Task ResponseHeaders_ContainsHeadersAfterOperation() { var wc = new DerivedWebClient(); // verify we can use a derived type as well Assert.Null(wc.ResponseHeaders); await LoopbackServer.CreateServerAsync(async (server, url) => { Task<string> download = wc.DownloadStringTaskAsync(url.ToString()); Assert.Null(wc.ResponseHeaders); await LoopbackServer.ReadRequestAndSendResponseAsync(server, "HTTP/1.1 200 OK\r\n" + $"Date: {DateTimeOffset.UtcNow:R}\r\n" + $"Content-Length: 0\r\n" + "ArbitraryHeader: ArbitraryValue\r\n" + "\r\n"); await download; }); Assert.NotNull(wc.ResponseHeaders); Assert.Equal("ArbitraryValue", wc.ResponseHeaders["ArbitraryHeader"]); }