2using System.Collections.Generic;
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<KeyValuePair<byte[], string>>
PostAsync(Uri Uri,
byte[] EncodedData,
string ContentType,
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 Method = HttpMethod.Post,
76 Content =
new ByteArrayContent(EncodedData),
79 Request.Content.Headers.ContentType = MediaTypeHeaderValue.Parse(ContentType);
80 WebGetter.PrepareHeaders(Request, Headers, Handler);
82 HttpResponseMessage Response = await HttpClient.SendAsync(Request);
97 public static async Task<KeyValuePair<byte[], string>>
ProcessResponse(HttpResponseMessage Response, Uri Uri)
99 if (!Response.IsSuccessStatusCode)
102 byte[] Bin = await Response.Content.ReadAsByteArrayAsync();
105 return new KeyValuePair<byte[], string>(Bin, ContentType);
const string DefaultContentType
text/plain
Gets resources from the Web (i.e. using HTTP or HTTPS).
static HttpClientHandler GetClientHandler()
Gets a HTTP Client handler
static async Task< object > 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 posters.
Posts to resources on the Web (i.e. using HTTP or HTTPS).
WebPoster()
Posts to resources on the Web (i.e. using HTTP or HTTPS).
static async Task< KeyValuePair< byte[], string > > ProcessResponse(HttpResponseMessage Response, Uri Uri)
Decodes a response from the web. If the response is a success, the decoded response is returned....
override string[] UriSchemes
Supported URI schemes.
override bool CanPost(Uri Uri, out Grade Grade)
If the poster is able to post to a resource, given its URI.
override async Task< KeyValuePair< byte[], string > > PostAsync(Uri Uri, byte[] EncodedData, string ContentType, X509Certificate Certificate, RemoteCertificateEventHandler RemoteCertificateValidator, int TimeoutMs, params KeyValuePair< string, string >[] Headers)
Posts to a resource, using a Uniform Resource Identifier (or Locator).
delegate void RemoteCertificateEventHandler(object Sender, RemoteCertificateEventArgs e)
Delegate for remote certificate event handlers.