This commit is contained in:
2013-11-18 22:52:39 +01:00
parent 42693a967e
commit 31c69fb12b
2 changed files with 20 additions and 31 deletions
+9 -13
View File
@@ -24,8 +24,11 @@ namespace PocketSharp
/// <summary>
/// Initializes a new instance of the <see cref="PocketReader"/> class.
/// Initializes a new instance of the <see cref="PocketReader" /> class.
/// </summary>
/// <param name="userAgent">Custom UserAgent string.</param>
/// <param name="handler">The HttpMessage handler.</param>
/// <param name="timeout">Request timeout (in seconds).</param>
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
+11 -18
View File
@@ -84,8 +84,8 @@ namespace PocketSharp
/// <param name="consumerKey">The API key</param>
/// <param name="accessCode">Provide an access code if the user is already authenticated</param>
/// <param name="callbackUri">The callback URL is called by Pocket after authentication</param>
/// <param name="handler">The http handler.</param>
/// <param name="timeout">The timeout (in seconds).</param>
/// <param name="handler">The HttpMessage handler.</param>
/// <param name="timeout">Request timeout (in seconds).</param>
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