2using System.Collections.Generic;
4using System.Security.Cryptography.X509Certificates;
6using System.Threading.Tasks;
35 public override string[]
UriSchemes =>
new string[] { HttpxGetter.HttpxUriScheme };
74 public override async Task<object>
DeleteAsync(Uri Uri, X509Certificate Certificate,
84 if (Proxy.DefaultXmppClient.Disposed || Proxy.ServerlessMessaging.Disposed)
85 throw new InvalidOperationException(
"Service is being shut down.");
97 throw new InvalidOperationException(
"Service is being shut down.");
100 throw new InvalidOperationException(
"No HTTPX Extesion has been registered on the XMPP Client.");
104 if (
string.IsNullOrEmpty(Uri.UserInfo))
105 FullJid = BareJid = Uri.Authority;
108 BareJid = Uri.UserInfo +
"@" + Uri.Authority;
113 throw new ConflictException(
"No approved presence subscription with " + BareJid +
".");
120 LocalUrl = Uri.PathAndQuery + Uri.Fragment;
123 throw new InvalidOperationException(
"An HTTPX Proxy or XMPP Client Module Parameter has not been registered.");
125 List<HttpField> Headers2 =
new List<HttpField>();
126 bool HasHost =
false;
128 foreach (KeyValuePair<string, string> Header
in Headers)
130 switch (Header.Key.ToLower())
133 Headers2.Add(
new HttpField(
"Host", BareJid));
143 Headers2.Add(
new HttpField(Header.Key, Header.Value));
149 Headers2.Add(
new HttpField(
"Host", Uri.Authority));
157 Timer =
new Timer((P) =>
159 State.Done.TrySetResult(
false);
160 },
null, TimeoutMs, Timeout.Infinite);
164 await
HttpxClient.
Request(FullJid,
"DELETE", LocalUrl, 1.1, Headers2,
null, async (Sender, e) =>
168 State.HttpResponse = e.HttpResponse;
169 State.StatusCode = e.StatusCode;
170 State.StatusMessage = e.StatusMessage;
174 if (State.Data is null)
175 State.Data = new MemoryStream();
177 if (!(e.Data is null))
179 await State.Data.WriteAsync(e.Data, 0, e.Data.Length);
180 State.Done.TrySetResult(true);
184 State.Done.TrySetResult(
true);
187 State.Done.TrySetException(e.StanzaError ??
new Exception(
"Unable to get resource."));
189 }, async (Sender, e) =>
191 if (State.Data is
null)
192 State.Data =
new MemoryStream();
194 await State.Data.WriteAsync(e.Data, 0, e.Data.Length);
196 State.Done.TrySetResult(
true);
200 if (!await State.Done.Task)
201 throw new TimeoutException(
"Request timed out.");
206 if (State.StatusCode >= 200 && State.StatusCode < 300)
207 return new KeyValuePair<byte[], string>(State.Data?.ToArray(), State.HttpResponse?.ContentType);
210 string ContentType =
string.Empty;
211 byte[] EncodedData = State.Data?.ToArray();
213 throw HttpxGetter.GetExceptionObject(State.StatusCode, State.StatusMessage,
214 State.HttpResponse, EncodedData, ContentType);
219 State.Data?.Dispose();
222 if (!(State.HttpResponse is
null))
224 await State.HttpResponse.DisposeAsync();
225 State.HttpResponse =
null;
236 public MemoryStream Data =
null;
237 public TaskCompletionSource<bool> Done =
new TaskCompletionSource<bool>();
238 public string StatusMessage =
string.Empty;
239 public int StatusCode = 0;
Abstract base class for deleters.
The request could not be completed due to a conflict with the current state of the resource....
Base class for all HTTP fields.
Represets a response of an HTTP client request.
The server is currently unable to handle the request due to a temporary overloading or maintenance of...
Response to the HttpxProxy.GetClientAsync(Uri) method call.
string BareJid
Bare JID of entity hosting the resource.
HttpxClient HttpxClient
Corresponding HttpxClient object to use for the request..
string FullJid
Full JID of entity hosting the resource.
string LocalUrl
Local part of the URL
Task Request(string To, string Method, string LocalResource, EventHandlerAsync< HttpxResponseEventArgs > Callback, EventHandlerAsync< HttpxResponseDataEventArgs > DataCallback, object State, params HttpField[] Headers)
Performs an HTTP request.
Content Deleter, deleting content using the HTTPX URI Scheme.
override string[] UriSchemes
Supported URI schemes.
override async Task< object > DeleteAsync(Uri Uri, X509Certificate Certificate, RemoteCertificateEventHandler RemoteCertificateValidator, int TimeoutMs, params KeyValuePair< string, string >[] Headers)
Deletes a resource, using a Uniform Resource Identifier (or Locator).
HttpxDeleter()
Content Deleter, deleting content using the HTTPX URI Scheme.
override bool CanDelete(Uri Uri, out Grade Grade)
If the deleter is able to delete to a resource, given its URI.
Content Getter, retrieving content using the HTTPX URI Scheme.
const string HttpxUriScheme
httpx
Implements a Proxy resource that allows Web clients to fetch HTTP-based resources over HTTPX.
Maintains information about an item in the roster.
bool HasLastPresence
If the roster item has received presence from an online resource having the given bare JID.
string LastPresenceFullJid
Full JID of last resource sending online presence.
PresenceEventArgs LastPresence
Last presence received from a resource having this bare JID.
Manages an XMPP client connection. Implements XMPP, as defined in https://tools.ietf....
bool Disposed
If the client has been disposed.
bool TryGetExtension(Type Type, out IXmppExtension Extension)
Tries to get a registered extension of a specific type from the client.
RosterItem GetRosterItem(string BareJID)
Gets a roster item.
Static class that dynamically manages types and interfaces available in the runtime environment.
static bool TryGetModuleParameter(string Name, out object Value)
Tries to get a module parameter value.
delegate void RemoteCertificateEventHandler(object Sender, RemoteCertificateEventArgs e)
Delegate for remote certificate event handlers.