Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
HttpxProxy.cs
1using System;
3using System.Threading.Tasks;
4using Waher.Content;
5using Waher.Events;
10
12{
19 {
20 private readonly XmppClient defaultXmppClient;
21 private HttpxClient httpxClient;
22 private XmppServerlessMessaging serverlessMessaging;
23 private IHttpxCache httpxCache;
24 private IPostResource postResource = null;
25 private InBandBytestreams.IbbClient ibbClient = null;
26 private P2P.SOCKS5.Socks5Proxy socks5Proxy = null;
27 private bool disposed = false;
28
35 public HttpxProxy(string ResourceName, XmppClient DefaultXmppClient, int MaxChunkSize)
36 : this(ResourceName, DefaultXmppClient, MaxChunkSize, null, null)
37 {
38 }
39
48 : this(ResourceName, DefaultXmppClient, MaxChunkSize, ServerlessMessaging, null)
49 {
50 }
51
62 {
63 this.defaultXmppClient = DefaultXmppClient;
64 this.serverlessMessaging = ServerlessMessaging;
65 this.httpxCache = HttpxCache;
66
67 this.httpxClient = new HttpxClient(this.defaultXmppClient, MaxChunkSize)
68 {
69 PostResource = this.postResource
70 };
71 }
72
76 public void Dispose()
77 {
78 this.httpxClient?.Dispose();
79 this.httpxClient = null;
80 this.disposed = true;
81 }
82
86 public bool Disposed => this.disposed;
87
92 {
93 get => this.postResource;
94 set
95 {
96 this.postResource = value;
97
98 if (!(this.httpxClient is null))
99 this.httpxClient.PostResource = value;
100 }
101 }
102
107 {
108 get => this.serverlessMessaging;
109 set
110 {
111 if (!(this.serverlessMessaging is null) && this.serverlessMessaging != value)
112 throw new Exception("Property already set.");
113
114 this.serverlessMessaging = value;
115 }
116 }
117
122 {
123 get => this.httpxCache;
124 set
125 {
126 if (!(this.httpxCache is null) && this.httpxCache != value)
127 throw new Exception("Property already set.");
128
129 this.httpxCache = value;
130 }
131 }
132
136 public XmppClient DefaultXmppClient => this.defaultXmppClient;
137
141 public HttpxClient DefaultHttpxClient => this.httpxClient;
142
147 {
148 get => this.ibbClient;
149 set
150 {
151 this.ibbClient = value;
152
153 if (!(this.httpxClient is null))
154 this.httpxClient.IbbClient = value;
155 }
156 }
157
162 {
163 get => this.socks5Proxy;
164 set
165 {
166 this.socks5Proxy = value;
167
168 if (!(this.httpxClient is null))
169 this.httpxClient.Socks5Proxy = value;
170 }
171 }
172
176 public override bool HandlesSubPaths
177 {
178 get
179 {
180 return true;
181 }
182 }
183
187 public override bool UserSessions
188 {
189 get
190 {
191 return false;
192 }
193 }
194
195 private async Task Request(string Method, HttpRequest Request, HttpResponse Response)
196 {
197 try
198 {
199 string Url = Request.SubPath;
200 if (Url.StartsWith("/"))
201 Url = Url[1..];
202
203 if (!Url.StartsWith("httpx://", StringComparison.OrdinalIgnoreCase))
204 throw new BadRequestException("Invalid URI. Must use httpx URI scheme.");
205
206 int i = Url.IndexOf('/', 8);
207 if (i < 0)
208 throw new BadRequestException("Invalid URI.");
209
210 string BareJID = Url[8..i];
211 string LocalUrl = Url[i..];
212
213 IHttpxCachedResource CachedResource;
214
215 if (Method == "GET" && !(this.httpxCache is null))
216 {
217 if (!((CachedResource = await this.httpxCache.TryGetCachedResource(BareJID, LocalUrl)) is null))
218 {
219 if (!(Request.Header.IfNoneMatch is null))
220 {
221 if (!(CachedResource.ETag is null) && Request.Header.IfNoneMatch.Value == CachedResource.ETag)
222 {
223 await Response.SendResponse(new NotModifiedException());
224 return;
225 }
226 }
227 else if (!(Request.Header.IfModifiedSince is null))
228 {
229 DateTimeOffset? Limit;
230
231 if ((Limit = Request.Header.IfModifiedSince.Timestamp).HasValue &&
232 HttpFolderResource.LessOrEqual(CachedResource.LastModified.UtcDateTime, Limit.Value.ToUniversalTime()))
233 {
234 await Response.SendResponse(new NotModifiedException());
235 return;
236 }
237 }
238
239 await HttpFolderResource.SendResponse(CachedResource.FileName,
240 CachedResource.ContentType, CachedResource.ETag,
241 CachedResource.LastModified.UtcDateTime, false, Response, Request);
242
243 return;
244 }
245 }
246
247 RosterItem Item = this.defaultXmppClient.GetRosterItem(BareJID);
248 if (Item is null)
249 {
250 if (!XmppClient.BareJidRegEx.IsMatch(BareJID))
251 throw new BadRequestException("Invalid Bare JID.");
252
253 // TODO: Request presence subscription, if user authenticated and request valid.
254
255 throw new ConflictException("No approved presence subscription with " + BareJID + ".");
256 }
257 else
258 {
259 foreach (PresenceEventArgs e in Item.Resources)
260 {
261 // TODO: Select one based on features.
262
263 if (!(this.serverlessMessaging is null))
264 {
265 await this.serverlessMessaging.GetPeerConnection(e.From, this.SendP2P, new SendP2pRec()
266 {
267 item = Item,
268 method = Method,
269 fullJID = e.From,
270 localUrl = LocalUrl,
271 request = Request,
272 response = Response
273 });
274 }
275 else
276 await this.SendRequest(this.httpxClient, e.From, Method, BareJID, LocalUrl, Request, Response);
277
278 return;
279 }
280
281 throw new ServiceUnavailableException(BareJID + " not online.");
282 }
283 }
284 catch (Exception ex)
285 {
286 await Response.SendResponse(ex);
287 }
288 }
289
299 public async Task<GetClientResponse> GetClientAsync(Uri Uri)
300 {
301 if (string.Compare(Uri.Scheme, HttpxGetter.HttpxUriScheme, true) != 0)
302 throw new ArgumentException("URI must use URI Scheme HTTPX.", nameof(Uri));
303
304 string BareJID = Uri.UserInfo + "@" + Uri.Authority;
305 string LocalUrl = Uri.PathAndQuery + Uri.Fragment;
306
307 RosterItem Item = this.defaultXmppClient.GetRosterItem(BareJID);
308 if (Item is null)
309 {
310 if (BareJID.IndexOf('@') < 0) // Server or component hosts HTTPX interface
311 {
312 return new GetClientResponse()
313 {
314 BareJid = BareJID,
315 FullJid = BareJID,
317 LocalUrl = LocalUrl
318 };
319 }
320
321 if (!XmppClient.BareJidRegEx.IsMatch(BareJID))
322 throw new BadRequestException("Invalid Bare JID.");
323
324 // TODO: Request presence subscription, if user authenticated and request valid.
325
326 throw new ConflictException("No approved presence subscription with " + BareJID + ".");
327 }
328 else
329 {
330 TaskCompletionSource<HttpxClient> Result = new TaskCompletionSource<HttpxClient>();
331
332 foreach (PresenceEventArgs e in Item.Resources)
333 {
334 if (!(this.serverlessMessaging is null))
335 {
336 await this.serverlessMessaging.GetPeerConnection(e.From, (sender, e2) =>
337 {
338 if (e2.Client is null)
339 Result.TrySetResult(this.httpxClient);
340 else
341 {
342 if (e2.Client.SupportsFeature(HttpxClient.Namespace) &&
343 e2.Client.TryGetTag("HttpxClient", out object Obj) &&
344 Obj is HttpxClient Client)
345 {
346 Result.TrySetResult(Client);
347 }
348 else
349 Result.TrySetResult(this.httpxClient);
350 }
351
352 return Task.CompletedTask;
353 }, null);
354 }
355 else
356 Result.TrySetResult(this.httpxClient);
357
358 HttpxClient Client2 = await Result.Task;
359
360 return new GetClientResponse()
361 {
362 FullJid = e.From,
363 BareJid = BareJID,
364 LocalUrl = LocalUrl,
365 HttpxClient = Client2
366 };
367 }
368
369 throw new ServiceUnavailableException(BareJID + " not online.");
370 }
371 }
372
373 private class SendP2pRec
374 {
375 public RosterItem item;
376 public string method;
377 public string fullJID;
378 public string localUrl;
379 public HttpRequest request;
380 public HttpResponse response;
381 }
382
383 private async Task SendP2P(object Sender, PeerConnectionEventArgs e)
384 {
385 SendP2pRec Rec = (SendP2pRec)e.State;
386
387 try
388 {
389 if (e.Client is null)
390 {
391 await this.SendRequest(this.httpxClient, Rec.fullJID, Rec.method, XmppClient.GetBareJID(Rec.fullJID),
392 Rec.localUrl, Rec.request, Rec.response);
393 }
394 else
395 {
396 if (e.Client.SupportsFeature(HttpxClient.Namespace) &&
397 e.Client.TryGetTag("HttpxClient", out object Obj) &&
398 Obj is HttpxClient Client)
399 {
400 await this.SendRequest(Client, Rec.fullJID, Rec.method, XmppClient.GetBareJID(Rec.fullJID),
401 Rec.localUrl, Rec.request, Rec.response);
402 }
403 else
404 {
405 await this.SendRequest(this.httpxClient, Rec.fullJID, Rec.method, XmppClient.GetBareJID(Rec.fullJID),
406 Rec.localUrl, Rec.request, Rec.response);
407 }
408 }
409 }
410 catch (Exception ex)
411 {
412 await Rec.response.SendResponse(ex);
413 }
414 }
415
416 private Task SendRequest(HttpxClient HttpxClient, string To, string Method, string BareJID, string LocalUrl,
417 HttpRequest Request, HttpResponse Response)
418 {
419 LinkedList<HttpField> Headers = new LinkedList<HttpField>();
420
421 foreach (HttpField Header in Request.Header)
422 {
423 switch (Header.Key.ToLower())
424 {
425 case "host":
426 Headers.AddLast(new HttpField("Host", BareJID));
427 break;
428
429 case "cookie":
430 case "set-cookie":
431 // Do not forward cookies.
432 break;
433
434 default:
435 Headers.AddLast(Header);
436 break;
437 }
438 }
439
440 ReadoutState State = new ReadoutState(Response, BareJID, LocalUrl)
441 {
442 Cacheable = (Method == "GET" && !(this.httpxCache is null))
443 };
444
445 string s = LocalUrl;
446 int i = s.IndexOf('.');
447 if (i > 0)
448 {
449 s = s[(i + 1)..];
450 i = s.IndexOfAny(new char[] { '?', '#' });
451 if (i > 0)
452 s = s[..i];
453
454 if (this.httpxCache.CanCache(BareJID, LocalUrl, InternetContent.GetContentType(s)))
455 {
456 LinkedListNode<HttpField> Loop = Headers.First;
457 LinkedListNode<HttpField> Next;
458
459 while (!(Loop is null))
460 {
461 Next = Loop.Next;
462
463 switch (Loop.Value.Key.ToLower())
464 {
465 case "if-match":
466 case "if-modified-since":
467 case "if-none-match":
468 case "if-range":
469 case "if-unmodified-since":
470 Headers.Remove(Loop);
471 break;
472 }
473
474 Loop = Next;
475 }
476 }
477 }
478
479 return HttpxClient.Request(To, Method, LocalUrl, Request.Header.HttpVersion, Headers, Request.HasData ? Request.DataStream : null,
480 this.RequestResponse, this.ResponseData, State);
481 }
482
483 private async Task RequestResponse(object Sender, HttpxResponseEventArgs e)
484 {
485 ReadoutState State2 = (ReadoutState)e.State;
486
487 State2.Response.StatusCode = e.StatusCode;
488 State2.Response.StatusMessage = e.StatusMessage;
489
490 if (!(e.HttpResponse is null))
491 {
492 foreach (KeyValuePair<string, string> Field in e.HttpResponse.GetHeaders())
493 {
494 switch (Field.Key.ToLower())
495 {
496 case "cookie":
497 case "set-cookie":
498 // Do not forward cookies.
499 break;
500
501 case "content-type":
502 State2.ContentType = Field.Value;
503 State2.Response.SetHeader(Field.Key, Field.Value);
504 break;
505
506 case "etag":
507 State2.ETag = Field.Value;
508 State2.Response.SetHeader(Field.Key, Field.Value);
509 break;
510
511 case "last-modified":
512 DateTimeOffset TP;
513 if (CommonTypes.TryParseRfc822(Field.Value, out TP))
514 State2.LastModified = TP;
515 State2.Response.SetHeader(Field.Key, Field.Value);
516 break;
517
518 case "expires":
519 if (CommonTypes.TryParseRfc822(Field.Value, out TP))
520 State2.Expires = TP;
521 State2.Response.SetHeader(Field.Key, Field.Value);
522 break;
523
524 case "cache-control":
525 State2.CacheControl = Field.Value;
526 State2.Response.SetHeader(Field.Key, Field.Value);
527 break;
528
529 case "pragma":
530 State2.Pragma = Field.Value;
531 State2.Response.SetHeader(Field.Key, Field.Value);
532 break;
533
534 default:
535 State2.Response.SetHeader(Field.Key, Field.Value);
536 break;
537 }
538 }
539 }
540
541 if (!e.HasData)
542 await State2.Response.SendResponse();
543 else
544 {
545 if (e.StatusCode == 200 && State2.Cacheable && State2.CanCache &&
546 this.httpxCache.CanCache(State2.BareJid, State2.LocalResource, State2.ContentType))
547 {
548 State2.TempOutput = new TemporaryStream();
549 }
550
551 if (!(e.Data is null))
552 await this.BinaryDataReceived(State2, true, e.ConstantBuffer, e.Data);
553 }
554 }
555
556 private Task ResponseData(object Sender, HttpxResponseDataEventArgs e)
557 {
558 ReadoutState State2 = (ReadoutState)e.State;
559
560 return this.BinaryDataReceived(State2, e.Last, e.ConstantBuffer, e.Data);
561 }
562
563 private async Task BinaryDataReceived(ReadoutState State2, bool Last, bool ConstantBuffer, byte[] Data)
564 {
565 try
566 {
567 await State2.Response.Write(ConstantBuffer, Data);
568 }
569 catch (Exception)
570 {
571 State2.Dispose();
572 return;
573 }
574
575 State2.TempOutput?.Write(Data, 0, Data.Length);
576
577 if (Last)
578 {
579 await State2.Response.SendResponse();
580 this.AddToCacheAsync(State2);
581 }
582 }
583
584 private async void AddToCacheAsync(ReadoutState State)
585 {
586 try
587 {
588 if (!(State.TempOutput is null))
589 {
590 State.TempOutput.Position = 0;
591
592 await this.httpxCache.AddToCache(State.BareJid, State.LocalResource, State.ContentType, State.ETag,
593 State.LastModified.Value, State.Expires, State.TempOutput);
594 }
595 }
596 catch (Exception ex)
597 {
598 Log.Exception(ex);
599 }
600 finally
601 {
602 try
603 {
604 State.Dispose();
605 }
606 catch (Exception ex2)
607 {
608 Log.Exception(ex2);
609 }
610 }
611 }
612
613 private class ReadoutState : IDisposable
614 {
615 public bool Cacheable = false;
616 public HttpResponse Response;
617 public string ETag = null;
618 public string BareJid = null;
619 public string LocalResource = null;
620 public string ContentType = null;
621 public string CacheControl = null;
622 public string Pragma = null;
623 public DateTimeOffset? Expires = null;
624 public DateTimeOffset? LastModified = null;
625 public TemporaryStream TempOutput = null;
626
627 public ReadoutState(HttpResponse Response, string BareJid, string LocalResource)
628 {
629 this.Response = Response;
630 this.BareJid = BareJid;
631 this.LocalResource = LocalResource;
632 }
633
634 public bool CanCache
635 {
636 get
637 {
638 if (this.ETag is null || !this.LastModified.HasValue)
639 return false;
640
641 if (!(this.CacheControl is null))
642 {
643 if ((this.CacheControl.Contains("no-cache") || this.CacheControl.Contains("no-store")))
644 return false;
645
646 if (!this.Expires.HasValue)
647 {
648 string s = this.CacheControl;
649 int i = s.IndexOf("max-age");
650 int c = s.Length;
651 char ch;
652
653 while (i < c && ((ch = s[i]) <= ' ' || ch == '=' || ch == 160))
654 i++;
655
656 int j = i;
657
658 while (j < c && (ch = s[j]) >= '0' && ch <= '9')
659 j++;
660
661 if (j > i && int.TryParse(s[i..j], out j))
662 this.Expires = DateTimeOffset.UtcNow.AddSeconds(j);
663 }
664 }
665
666 if (!(this.Pragma is null) && this.Pragma.Contains("no-cache"))
667 return false;
668
669 return true;
670 }
671 }
672
673 public void Dispose()
674 {
675 if (!(this.TempOutput is null))
676 {
677 this.TempOutput.Dispose();
678 this.TempOutput = null;
679 }
680 }
681 }
682
686 public bool AllowsGET
687 {
688 get { return true; }
689 }
690
697 public Task GET(HttpRequest Request, HttpResponse Response)
698 {
699 return this.Request("GET", Request, Response);
700 }
701
709 public Task GET(HttpRequest Request, HttpResponse Response, ByteRangeInterval FirstInterval)
710 {
711 return this.Request("GET", Request, Response);
712 }
713
720 public override Task OPTIONS(HttpRequest Request, HttpResponse Response)
721 {
722 return this.Request("OPTIONS", Request, Response);
723 }
724
728 public bool AllowsPOST
729 {
730 get { return true; }
731 }
732
739 public Task POST(HttpRequest Request, HttpResponse Response)
740 {
741 return this.Request("POST", Request, Response);
742 }
743
751 public Task POST(HttpRequest Request, HttpResponse Response, ContentByteRangeInterval Interval)
752 {
753 return this.Request("POST", Request, Response);
754 }
755
759 public bool AllowsPUT
760 {
761 get { return true; }
762 }
763
770 public Task PUT(HttpRequest Request, HttpResponse Response)
771 {
772 return this.Request("PUT", Request, Response);
773 }
774
782 public Task PUT(HttpRequest Request, HttpResponse Response, ContentByteRangeInterval Interval)
783 {
784 return this.Request("PUT", Request, Response);
785 }
786
790 public bool AllowsPATCH
791 {
792 get { return true; }
793 }
794
801 public Task PATCH(HttpRequest Request, HttpResponse Response)
802 {
803 return this.Request("PATCH", Request, Response);
804 }
805
813 public Task PATCH(HttpRequest Request, HttpResponse Response, ContentByteRangeInterval Interval)
814 {
815 return this.Request("PATCH", Request, Response);
816 }
817
821 public bool AllowsTRACE
822 {
823 get { return true; }
824 }
825
832 public Task TRACE(HttpRequest Request, HttpResponse Response)
833 {
834 return this.Request("TRACE", Request, Response);
835 }
836
840 public bool AllowsDELETE
841 {
842 get { return true; }
843 }
844
851 public Task DELETE(HttpRequest Request, HttpResponse Response)
852 {
853 return this.Request("DELETE", Request, Response);
854 }
855 }
856}
Helps with parsing of commong data types.
Definition: CommonTypes.cs:15
static bool TryParseRfc822(string s, out DateTimeOffset Value)
Parses a date and time value encoded according to RFC 822, §5.
Definition: CommonTypes.cs:172
Static class managing encoding and decoding of internet content.
static string GetContentType(string FileExtension)
Gets the content type of an item, given its file extension. It uses the TryGetContentType to see if a...
Static class managing the application event log. Applications and services log events on this static ...
Definition: Log.cs:14
static void Exception(Exception Exception, string Object, string Actor, string EventId, EventLevel Level, string Facility, string Module, params KeyValuePair< string, object >[] Tags)
Logs an exception. Event type will be determined by the severity of the exception.
Definition: Log.cs:1657
The request could not be understood by the server due to malformed syntax. The client SHOULD NOT repe...
Represents a range in a ranged HTTP request or response.
The request could not be completed due to a conflict with the current state of the resource....
Represents a content range in a ranged HTTP request or response.
Base class for all asynchronous HTTP resources. An asynchronous resource responds outside of the meth...
Base class for all HTTP fields.
Definition: HttpField.cs:7
Publishes a folder with all its files and subfolders through HTTP GET, with optional support for PUT,...
static Task SendResponse(string FullPath, string ContentType, string ETag, DateTime LastModified, bool LastModifiedUpdated, HttpResponse Response)
Sends a file-based response back to the client.
static bool LessOrEqual(DateTime LastModified, DateTimeOffset Limit)
Computes LastModified <=Limit . The normal <= operator behaved strangely, and did not get the equalit...
HttpFieldIfModifiedSince IfModifiedSince
If-Modified-Since HTTP Field header. (RFC 2616, §14.25)
HttpFieldIfNoneMatch IfNoneMatch
If-None-Match HTTP Field header. (RFC 2616, §14.26)
Represents an HTTP request.
Definition: HttpRequest.cs:22
Stream DataStream
Data stream, if data is available, or null if data is not available.
Definition: HttpRequest.cs:187
HttpRequestHeader Header
Request header.
Definition: HttpRequest.cs:182
bool HasData
If the request has data.
Definition: HttpRequest.cs:113
string SubPath
Sub-path. If a resource is found handling the request, this property contains the trailing sub-path o...
Definition: HttpRequest.cs:194
string ResourceName
Name of resource.
Represets a response of an HTTP client request.
Definition: HttpResponse.cs:23
async Task SendResponse()
Sends the response back to the client. If the resource is synchronous, there's no need to call this m...
If the client has performed a conditional GET request and access is allowed, but the document has not...
The server is currently unable to handle the request due to a temporary overloading or maintenance of...
Event arguments for presence events.
string From
From where the presence was received.
Response to the HttpxProxy.GetClientAsync(Uri) method call.
override void Dispose()
Disposes of the extension.
Definition: HttpxClient.cs:135
Content Getter, retrieving content using the HTTPX URI Scheme.
Definition: HttpxGetter.cs:23
Implements a Proxy resource that allows Web clients to fetch HTTP-based resources over HTTPX.
Definition: HttpxProxy.cs:19
HttpxProxy(string ResourceName, XmppClient DefaultXmppClient, int MaxChunkSize, XmppServerlessMessaging ServerlessMessaging, IHttpxCache HttpxCache)
Implements a Proxy resource that allows Web clients to fetch HTTP-based resources over HTTPX.
Definition: HttpxProxy.cs:60
override Task OPTIONS(HttpRequest Request, HttpResponse Response)
Executes the OPTIONS method on the resource.
Definition: HttpxProxy.cs:720
Task TRACE(HttpRequest Request, HttpResponse Response)
Executes the TRACE method on the resource.
Definition: HttpxProxy.cs:832
XmppServerlessMessaging ServerlessMessaging
Serverless messaging manager.
Definition: HttpxProxy.cs:107
Task POST(HttpRequest Request, HttpResponse Response)
Executes the POST method on the resource.
Definition: HttpxProxy.cs:739
Task PUT(HttpRequest Request, HttpResponse Response, ContentByteRangeInterval Interval)
Executes the ranged PUT method on the resource.
Definition: HttpxProxy.cs:782
InBandBytestreams.IbbClient IbbClient
In-band bytestream client, if supported.
Definition: HttpxProxy.cs:147
Task PUT(HttpRequest Request, HttpResponse Response)
Executes the PUT method on the resource.
Definition: HttpxProxy.cs:770
Task GET(HttpRequest Request, HttpResponse Response)
Executes the GET method on the resource.
Definition: HttpxProxy.cs:697
Task DELETE(HttpRequest Request, HttpResponse Response)
Executes the DELETE method on the resource.
Definition: HttpxProxy.cs:851
Task PATCH(HttpRequest Request, HttpResponse Response)
Executes the PATCH method on the resource.
Definition: HttpxProxy.cs:801
HttpxClient DefaultHttpxClient
Default HTTPX client.
Definition: HttpxProxy.cs:141
bool Disposed
If the proxy has been disposed.
Definition: HttpxProxy.cs:86
P2P.SOCKS5.Socks5Proxy Socks5Proxy
SOCKS5 proxy, if supported.
Definition: HttpxProxy.cs:162
IHttpxCache HttpxCache
Reference to the HTTPX Cache manager.
Definition: HttpxProxy.cs:122
Task PATCH(HttpRequest Request, HttpResponse Response, ContentByteRangeInterval Interval)
Executes the ranged PATCH method on the resource.
Definition: HttpxProxy.cs:813
HttpxProxy(string ResourceName, XmppClient DefaultXmppClient, int MaxChunkSize)
Implements a Proxy resource that allows Web clients to fetch HTTP-based resources over HTTPX.
Definition: HttpxProxy.cs:35
async Task< GetClientResponse > GetClientAsync(Uri Uri)
Gets a corresponding HttpxClient appropriate for a given request.
Definition: HttpxProxy.cs:299
override bool UserSessions
If the resource uses user sessions.
Definition: HttpxProxy.cs:188
HttpxProxy(string ResourceName, XmppClient DefaultXmppClient, int MaxChunkSize, XmppServerlessMessaging ServerlessMessaging)
Implements a Proxy resource that allows Web clients to fetch HTTP-based resources over HTTPX.
Definition: HttpxProxy.cs:47
void Dispose()
IDisposable.Dispose
Definition: HttpxProxy.cs:76
IPostResource PostResource
Post resource for responses.
Definition: HttpxProxy.cs:92
override bool HandlesSubPaths
If the resource handles sub-paths.
Definition: HttpxProxy.cs:177
Task GET(HttpRequest Request, HttpResponse Response, ByteRangeInterval FirstInterval)
Executes the ranged GET method on the resource.
Definition: HttpxProxy.cs:709
Task POST(HttpRequest Request, HttpResponse Response, ContentByteRangeInterval Interval)
Executes the ranged POST method on the resource.
Definition: HttpxProxy.cs:751
XmppClient DefaultXmppClient
Default XMPP client.
Definition: HttpxProxy.cs:136
Class sending and receiving binary streams over XMPP using XEP-0047: In-band Bytestreams: https://xmp...
Definition: IbbClient.cs:20
object State
State object passed to the original request.
XmppClient Client
XMPP client, if aquired, or null otherwise.
Class managing a SOCKS5 proxy associated with the current XMPP server.
Definition: Socks5Proxy.cs:19
Class managing peer-to-peer serveless XMPP communication.
Task GetPeerConnection(string FullJID, EventHandlerAsync< PeerConnectionEventArgs > Callback, object State)
Gets a peer XMPP connection.
Maintains information about an item in the roster.
Definition: RosterItem.cs:75
PresenceEventArgs[] Resources
Active resources utilized by contact.
Definition: RosterItem.cs:300
Manages an XMPP client connection. Implements XMPP, as defined in https://tools.ietf....
Definition: XmppClient.cs:58
static string GetBareJID(string JID)
Gets the Bare JID from a JID, which may be a Full JID.
Definition: XmppClient.cs:6958
static readonly Regex BareJidRegEx
Regular expression for Bare JIDs
Definition: XmppClient.cs:187
bool SupportsFeature(string Feature)
Checks if a feature is supported by the client.
Definition: XmppClient.cs:3032
bool TryGetTag(string TagName, out object Tag)
Tries to get a tag from the client. Tags can be used to attached application specific objects to the ...
Definition: XmppClient.cs:7270
Manages a temporary stream. Contents is kept in-memory, if below a memory threshold,...
override void Dispose(bool disposing)
Releases the unmanaged resources used by the System.IO.Stream and optionally releases the managed res...
DELETE Interface for HTTP resources.
GET Interface for HTTP resources.
Ranged GET Interface for HTTP resources.
PATCH Interface for HTTP resources.
Ranged PATCH Interface for HTTP resources.
POST Interface for HTTP resources.
Ranged POST Interface for HTTP resources.
PUT Interface for HTTP resources.
Ranged PUT Interface for HTTP resources.
TRACE Interface for HTTP resources.
Interface for HTTPX caches. HTTPX caches can improve performance by storing resources locally.
Definition: IHttpxCache.cs:11
bool CanCache(string BareJid, string LocalResource, string ContentType)
Checks if content from a remote resource can be cached.
Task< IHttpxCachedResource > TryGetCachedResource(string BareJid, string LocalResource)
Tries to get a reference to the resource from the local cache.
Task AddToCache(string BareJid, string LocalResource, string ContentType, string ETag, DateTimeOffset LastModified, DateTimeOffset? Expires, Stream Content)
Adds content to the cache.
Interface for HTTPX Cache resource items.
string FileName
Name of file of local resource.
DateTimeOffset LastModified
When resource was last modified on remote peer.
Interface for HTTP(S) Post-back resources. These can be used to allow HTTPX servers to HTTP POST back...
class Header(ISimulationNode Parent, Model Model)
Represents an identity property.
Definition: Header.cs:18
ContentType
DTLS Record content type.
Definition: Enumerations.cs:11