diff --git a/PocketSharp/Components/Get.cs b/PocketSharp/Components/Get.cs index ec497f0..8e049a2 100644 --- a/PocketSharp/Components/Get.cs +++ b/PocketSharp/Components/Get.cs @@ -58,7 +58,7 @@ namespace PocketSharp Offset = offset }; - return (await Request("get", cancellationToken, parameters.Convert())).Items; + return (await Request("get", cancellationToken, parameters.Convert())).Items ?? new List(); } diff --git a/PocketSharp/PocketClient.cs b/PocketSharp/PocketClient.cs index 5283cc9..6485c18 100644 --- a/PocketSharp/PocketClient.cs +++ b/PocketSharp/PocketClient.cs @@ -52,6 +52,11 @@ namespace PocketSharp /// protected bool isMobileClient = true; + /// + /// Indicates, whether the last HTTP response is cached + /// + protected bool cacheHTTPResponseData; + /// /// callback URLi for API calls /// @@ -104,6 +109,7 @@ namespace PocketSharp /// Request timeout (in seconds). /// Indicates, whether this client is used for mobile or desktop /// Enables the wrapper for the private Text Parser API + /// Caches the last HTTP response in public properties public PocketClient( string consumerKey, string accessCode = null, @@ -111,12 +117,14 @@ namespace PocketSharp HttpMessageHandler handler = null, int? timeout = null, bool isMobileClient = true, - Uri parserUri = null) + Uri parserUri = null, + bool cacheHTTPResponseData = true) { // assign public properties ConsumerKey = consumerKey; this.isMobileClient = isMobileClient; + this.cacheHTTPResponseData = cacheHTTPResponseData; // assign access code if submitted if (accessCode != null) @@ -244,7 +252,10 @@ namespace PocketSharp ValidateResponse(response); // cache headers - lastHeaders = response.Headers; + if (cacheHTTPResponseData) + { + lastHeaders = response.Headers; + } // read response responseString = await response.Content.ReadAsStringAsync(); @@ -268,7 +279,10 @@ namespace PocketSharp } // cache response - lastResponseData = responseString; + if (cacheHTTPResponseData) + { + lastResponseData = responseString; + } return DeserializeJson(responseString); } diff --git a/PocketSharp/Utilities/JsonExtensions.cs b/PocketSharp/Utilities/JsonExtensions.cs index 6598fdd..0a4e55a 100644 --- a/PocketSharp/Utilities/JsonExtensions.cs +++ b/PocketSharp/Utilities/JsonExtensions.cs @@ -187,7 +187,6 @@ namespace PocketSharp public override object ReadJson(Newtonsoft.Json.JsonReader reader, Type objectType, object existingValue, Newtonsoft.Json.JsonSerializer serializer) { - var jObject = JObject.ReadFrom(reader); var pocketItem = new PocketItem(); serializer.Populate(jObject.CreateReader(), pocketItem);