-
Notifications
You must be signed in to change notification settings - Fork 76
/
Copy pathHttpxProxy.cs
855 lines (746 loc) · 23.5 KB
/
HttpxProxy.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Waher.Content;
using Waher.Events;
using Waher.Networking.HTTP;
using Waher.Networking.XMPP.Events;
using Waher.Networking.XMPP.P2P;
using Waher.Runtime.Temporary;
namespace Waher.Networking.XMPP.HTTPX
{
/// <summary>
/// Implements a Proxy resource that allows Web clients to fetch HTTP-based resources over HTTPX.
/// </summary>
public partial class HttpxProxy : HttpAsynchronousResource, IDisposable, IHttpGetMethod, IHttpGetRangesMethod,
IHttpPostMethod, IHttpPostRangesMethod, IHttpPutMethod, IHttpPutRangesMethod, IHttpPatchMethod, IHttpPatchRangesMethod,
IHttpTraceMethod, IHttpDeleteMethod
{
private readonly XmppClient defaultXmppClient;
private HttpxClient httpxClient;
private XmppServerlessMessaging serverlessMessaging;
private IHttpxCache httpxCache;
private IPostResource postResource = null;
private InBandBytestreams.IbbClient ibbClient = null;
private P2P.SOCKS5.Socks5Proxy socks5Proxy = null;
private bool disposed = false;
/// <summary>
/// Implements a Proxy resource that allows Web clients to fetch HTTP-based resources over HTTPX.
/// </summary>
/// <param name="ResourceName">Resource name of proxy resource.</param>
/// <param name="DefaultXmppClient">Default XMPP client.</param>
/// <param name="MaxChunkSize">Max Chunk Size to use.</param>
public HttpxProxy(string ResourceName, XmppClient DefaultXmppClient, int MaxChunkSize)
: this(ResourceName, DefaultXmppClient, MaxChunkSize, null, null)
{
}
/// <summary>
/// Implements a Proxy resource that allows Web clients to fetch HTTP-based resources over HTTPX.
/// </summary>
/// <param name="ResourceName">Resource name of proxy resource.</param>
/// <param name="DefaultXmppClient">Default XMPP client.</param>
/// <param name="MaxChunkSize">Max Chunk Size to use.</param>
/// <param name="ServerlessMessaging">Serverless messaging manager.</param>
public HttpxProxy(string ResourceName, XmppClient DefaultXmppClient, int MaxChunkSize, XmppServerlessMessaging ServerlessMessaging)
: this(ResourceName, DefaultXmppClient, MaxChunkSize, ServerlessMessaging, null)
{
}
/// <summary>
/// Implements a Proxy resource that allows Web clients to fetch HTTP-based resources over HTTPX.
/// </summary>
/// <param name="ResourceName">Resource name of proxy resource.</param>
/// <param name="DefaultXmppClient">Default XMPP client.</param>
/// <param name="MaxChunkSize">Max Chunk Size to use.</param>
/// <param name="ServerlessMessaging">Serverless messaging manager.</param>
/// <param name="HttpxCache">HTTPX cache object.</param>
public HttpxProxy(string ResourceName, XmppClient DefaultXmppClient, int MaxChunkSize, XmppServerlessMessaging ServerlessMessaging,
IHttpxCache HttpxCache) : base(ResourceName)
{
this.defaultXmppClient = DefaultXmppClient;
this.serverlessMessaging = ServerlessMessaging;
this.httpxCache = HttpxCache;
this.httpxClient = new HttpxClient(this.defaultXmppClient, MaxChunkSize)
{
PostResource = this.postResource
};
}
/// <summary>
/// <see cref="IDisposable.Dispose"/>
/// </summary>
public void Dispose()
{
this.httpxClient?.Dispose();
this.httpxClient = null;
this.disposed = true;
}
/// <summary>
/// If the proxy has been disposed.
/// </summary>
public bool Disposed => this.disposed;
/// <summary>
/// Post resource for responses.
/// </summary>
public IPostResource PostResource
{
get => this.postResource;
set
{
this.postResource = value;
if (!(this.httpxClient is null))
this.httpxClient.PostResource = value;
}
}
/// <summary>
/// Serverless messaging manager.
/// </summary>
public XmppServerlessMessaging ServerlessMessaging
{
get => this.serverlessMessaging;
set
{
if (!(this.serverlessMessaging is null) && this.serverlessMessaging != value)
throw new Exception("Property already set.");
this.serverlessMessaging = value;
}
}
/// <summary>
/// Reference to the HTTPX Cache manager.
/// </summary>
public IHttpxCache HttpxCache
{
get => this.httpxCache;
set
{
if (!(this.httpxCache is null) && this.httpxCache != value)
throw new Exception("Property already set.");
this.httpxCache = value;
}
}
/// <summary>
/// Default XMPP client.
/// </summary>
public XmppClient DefaultXmppClient => this.defaultXmppClient;
/// <summary>
/// Default HTTPX client.
/// </summary>
public HttpxClient DefaultHttpxClient => this.httpxClient;
/// <summary>
/// In-band bytestream client, if supported.
/// </summary>
public InBandBytestreams.IbbClient IbbClient
{
get => this.ibbClient;
set
{
this.ibbClient = value;
if (!(this.httpxClient is null))
this.httpxClient.IbbClient = value;
}
}
/// <summary>
/// SOCKS5 proxy, if supported.
/// </summary>
public P2P.SOCKS5.Socks5Proxy Socks5Proxy
{
get => this.socks5Proxy;
set
{
this.socks5Proxy = value;
if (!(this.httpxClient is null))
this.httpxClient.Socks5Proxy = value;
}
}
/// <summary>
/// If the resource handles sub-paths.
/// </summary>
public override bool HandlesSubPaths
{
get
{
return true;
}
}
/// <summary>
/// If the resource uses user sessions.
/// </summary>
public override bool UserSessions
{
get
{
return false;
}
}
private async Task Request(string Method, HttpRequest Request, HttpResponse Response)
{
try
{
string Url = Request.SubPath;
if (Url.StartsWith("/"))
Url = Url[1..];
if (!Url.StartsWith("httpx://", StringComparison.OrdinalIgnoreCase))
throw new BadRequestException("Invalid URI. Must use httpx URI scheme.");
int i = Url.IndexOf('/', 8);
if (i < 0)
throw new BadRequestException("Invalid URI.");
string BareJID = Url[8..i];
string LocalUrl = Url[i..];
IHttpxCachedResource CachedResource;
if (Method == "GET" && !(this.httpxCache is null))
{
if (!((CachedResource = await this.httpxCache.TryGetCachedResource(BareJID, LocalUrl)) is null))
{
if (!(Request.Header.IfNoneMatch is null))
{
if (!(CachedResource.ETag is null) && Request.Header.IfNoneMatch.Value == CachedResource.ETag)
{
await Response.SendResponse(new NotModifiedException());
return;
}
}
else if (!(Request.Header.IfModifiedSince is null))
{
DateTimeOffset? Limit;
if ((Limit = Request.Header.IfModifiedSince.Timestamp).HasValue &&
HttpFolderResource.LessOrEqual(CachedResource.LastModified.UtcDateTime, Limit.Value.ToUniversalTime()))
{
await Response.SendResponse(new NotModifiedException());
return;
}
}
await HttpFolderResource.SendResponse(CachedResource.FileName, CachedResource.ContentType, CachedResource.ETag,
CachedResource.LastModified.UtcDateTime, Response, Request);
return;
}
}
RosterItem Item = this.defaultXmppClient.GetRosterItem(BareJID);
if (Item is null)
{
if (!XmppClient.BareJidRegEx.IsMatch(BareJID))
throw new BadRequestException("Invalid Bare JID.");
// TODO: Request presence subscription, if user authenticated and request valid.
throw new ConflictException("No approved presence subscription with " + BareJID + ".");
}
else
{
foreach (PresenceEventArgs e in Item.Resources)
{
// TODO: Select one based on features.
if (!(this.serverlessMessaging is null))
{
await this.serverlessMessaging.GetPeerConnection(e.From, this.SendP2P, new SendP2pRec()
{
item = Item,
method = Method,
fullJID = e.From,
localUrl = LocalUrl,
request = Request,
response = Response
});
}
else
await this.SendRequest(this.httpxClient, e.From, Method, BareJID, LocalUrl, Request, Response);
return;
}
throw new ServiceUnavailableException(BareJID + " not online.");
}
}
catch (Exception ex)
{
await Response.SendResponse(ex);
}
}
/// <summary>
/// Gets a corresponding <see cref="HttpxClient"/> appropriate for a given request.
/// </summary>
/// <param name="Uri">URI</param>
/// <returns>Contains details of the <paramref name="Uri"/> and the corresponding <see cref="HttpxClient"/> to use
/// for requesting the resource from the entity.</returns>
/// <exception cref="ArgumentException">If the <paramref name="Uri"/> parameter is invalid.</exception>
/// <exception cref="ConflictException">If an approved presence subscription with the remote entity does not exist.</exception>
/// <exception cref="ServiceUnavailableException">If the remote entity is not online.</exception>
public async Task<GetClientResponse> GetClientAsync(Uri Uri)
{
if (string.Compare(Uri.Scheme, HttpxGetter.HttpxUriScheme, true) != 0)
throw new ArgumentException("URI must use URI Scheme HTTPX.", nameof(Uri));
string BareJID = Uri.UserInfo + "@" + Uri.Authority;
string LocalUrl = Uri.PathAndQuery + Uri.Fragment;
RosterItem Item = this.defaultXmppClient.GetRosterItem(BareJID);
if (Item is null)
{
if (BareJID.IndexOf('@') < 0) // Server or component hosts HTTPX interface
{
return new GetClientResponse()
{
BareJid = BareJID,
FullJid = BareJID,
HttpxClient = this.DefaultHttpxClient,
LocalUrl = LocalUrl
};
}
if (!XmppClient.BareJidRegEx.IsMatch(BareJID))
throw new BadRequestException("Invalid Bare JID.");
// TODO: Request presence subscription, if user authenticated and request valid.
throw new ConflictException("No approved presence subscription with " + BareJID + ".");
}
else
{
TaskCompletionSource<HttpxClient> Result = new TaskCompletionSource<HttpxClient>();
foreach (PresenceEventArgs e in Item.Resources)
{
if (!(this.serverlessMessaging is null))
{
await this.serverlessMessaging.GetPeerConnection(e.From, (sender, e2) =>
{
if (e2.Client is null)
Result.TrySetResult(this.httpxClient);
else
{
if (e2.Client.SupportsFeature(HttpxClient.Namespace) &&
e2.Client.TryGetTag("HttpxClient", out object Obj) &&
Obj is HttpxClient Client)
{
Result.TrySetResult(Client);
}
else
Result.TrySetResult(this.httpxClient);
}
return Task.CompletedTask;
}, null);
}
else
Result.TrySetResult(this.httpxClient);
HttpxClient Client2 = await Result.Task;
return new GetClientResponse()
{
FullJid = e.From,
BareJid = BareJID,
LocalUrl = LocalUrl,
HttpxClient = Client2
};
}
throw new ServiceUnavailableException(BareJID + " not online.");
}
}
private class SendP2pRec
{
public RosterItem item;
public string method;
public string fullJID;
public string localUrl;
public HttpRequest request;
public HttpResponse response;
}
private async Task SendP2P(object Sender, PeerConnectionEventArgs e)
{
SendP2pRec Rec = (SendP2pRec)e.State;
try
{
if (e.Client is null)
{
await this.SendRequest(this.httpxClient, Rec.fullJID, Rec.method, XmppClient.GetBareJID(Rec.fullJID),
Rec.localUrl, Rec.request, Rec.response);
}
else
{
if (e.Client.SupportsFeature(HttpxClient.Namespace) &&
e.Client.TryGetTag("HttpxClient", out object Obj) &&
Obj is HttpxClient Client)
{
await this.SendRequest(Client, Rec.fullJID, Rec.method, XmppClient.GetBareJID(Rec.fullJID),
Rec.localUrl, Rec.request, Rec.response);
}
else
{
await this.SendRequest(this.httpxClient, Rec.fullJID, Rec.method, XmppClient.GetBareJID(Rec.fullJID),
Rec.localUrl, Rec.request, Rec.response);
}
}
}
catch (Exception ex)
{
await Rec.response.SendResponse(ex);
}
}
private Task SendRequest(HttpxClient HttpxClient, string To, string Method, string BareJID, string LocalUrl,
HttpRequest Request, HttpResponse Response)
{
LinkedList<HttpField> Headers = new LinkedList<HttpField>();
foreach (HttpField Header in Request.Header)
{
switch (Header.Key.ToLower())
{
case "host":
Headers.AddLast(new HttpField("Host", BareJID));
break;
case "cookie":
case "set-cookie":
// Do not forward cookies.
break;
default:
Headers.AddLast(Header);
break;
}
}
ReadoutState State = new ReadoutState(Response, BareJID, LocalUrl)
{
Cacheable = (Method == "GET" && !(this.httpxCache is null))
};
string s = LocalUrl;
int i = s.IndexOf('.');
if (i > 0)
{
s = s[(i + 1)..];
i = s.IndexOfAny(new char[] { '?', '#' });
if (i > 0)
s = s[..i];
if (this.httpxCache.CanCache(BareJID, LocalUrl, InternetContent.GetContentType(s)))
{
LinkedListNode<HttpField> Loop = Headers.First;
LinkedListNode<HttpField> Next;
while (!(Loop is null))
{
Next = Loop.Next;
switch (Loop.Value.Key.ToLower())
{
case "if-match":
case "if-modified-since":
case "if-none-match":
case "if-range":
case "if-unmodified-since":
Headers.Remove(Loop);
break;
}
Loop = Next;
}
}
}
return HttpxClient.Request(To, Method, LocalUrl, Request.Header.HttpVersion, Headers, Request.HasData ? Request.DataStream : null,
this.RequestResponse, this.ResponseData, State);
}
private async Task RequestResponse(object Sender, HttpxResponseEventArgs e)
{
ReadoutState State2 = (ReadoutState)e.State;
State2.Response.StatusCode = e.StatusCode;
State2.Response.StatusMessage = e.StatusMessage;
if (!(e.HttpResponse is null))
{
foreach (KeyValuePair<string, string> Field in e.HttpResponse.GetHeaders())
{
switch (Field.Key.ToLower())
{
case "cookie":
case "set-cookie":
// Do not forward cookies.
break;
case "content-type":
State2.ContentType = Field.Value;
State2.Response.SetHeader(Field.Key, Field.Value);
break;
case "etag":
State2.ETag = Field.Value;
State2.Response.SetHeader(Field.Key, Field.Value);
break;
case "last-modified":
DateTimeOffset TP;
if (CommonTypes.TryParseRfc822(Field.Value, out TP))
State2.LastModified = TP;
State2.Response.SetHeader(Field.Key, Field.Value);
break;
case "expires":
if (CommonTypes.TryParseRfc822(Field.Value, out TP))
State2.Expires = TP;
State2.Response.SetHeader(Field.Key, Field.Value);
break;
case "cache-control":
State2.CacheControl = Field.Value;
State2.Response.SetHeader(Field.Key, Field.Value);
break;
case "pragma":
State2.Pragma = Field.Value;
State2.Response.SetHeader(Field.Key, Field.Value);
break;
default:
State2.Response.SetHeader(Field.Key, Field.Value);
break;
}
}
}
if (!e.HasData)
await State2.Response.SendResponse();
else
{
if (e.StatusCode == 200 && State2.Cacheable && State2.CanCache &&
this.httpxCache.CanCache(State2.BareJid, State2.LocalResource, State2.ContentType))
{
State2.TempOutput = new TemporaryStream();
}
if (!(e.Data is null))
await this.BinaryDataReceived(State2, true, e.ConstantBuffer, e.Data);
}
}
private Task ResponseData(object Sender, HttpxResponseDataEventArgs e)
{
ReadoutState State2 = (ReadoutState)e.State;
return this.BinaryDataReceived(State2, e.Last, e.ConstantBuffer, e.Data);
}
private async Task BinaryDataReceived(ReadoutState State2, bool Last, bool ConstantBuffer, byte[] Data)
{
try
{
await State2.Response.Write(ConstantBuffer, Data);
}
catch (Exception)
{
State2.Dispose();
return;
}
State2.TempOutput?.Write(Data, 0, Data.Length);
if (Last)
{
await State2.Response.SendResponse();
this.AddToCacheAsync(State2);
}
}
private async void AddToCacheAsync(ReadoutState State)
{
try
{
if (!(State.TempOutput is null))
{
State.TempOutput.Position = 0;
await this.httpxCache.AddToCache(State.BareJid, State.LocalResource, State.ContentType, State.ETag,
State.LastModified.Value, State.Expires, State.TempOutput);
}
}
catch (Exception ex)
{
Log.Exception(ex);
}
finally
{
try
{
State.Dispose();
}
catch (Exception ex2)
{
Log.Exception(ex2);
}
}
}
private class ReadoutState : IDisposable
{
public bool Cacheable = false;
public HttpResponse Response;
public string ETag = null;
public string BareJid = null;
public string LocalResource = null;
public string ContentType = null;
public string CacheControl = null;
public string Pragma = null;
public DateTimeOffset? Expires = null;
public DateTimeOffset? LastModified = null;
public TemporaryStream TempOutput = null;
public ReadoutState(HttpResponse Response, string BareJid, string LocalResource)
{
this.Response = Response;
this.BareJid = BareJid;
this.LocalResource = LocalResource;
}
public bool CanCache
{
get
{
if (this.ETag is null || !this.LastModified.HasValue)
return false;
if (!(this.CacheControl is null))
{
if ((this.CacheControl.Contains("no-cache") || this.CacheControl.Contains("no-store")))
return false;
if (!this.Expires.HasValue)
{
string s = this.CacheControl;
int i = s.IndexOf("max-age");
int c = s.Length;
char ch;
while (i < c && ((ch = s[i]) <= ' ' || ch == '=' || ch == 160))
i++;
int j = i;
while (j < c && (ch = s[j]) >= '0' && ch <= '9')
j++;
if (j > i && int.TryParse(s[i..j], out j))
this.Expires = DateTimeOffset.UtcNow.AddSeconds(j);
}
}
if (!(this.Pragma is null) && this.Pragma.Contains("no-cache"))
return false;
return true;
}
}
public void Dispose()
{
if (!(this.TempOutput is null))
{
this.TempOutput.Dispose();
this.TempOutput = null;
}
}
}
/// <summary>
/// If the GET method is allowed.
/// </summary>
public bool AllowsGET
{
get { return true; }
}
/// <summary>
/// Executes the GET method on the resource.
/// </summary>
/// <param name="Request">HTTP Request</param>
/// <param name="Response">HTTP Response</param>
/// <exception cref="HttpException">If an error occurred when processing the method.</exception>
public Task GET(HttpRequest Request, HttpResponse Response)
{
return this.Request("GET", Request, Response);
}
/// <summary>
/// Executes the ranged GET method on the resource.
/// </summary>
/// <param name="Request">HTTP Request</param>
/// <param name="Response">HTTP Response</param>
/// <param name="FirstInterval">First byte range interval.</param>
/// <exception cref="HttpException">If an error occurred when processing the method.</exception>
public Task GET(HttpRequest Request, HttpResponse Response, ByteRangeInterval FirstInterval)
{
return this.Request("GET", Request, Response);
}
/// <summary>
/// Executes the OPTIONS method on the resource.
/// </summary>
/// <param name="Request">HTTP Request</param>
/// <param name="Response">HTTP Response</param>
/// <exception cref="HttpException">If an error occurred when processing the method.</exception>
public override Task OPTIONS(HttpRequest Request, HttpResponse Response)
{
return this.Request("OPTIONS", Request, Response);
}
/// <summary>
/// If the POST method is allowed.
/// </summary>
public bool AllowsPOST
{
get { return true; }
}
/// <summary>
/// Executes the POST method on the resource.
/// </summary>
/// <param name="Request">HTTP Request</param>
/// <param name="Response">HTTP Response</param>
/// <exception cref="HttpException">If an error occurred when processing the method.</exception>
public Task POST(HttpRequest Request, HttpResponse Response)
{
return this.Request("POST", Request, Response);
}
/// <summary>
/// Executes the ranged POST method on the resource.
/// </summary>
/// <param name="Request">HTTP Request</param>
/// <param name="Response">HTTP Response</param>
/// <param name="Interval">Content byte range.</param>
/// <exception cref="HttpException">If an error occurred when processing the method.</exception>
public Task POST(HttpRequest Request, HttpResponse Response, ContentByteRangeInterval Interval)
{
return this.Request("POST", Request, Response);
}
/// <summary>
/// If the PUT method is allowed.
/// </summary>
public bool AllowsPUT
{
get { return true; }
}
/// <summary>
/// Executes the PUT method on the resource.
/// </summary>
/// <param name="Request">HTTP Request</param>
/// <param name="Response">HTTP Response</param>
/// <exception cref="HttpException">If an error occurred when processing the method.</exception>
public Task PUT(HttpRequest Request, HttpResponse Response)
{
return this.Request("PUT", Request, Response);
}
/// <summary>
/// Executes the ranged PUT method on the resource.
/// </summary>
/// <param name="Request">HTTP Request</param>
/// <param name="Response">HTTP Response</param>
/// <param name="Interval">Content byte range.</param>
/// <exception cref="HttpException">If an error occurred when processing the method.</exception>
public Task PUT(HttpRequest Request, HttpResponse Response, ContentByteRangeInterval Interval)
{
return this.Request("PUT", Request, Response);
}
/// <summary>
/// If the PATCH method is allowed.
/// </summary>
public bool AllowsPATCH
{
get { return true; }
}
/// <summary>
/// Executes the PATCH method on the resource.
/// </summary>
/// <param name="Request">HTTP Request</param>
/// <param name="Response">HTTP Response</param>
/// <exception cref="HttpException">If an error occurred when processing the method.</exception>
public Task PATCH(HttpRequest Request, HttpResponse Response)
{
return this.Request("PATCH", Request, Response);
}
/// <summary>
/// Executes the ranged PATCH method on the resource.
/// </summary>
/// <param name="Request">HTTP Request</param>
/// <param name="Response">HTTP Response</param>
/// <param name="Interval">Content byte range.</param>
/// <exception cref="HttpException">If an error occurred when processing the method.</exception>
public Task PATCH(HttpRequest Request, HttpResponse Response, ContentByteRangeInterval Interval)
{
return this.Request("PATCH", Request, Response);
}
/// <summary>
/// If the TRACE method is allowed.
/// </summary>
public bool AllowsTRACE
{
get { return true; }
}
/// <summary>
/// Executes the TRACE method on the resource.
/// </summary>
/// <param name="Request">HTTP Request</param>
/// <param name="Response">HTTP Response</param>
/// <exception cref="HttpException">If an error occurred when processing the method.</exception>
public Task TRACE(HttpRequest Request, HttpResponse Response)
{
return this.Request("TRACE", Request, Response);
}
/// <summary>
/// If the DELETE method is allowed.
/// </summary>
public bool AllowsDELETE
{
get { return true; }
}
/// <summary>
/// Executes the DELETE method on the resource.
/// </summary>
/// <param name="Request">HTTP Request</param>
/// <param name="Response">HTTP Response</param>
/// <exception cref="HttpException">If an error occurred when processing the method.</exception>
public Task DELETE(HttpRequest Request, HttpResponse Response)
{
return this.Request("DELETE", Request, Response);
}
}
}