2using System.Collections.Generic;
3using System.Security.Cryptography.X509Certificates;
4using System.Threading.Tasks;
35 switch (Uri.Scheme.ToLower())
55 public Task<object>
GetAsync(Uri Uri, X509Certificate Certificate,
58 return this.
GetAsync(Uri, Certificate, RemoteCertificateValidator, 60000, Headers);
71 int TimeoutMs, params KeyValuePair<string, string>[] Headers)
73 KeyValuePair<byte[], string> P =
Decode(Uri);
83 public static KeyValuePair<byte[], string>
Decode(Uri Uri)
85 string s = Uri.OriginalString;
86 int i = s.IndexOf(
':');
88 throw new ArgumentException(
"Invalid Data URI.", nameof(Uri));
90 int j = s.IndexOf(
';', i + 1);
92 throw new ArgumentException(
"Content-Type not encoded in Data URI.", nameof(Uri));
94 string ContentType = s.Substring(i + 1, j - i - 1);
96 int k = s.IndexOf(
',', j + 1);
98 throw new ArgumentException(
"Data not encoded in Data URI.", nameof(Uri));
100 byte[] Bin = Convert.FromBase64String(s.Substring(k + 1));
102 return new KeyValuePair<byte[], string>(Bin, ContentType);
113 public Task<KeyValuePair<string, TemporaryStream>>
GetTempStreamAsync(Uri Uri, X509Certificate Certificate,
116 return this.
GetTempStreamAsync(Uri, Certificate, RemoteCertificateValidator, 60000, Headers);
128 public async Task<KeyValuePair<string, TemporaryStream>>
GetTempStreamAsync(Uri Uri, X509Certificate Certificate,
131 KeyValuePair<byte[], string> P =
Decode(Uri);
135 return new KeyValuePair<string, TemporaryStream>(P.Value, f);
159 params KeyValuePair<string, string>[] Headers)
161 return Task.FromResult<
object>(
null);
174 int TimeoutMs, params KeyValuePair<string, string>[] Headers)
176 return Task.FromResult<
object>(
null);
Gets data encoded into data URIs.
static KeyValuePair< byte[], string > Decode(Uri Uri)
Decodes a Data URI.
bool CanGet(Uri Uri, out Grade Grade)
If the getter is able to get a resource, given its URI.
Task< object > HeadAsync(Uri Uri, X509Certificate Certificate, RemoteCertificateEventHandler RemoteCertificateValidator, params KeyValuePair< string, string >[] Headers)
Gets the headers of a resource, using a Uniform Resource Identifier (or Locator).
Task< object > GetAsync(Uri Uri, X509Certificate Certificate, RemoteCertificateEventHandler RemoteCertificateValidator, int TimeoutMs, params KeyValuePair< string, string >[] Headers)
Gets a resource, using a Uniform Resource Identifier (or Locator).
Task< object > HeadAsync(Uri Uri, X509Certificate Certificate, RemoteCertificateEventHandler RemoteCertificateValidator, int TimeoutMs, params KeyValuePair< string, string >[] Headers)
Gets the headers of a resource, using a Uniform Resource Identifier (or Locator).
Task< KeyValuePair< string, TemporaryStream > > GetTempStreamAsync(Uri Uri, X509Certificate Certificate, RemoteCertificateEventHandler RemoteCertificateValidator, params KeyValuePair< string, string >[] Headers)
Gets a (possibly big) resource, using a Uniform Resource Identifier (or Locator).
DataGetter()
Gets data encoded into data URIs.
string[] UriSchemes
Supported URI schemes.
async Task< KeyValuePair< string, TemporaryStream > > GetTempStreamAsync(Uri Uri, X509Certificate Certificate, RemoteCertificateEventHandler RemoteCertificateValidator, int TimeoutMs, params KeyValuePair< string, string >[] Headers)
Gets a (possibly big) resource, using a Uniform Resource Identifier (or Locator).
Task< object > GetAsync(Uri Uri, X509Certificate Certificate, RemoteCertificateEventHandler RemoteCertificateValidator, params KeyValuePair< string, string >[] Headers)
Gets a resource, using a Uniform Resource Identifier (or Locator).
bool CanHead(Uri Uri, out Grade Grade)
If the getter is able to get headers of a resource, given its URI.
Static class managing encoding and decoding of internet content.
static Task< object > 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...
delegate void RemoteCertificateEventHandler(object Sender, RemoteCertificateEventArgs e)
Delegate for remote certificate event handlers.