4using System.Net.Http.Headers;
5using System.Security.Cryptography.X509Certificates;
6using System.Threading.Tasks;
28 public override string[]
UriSchemes =>
new string[] {
"http",
"https" };
38 switch (Uri.Scheme.ToLower())
62 public override async Task<ContentBinaryResponse>
QueryAsync(Uri Uri,
byte[] EncodedData,
string ContentType,
63 X509Certificate Certificate, EventHandler<RemoteCertificateEventArgs> RemoteCertificateValidator,
int TimeoutMs,
64 params KeyValuePair<string, string>[] Headers)
67 using (HttpClient HttpClient =
new HttpClient(Handler,
true)
69 Timeout = TimeSpan.FromMilliseconds(TimeoutMs)
72 using (HttpRequestMessage Request =
new HttpRequestMessage()
75 Content =
new ByteArrayContent(EncodedData)
79 Request.Content.Headers.ContentType = MediaTypeHeaderValue.Parse(ContentType);
82 HttpResponseMessage Response = await HttpClient.SendAsync(Request);
89 private static readonly HttpMethod queryMethod =
new HttpMethod(
"QUERY");
Gets resources from the Web (i.e. using HTTP or HTTPS).
static void PrepareHeaders(HttpRequestMessage Request, KeyValuePair< string, string >[] Headers, HttpClientHandler Handler)
Prepares headers for a HTTP request.
static HttpClientHandler GetClientHandler()
Gets a HTTP Client handler
static Uri CheckUri(Uri Uri, HttpRequestMessage Request)
Checks the URI, if it is suitable for processing, or if it needs to be modified.
Posts to resources on the Web (i.e. using HTTP or HTTPS).
static async Task< ContentBinaryResponse > ProcessResponse(HttpResponseMessage Response, Uri Uri)
Decodes a response from the web. If the response is a success, the decoded response is returned....
Abstract base class for query handlers.
Queries resources on the Web (i.e. using HTTP or HTTPS).
override async Task< ContentBinaryResponse > QueryAsync(Uri Uri, byte[] EncodedData, string ContentType, X509Certificate Certificate, EventHandler< RemoteCertificateEventArgs > RemoteCertificateValidator, int TimeoutMs, params KeyValuePair< string, string >[] Headers)
Queries a resource, using a Uniform Resource Identifier (or Locator).
override string[] UriSchemes
Supported URI schemes.
WebQuery()
Queries resources on the Web (i.e. using HTTP or HTTPS).
override bool CanQuery(Uri Uri, out Grade Grade)
If the query handler is able to query a resource, given its URI.