diff --git a/PocketSharp.Examples/PocketSharp.Silverlight/PocketSharp.Silverlight.csproj b/PocketSharp.Examples/PocketSharp.Silverlight/PocketSharp.Silverlight.csproj
index ca56cb5..6c2348c 100644
--- a/PocketSharp.Examples/PocketSharp.Silverlight/PocketSharp.Silverlight.csproj
+++ b/PocketSharp.Examples/PocketSharp.Silverlight/PocketSharp.Silverlight.csproj
@@ -78,6 +78,17 @@
False
..\..\packages\Microsoft.Bcl.1.1.3\lib\sl5\System.IO.dll
+
+ False
+ ..\..\packages\Microsoft.Net.Http.2.2.18\lib\portable-net40+sl4+win8+wp71\System.Net.Http.dll
+
+
+ ..\..\packages\Microsoft.Net.Http.2.2.18\lib\portable-net40+sl4+win8+wp71\System.Net.Http.Extensions.dll
+
+
+ False
+ ..\..\packages\Microsoft.Net.Http.2.2.18\lib\portable-net40+sl4+win8+wp71\System.Net.Http.Primitives.dll
+
False
..\..\packages\Microsoft.Bcl.1.1.3\lib\sl5\System.Runtime.dll
diff --git a/PocketSharp.Examples/PocketSharp.Silverlight/packages.config b/PocketSharp.Examples/PocketSharp.Silverlight/packages.config
index 60ba07f..04cf144 100644
--- a/PocketSharp.Examples/PocketSharp.Silverlight/packages.config
+++ b/PocketSharp.Examples/PocketSharp.Silverlight/packages.config
@@ -3,4 +3,5 @@
+
\ No newline at end of file
diff --git a/PocketSharp.Examples/PocketSharp.WP8/PocketSharp.WP8.csproj b/PocketSharp.Examples/PocketSharp.WP8/PocketSharp.WP8.csproj
index c48ea9a..aa8d6e2 100644
--- a/PocketSharp.Examples/PocketSharp.WP8/PocketSharp.WP8.csproj
+++ b/PocketSharp.Examples/PocketSharp.WP8/PocketSharp.WP8.csproj
@@ -130,6 +130,7 @@
+
Designer
@@ -178,6 +179,17 @@
..\..\packages\Microsoft.Bcl.Async.1.0.16\lib\wp8\Microsoft.Threading.Tasks.Extensions.Phone.dll
+
+ False
+ ..\..\packages\Microsoft.Net.Http.2.2.18\lib\sl4-windowsphone71\System.Net.Http.dll
+
+
+ ..\..\packages\Microsoft.Net.Http.2.2.18\lib\sl4-windowsphone71\System.Net.Http.Extensions.dll
+
+
+ False
+ ..\..\packages\Microsoft.Net.Http.2.2.18\lib\sl4-windowsphone71\System.Net.Http.Primitives.dll
+
@@ -196,4 +208,9 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/PocketSharp.Examples/PocketSharp.WP8/packages.config b/PocketSharp.Examples/PocketSharp.WP8/packages.config
new file mode 100644
index 0000000..5646a1a
--- /dev/null
+++ b/PocketSharp.Examples/PocketSharp.WP8/packages.config
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/PocketSharp.Reader/PocketReader.cs b/PocketSharp.Reader/PocketReader.cs
index 0944895..f70c7f2 100644
--- a/PocketSharp.Reader/PocketReader.cs
+++ b/PocketSharp.Reader/PocketReader.cs
@@ -26,7 +26,7 @@ namespace PocketSharp
///
/// Initializes a new instance of the class.
///
- public PocketReader(string userAgent = null)
+ public PocketReader(string userAgent = null, HttpMessageHandler handler = null, int? timeout = null)
{
// override user agent
if (!string.IsNullOrEmpty(userAgent))
@@ -35,11 +35,23 @@ namespace PocketSharp
}
// initialize HTTP client
- _httpClient = new HttpClient(new HttpClientHandler()
+ if (handler != null)
{
- AutomaticDecompression = DecompressionMethods.Deflate | DecompressionMethods.GZip,
- AllowAutoRedirect = true
- });
+ _httpClient = new HttpClient(handler);
+ }
+ else
+ {
+ _httpClient = new HttpClient(new HttpClientHandler()
+ {
+ AutomaticDecompression = DecompressionMethods.Deflate | DecompressionMethods.GZip,
+ AllowAutoRedirect = true
+ });
+ }
+
+ if (timeout.HasValue)
+ {
+ _httpClient.Timeout = TimeSpan.FromSeconds(timeout.Value);
+ }
// add accept types
_httpClient.DefaultRequestHeaders.TryAddWithoutValidation("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8");
@@ -61,8 +73,9 @@ namespace PocketSharp
/// An URI.
/// if set to true [only body is returned].
/// if set to true [no headline (h1) is included].
- /// A Pocket article with extracted content and title.
- ///
+ ///
+ /// A Pocket article with extracted content and title.
+ ///
public async Task Read(Uri uri, bool bodyOnly = true, bool noHeadline = false)
{
return await Read(new PocketItem()
diff --git a/PocketSharp/PocketClient.cs b/PocketSharp/PocketClient.cs
index a05a2b5..e0cc439 100644
--- a/PocketSharp/PocketClient.cs
+++ b/PocketSharp/PocketClient.cs
@@ -79,12 +79,14 @@ namespace PocketSharp
///
- /// Initializes a new instance of the class.
+ /// Initializes a new instance of the class.
///
/// The API key
/// Provide an access code if the user is already authenticated
/// The callback URL is called by Pocket after authentication
- public PocketClient(string consumerKey, string accessCode = null, string callbackUri = null)
+ /// The http handler.
+ /// The timeout (in seconds).
+ public PocketClient(string consumerKey, string accessCode = null, string callbackUri = null, HttpMessageHandler handler = null, int? timeout = null)
{
// assign public properties
ConsumerKey = consumerKey;
@@ -102,12 +104,24 @@ namespace PocketSharp
}
// initialize REST client
- _restClient = new HttpClient(new HttpClientHandler()
- {
- AutomaticDecompression = DecompressionMethods.Deflate | DecompressionMethods.GZip
- });
+ if (handler != null)
+ {
+ _restClient = new HttpClient(handler);
+ }
+ else
+ {
+ _restClient = new HttpClient(new HttpClientHandler()
+ {
+ AutomaticDecompression = DecompressionMethods.Deflate | DecompressionMethods.GZip
+ });
+ }
- // set base uri
+ if (timeout.HasValue)
+ {
+ _restClient.Timeout = TimeSpan.FromSeconds(timeout.Value);
+ }
+
+ // set base uri
_restClient.BaseAddress = baseUri;
// Pocket needs this specific Accept header :-S
@@ -123,6 +137,7 @@ namespace PocketSharp
///
///
/// Requested method (path after /v3/)
+ /// The cancellation token.
/// Additional POST parameters
/// if set to true [require auth].
///