diff --git a/PocketSharp.Reader/PocketReader.cs b/PocketSharp.Reader/PocketReader.cs
index f70c7f2..eab67a2 100644
--- a/PocketSharp.Reader/PocketReader.cs
+++ b/PocketSharp.Reader/PocketReader.cs
@@ -24,8 +24,11 @@ namespace PocketSharp
///
- /// Initializes a new instance of the class.
+ /// Initializes a new instance of the class.
///
+ /// Custom UserAgent string.
+ /// The HttpMessage handler.
+ /// Request timeout (in seconds).
public PocketReader(string userAgent = null, HttpMessageHandler handler = null, int? timeout = null)
{
// override user agent
@@ -35,22 +38,15 @@ namespace PocketSharp
}
// initialize HTTP client
- if (handler != null)
+ _httpClient = new HttpClient(handler ?? new HttpClientHandler()
{
- _httpClient = new HttpClient(handler);
- }
- else
- {
- _httpClient = new HttpClient(new HttpClientHandler()
- {
- AutomaticDecompression = DecompressionMethods.Deflate | DecompressionMethods.GZip,
- AllowAutoRedirect = true
- });
- }
+ AutomaticDecompression = DecompressionMethods.Deflate | DecompressionMethods.GZip,
+ AllowAutoRedirect = true
+ });
if (timeout.HasValue)
{
- _httpClient.Timeout = TimeSpan.FromSeconds(timeout.Value);
+ _httpClient.Timeout = TimeSpan.FromSeconds(timeout.Value);
}
// add accept types
diff --git a/PocketSharp/PocketClient.cs b/PocketSharp/PocketClient.cs
index e0cc439..1bd619c 100644
--- a/PocketSharp/PocketClient.cs
+++ b/PocketSharp/PocketClient.cs
@@ -84,8 +84,8 @@ namespace PocketSharp
/// The API key
/// Provide an access code if the user is already authenticated
/// The callback URL is called by Pocket after authentication
- /// The http handler.
- /// The timeout (in seconds).
+ /// The HttpMessage handler.
+ /// Request timeout (in seconds).
public PocketClient(string consumerKey, string accessCode = null, string callbackUri = null, HttpMessageHandler handler = null, int? timeout = null)
{
// assign public properties
@@ -104,24 +104,17 @@ namespace PocketSharp
}
// initialize REST client
- if (handler != null)
- {
- _restClient = new HttpClient(handler);
- }
- else
- {
- _restClient = new HttpClient(new HttpClientHandler()
- {
- AutomaticDecompression = DecompressionMethods.Deflate | DecompressionMethods.GZip
- });
- }
+ _restClient = new HttpClient(handler ?? new HttpClientHandler()
+ {
+ AutomaticDecompression = DecompressionMethods.Deflate | DecompressionMethods.GZip
+ });
- if (timeout.HasValue)
- {
- _restClient.Timeout = TimeSpan.FromSeconds(timeout.Value);
- }
+ if (timeout.HasValue)
+ {
+ _restClient.Timeout = TimeSpan.FromSeconds(timeout.Value);
+ }
- // set base uri
+ // set base uri
_restClient.BaseAddress = baseUri;
// Pocket needs this specific Accept header :-S