Exemplo n.º 1
0
 public Void Parse(IHttpWebResponse response)
 {
     using (response)
     {
         ResponseParseUtils.HandleStatusCode(response, HttpStatusCode.NoContent);
         var requestId = response.Headers.GetRequestIdFromHeader();
         Log.Debug($"Request: {requestId}");
         return(new Void());
     }
 }
Exemplo n.º 2
0
        public static T Parse(IHttpWebResponse response, params HttpStatusCode[] expectedStatusCodes)
        {
            using (response)
            {
                ResponseParseUtils.HandleStatusCode(response, expectedStatusCodes);
                using (var stream = response.GetResponseStream())
                    using (var textStreamReader = new StreamReader(stream))
                    {
                        var responseString = textStreamReader.ReadToEnd();

                        var requestId = response.Headers.GetRequestIdFromHeader();
#if DEBUG
                        Log.Debug($"Request: {requestId}\n{responseString.JsonFormat()}");
#else
                        Log.Debug($"Request: {requestId} {response.StatusCode}");
#endif
                        return(JsonConvert.DeserializeObject <T>(responseString));
                    }
            }
        }