partial void ProcessResponse(System.Net.Http.HttpClient client, System.Net.Http.HttpResponseMessage response) { var status_ = ((int)response.StatusCode).ToString(); if (status_ != "200" && status_ != "204") { var responseData_ = response.Content == null ? null : response.Content.ReadAsStringAsync().GetAwaiter().GetResult(); var typedBody = AbpJson.ToJson <AjaxResponseBase>(responseData_, JsonSerializerSettings); } }
protected override async System.Threading.Tasks.Task <ObjectResponseResult <T> > ReadObjectResponseAsync <T>(System.Net.Http.HttpResponseMessage response, System.Collections.Generic.IReadOnlyDictionary <string, System.Collections.Generic.IEnumerable <string> > headers) { if (response == null || response.Content == null) { return(new ObjectResponseResult <T>(default(T), string.Empty)); } if (ReadResponseAsString) { var responseText = await response.Content.ReadAsStringAsync().ConfigureAwait(false); try { var typedBody = AbpJson.ToJson <T>(responseText, JsonSerializerSettings); return(new ObjectResponseResult <T>(typedBody, responseText)); } catch (Newtonsoft.Json.JsonException exception) { var message = "Could not deserialize the response body string as " + typeof(T).FullName + "."; throw new ApiException(message, (int)response.StatusCode, responseText, headers, exception); } } else { try { using (var responseStream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false)) using (var streamReader = new System.IO.StreamReader(responseStream)) using (var jsonTextReader = new Newtonsoft.Json.JsonTextReader(streamReader)) { var typedBody = AbpJson.ToJson <T>(jsonTextReader, JsonSerializerSettings); return(new ObjectResponseResult <T>(typedBody, string.Empty)); } } catch (Newtonsoft.Json.JsonException exception) { var message = "Could not deserialize the response body stream as " + typeof(T).FullName + "."; throw new ApiException(message, (int)response.StatusCode, string.Empty, headers, exception); } } }