private protected static async Task <T> ParseResponse <T>(HttpResponseMessage response, MessageReader <T> reader, CancellationToken token) { var contentType = new ContentType(response.Content.Headers.ContentType.ToString()); var name = ParseHeader <IEnumerable <string> >(MessageNameHeader, response.Headers.TryGetValues); using (var content = await response.Content.ReadAsStreamAsync().ConfigureAwait(false)) using (var message = new InboundMessageContent(content, true, name, contentType)) return(await reader(message, token).ConfigureAwait(false)); }
internal static async Task <TResponse> FromResponseAsync <TResponse>(HttpResponseMessage response, MessageReader <TResponse> reader) { var contentType = new ContentType(response.Content.Headers.ContentType.ToString()); var name = ParseHeader <IEnumerable <string> >(MessageNameHeader, response.Headers.TryGetValues); using (var content = await response.Content.ReadAsStreamAsync().ConfigureAwait(false)) using (var message = new InboundMessageContent(content, true, name, contentType)) return(await reader(message).ConfigureAwait(false)); }