diff --git a/ReadSharp/IReader.cs b/ReadSharp/IReader.cs
index 8ef5502..1ce74d3 100644
--- a/ReadSharp/IReader.cs
+++ b/ReadSharp/IReader.cs
@@ -1,4 +1,5 @@
using System;
+using System.Threading;
using System.Threading.Tasks;
namespace ReadSharp
@@ -10,10 +11,13 @@ namespace ReadSharp
///
/// An URI to extract the content from.
/// The transform options.
+ /// The cancellation token.
///
/// An article with extracted content and meta information.
///
///
- Task Read(Uri uri, ReadOptions options = null);
+ ///
+ ///
+ Task Read(Uri uri, ReadOptions options = null, CancellationToken cancellationToken = default(CancellationToken));
}
}
\ No newline at end of file
diff --git a/ReadSharp/Reader.cs b/ReadSharp/Reader.cs
index fb2a21a..b2b17b9 100644
--- a/ReadSharp/Reader.cs
+++ b/ReadSharp/Reader.cs
@@ -7,6 +7,7 @@ using System.Net;
using System.Net.Http;
using System.Reflection;
using System.Text;
+using System.Threading;
using System.Threading.Tasks;
using System.Xml.Linq;
@@ -99,11 +100,14 @@ namespace ReadSharp
///
/// An URI to extract the content from.
/// The transform options.
+ /// The cancellation token.
///
/// An article with extracted content and meta information.
///
///
- public async Task Read(Uri uri, ReadOptions options = null)
+ ///
+ ///
+ public async Task Read(Uri uri, ReadOptions options = null, CancellationToken cancellationToken = default(CancellationToken))
{
Response response;
TranscodingResult transcodingResult;
@@ -118,7 +122,7 @@ namespace ReadSharp
try
{
// get HTML string from URI
- response = await Request(uri);
+ response = await Request(uri, cancellationToken);
}
catch (HttpRequestException exc)
{
@@ -267,8 +271,11 @@ namespace ReadSharp
/// Fetches a resource
///
/// The URI.
+ /// The cancellation token.
///
- private async Task Request(Uri uri)
+ ///
+ ///
+ private async Task Request(Uri uri, CancellationToken cancellationToken)
{
HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, uri);
HttpResponseMessage response = null;
@@ -276,7 +283,7 @@ namespace ReadSharp
// make async request
try
{
- response = await _httpClient.SendAsync(request);
+ response = await _httpClient.SendAsync(request, cancellationToken);
}
catch (HttpRequestException exc)
{