protected async Task <Tuple <HttpStatusCode, string, T> > GetResponseTask <T>(WebRequest request, CancellationToken cancellationToken) where T : class { var response = await request.GetResponseAsync(cancellationToken); var location = response.Headers["Location"]; var statusCode = (response as HttpWebResponse).Maybe(_ => _.StatusCode); if (ApiRequestHelper.IsGZipped((HttpWebResponse)response)) { var entityCompressed = ExtractJSonCompressedEntity <T>(response); return(new Tuple <HttpStatusCode, string, T>(statusCode, location, entityCompressed)); } var entityNormal = ExtractJSonEntity <T>(response); return(new Tuple <HttpStatusCode, string, T>(statusCode, location, entityNormal)); }
private T ExtractDetails <T>(HttpWebResponse response, out string location, out HttpStatusCode statusCode) where T : class { location = response.Headers["Location"]; statusCode = response.Maybe(_ => _.StatusCode); var entity = ApiRequestHelper.IsGZipped(response) ? ExtractJSonCompressedEntity <T>(response) : ExtractJSonEntity <T>(response); if (entity is IETagSupport) { (entity as IETagSupport).ETag = (response.Headers["ETag"] ?? string.Empty); } return(entity); }