3using System.Security.Cryptography.X509Certificates;
4using System.Threading.Tasks;
35 switch (Uri.Scheme.ToLower())
55 public Task<ContentResponse>
GetAsync(Uri Uri, X509Certificate Certificate,
56 EventHandler<RemoteCertificateEventArgs> RemoteCertificateValidator, params KeyValuePair<string, string>[] Headers)
70 public Task<ContentResponse>
GetAsync(Uri Uri, X509Certificate Certificate, EventHandler<RemoteCertificateEventArgs> RemoteCertificateValidator,
71 int TimeoutMs, params KeyValuePair<string, string>[] Headers)
88 string s = Uri.OriginalString;
89 int i = s.IndexOf(
':');
93 int j = s.IndexOf(
';', i + 1);
95 return new ContentBinaryResponse(
new ArgumentException(
"Content-Type not encoded in Data URI.", nameof(Uri)));
97 string ContentType = s.Substring(i + 1, j - i - 1);
99 int k = s.IndexOf(
',', j + 1);
101 return new ContentBinaryResponse(
new ArgumentException(
"Data not encoded in Data URI.", nameof(Uri)));
103 byte[] Bin = Convert.FromBase64String(s.Substring(k + 1));
117 EventHandler<RemoteCertificateEventArgs> RemoteCertificateValidator, params KeyValuePair<string, string>[] Headers)
132 EventHandler<RemoteCertificateEventArgs> RemoteCertificateValidator,
TemporaryStream Destination, params KeyValuePair<string, string>[] Headers)
147 EventHandler<RemoteCertificateEventArgs> RemoteCertificateValidator,
int TimeoutMs, params KeyValuePair<string, string>[] Headers)
149 return this.
GetTempStreamAsync(Uri, Certificate, RemoteCertificateValidator, TimeoutMs,
null, Headers);
163 EventHandler<RemoteCertificateEventArgs> RemoteCertificateValidator,
int TimeoutMs,
TemporaryStream Destination,
164 params KeyValuePair<string, string>[] Headers)
170 if (Destination is
null)
198 public Task<ContentResponse>
HeadAsync(Uri Uri, X509Certificate Certificate, EventHandler<RemoteCertificateEventArgs> RemoteCertificateValidator,
199 params KeyValuePair<string, string>[] Headers)
217 public Task<ContentResponse>
HeadAsync(Uri Uri, X509Certificate Certificate, EventHandler<RemoteCertificateEventArgs> RemoteCertificateValidator,
218 int TimeoutMs, params KeyValuePair<string, string>[] Headers)
220 return this.
HeadAsync(Uri, Certificate, RemoteCertificateValidator, Headers);
Contains information about a binary response to a content request.
bool HasError
If an error occurred.
string ContentType
Internet Content-Type of encoded object.
Exception Error
Error response.
byte[] Encoded
Encoded object.
Contains information about a response to a content request.
Contains information about a stream response to a content request.
Gets data encoded into data URIs.
bool CanGet(Uri Uri, out Grade Grade)
If the getter is able to get a resource, given its URI.
DataGetter()
Gets data encoded into data URIs.
string[] UriSchemes
Supported URI schemes.
Task< ContentResponse > GetAsync(Uri Uri, X509Certificate Certificate, EventHandler< RemoteCertificateEventArgs > RemoteCertificateValidator, params KeyValuePair< string, string >[] Headers)
Gets a resource, using a Uniform Resource Identifier (or Locator).
async Task< ContentStreamResponse > GetTempStreamAsync(Uri Uri, X509Certificate Certificate, EventHandler< RemoteCertificateEventArgs > RemoteCertificateValidator, int TimeoutMs, TemporaryStream Destination, params KeyValuePair< string, string >[] Headers)
Gets a (possibly big) resource, using a Uniform Resource Identifier (or Locator).
Task< ContentStreamResponse > GetTempStreamAsync(Uri Uri, X509Certificate Certificate, EventHandler< RemoteCertificateEventArgs > RemoteCertificateValidator, int TimeoutMs, params KeyValuePair< string, string >[] Headers)
Gets a (possibly big) resource, using a Uniform Resource Identifier (or Locator).
Task< ContentResponse > HeadAsync(Uri Uri, X509Certificate Certificate, EventHandler< RemoteCertificateEventArgs > RemoteCertificateValidator, params KeyValuePair< string, string >[] Headers)
Gets the headers of a resource, using a Uniform Resource Identifier (or Locator).
Task< ContentStreamResponse > GetTempStreamAsync(Uri Uri, X509Certificate Certificate, EventHandler< RemoteCertificateEventArgs > RemoteCertificateValidator, TemporaryStream Destination, params KeyValuePair< string, string >[] Headers)
Gets a (possibly big) resource, using a Uniform Resource Identifier (or Locator).
static ContentBinaryResponse Decode(Uri Uri)
Decodes a Data URI.
bool CanHead(Uri Uri, out Grade Grade)
If the getter is able to get headers of a resource, given its URI.
Task< ContentResponse > GetAsync(Uri Uri, X509Certificate Certificate, EventHandler< RemoteCertificateEventArgs > RemoteCertificateValidator, int TimeoutMs, params KeyValuePair< string, string >[] Headers)
Gets a resource, using a Uniform Resource Identifier (or Locator).
Task< ContentStreamResponse > GetTempStreamAsync(Uri Uri, X509Certificate Certificate, EventHandler< RemoteCertificateEventArgs > RemoteCertificateValidator, params KeyValuePair< string, string >[] Headers)
Gets a (possibly big) resource, using a Uniform Resource Identifier (or Locator).
Task< ContentResponse > HeadAsync(Uri Uri, X509Certificate Certificate, EventHandler< RemoteCertificateEventArgs > RemoteCertificateValidator, int TimeoutMs, params KeyValuePair< string, string >[] Headers)
Gets the headers of a resource, using a Uniform Resource Identifier (or Locator).
Static class managing encoding and decoding of internet content.
static int DefaultTimeout
Default timeout of internet access methods, in milliseconds.
static Task< ContentResponse > DecodeAsync(string ContentType, byte[] Data, Encoding Encoding, KeyValuePair< string, string >[] Fields, Uri BaseUri)
Decodes an object.
Manages a temporary stream. Contents is kept in-memory, if below a memory threshold,...
override async Task WriteAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken)
Asynchronously writes a sequence of bytes to the current stream, advances the current position within...
Basic interface for Internet Content getters. A class implementing this interface and having a defaul...