4using System.Security.Cryptography.X509Certificates;
6using System.Threading.Tasks;
36 public override string[]
UriSchemes =>
new string[] { HttpxGetter.HttpxUriScheme };
76 public override async Task<ContentResponse>
DeleteAsync(Uri Uri, X509Certificate Certificate,
77 EventHandler<RemoteCertificateEventArgs> RemoteCertificateValidator,
int TimeoutMs, params KeyValuePair<string, string>[] Headers)
86 if (Proxy.DefaultXmppClient.Disposed || Proxy.ServerlessMessaging.Disposed)
87 return new ContentResponse(
new InvalidOperationException(
"Service is being shut down."));
99 return new ContentResponse(
new InvalidOperationException(
"Service is being shut down."));
102 return new ContentResponse(
new InvalidOperationException(
"No HTTPX Extesion has been registered on the XMPP Client."));
106 if (
string.IsNullOrEmpty(Uri.UserInfo))
107 FullJid = BareJid = Uri.Authority;
110 BareJid = Uri.UserInfo +
"@" + Uri.Authority;
122 LocalUrl = Uri.PathAndQuery + Uri.Fragment;
125 return new ContentResponse(
new InvalidOperationException(
"An HTTPX Proxy or XMPP Client Module Parameter has not been registered."));
127 List<HttpField> Headers2 =
new List<HttpField>();
128 bool HasHost =
false;
130 foreach (KeyValuePair<string, string> Header
in Headers)
132 switch (Header.Key.ToLower())
135 Headers2.Add(
new HttpField(
"Host", BareJid));
145 Headers2.Add(
new HttpField(Header.Key, Header.Value));
151 Headers2.Add(
new HttpField(
"Host", Uri.Authority));
159 Timer =
new Timer((P) =>
161 State.Done.TrySetResult(
false);
162 },
null, TimeoutMs, Timeout.Infinite);
166 await
HttpxClient.
Request(FullJid,
"DELETE", LocalUrl, 1.1, Headers2,
null, async (Sender, e) =>
170 State.HttpResponse = e.HttpResponse;
171 State.StatusCode = e.StatusCode;
172 State.StatusMessage = e.StatusMessage;
176 State.Data ??= new MemoryStream();
178 if (!(e.Data is null))
180 await State.Data.WriteAsync(e.Data, 0, e.Data.Length);
181 State.Done.TrySetResult(true);
185 State.Done.TrySetResult(
true);
189 State.Done.TrySetException((Exception)e.StanzaError ??
190 new GenericException(
"Unable to delete resource.",
null, Uri.OriginalString));
193 }, async (Sender, e) =>
195 State.Data ??=
new MemoryStream();
197 await State.Data.WriteAsync(e.Data, 0, e.Data.Length);
199 State.Done.TrySetResult(
true);
203 if (!await State.Done.Task)
209 if (State.StatusCode >= 200 && State.StatusCode < 300)
211 byte[] Data = State.Data?.ToArray();
212 return new ContentResponse(State.HttpResponse?.ContentType, Data, Data);
216 string ContentType =
string.Empty;
217 byte[] EncodedData = State.Data?.ToArray();
220 State.HttpResponse, EncodedData, ContentType));
225 State.Data?.Dispose();
228 if (!(State.HttpResponse is
null))
230 await State.HttpResponse.DisposeAsync();
231 State.HttpResponse =
null;
242 public MemoryStream Data =
null;
243 public TaskCompletionSource<bool> Done =
new TaskCompletionSource<bool>();
244 public string StatusMessage =
string.Empty;
245 public int StatusCode = 0;
Contains information about a response to a content request.
Abstract base class for deleters.
Generic exception, with meta-data for logging.
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< ContentResponse > DeleteAsync(Uri Uri, X509Certificate Certificate, EventHandler< RemoteCertificateEventArgs > 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.