forked from ServiceStack/ServiceStack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHttpMethods.cs
More file actions
67 lines (61 loc) · 2.5 KB
/
HttpMethods.cs
File metadata and controls
67 lines (61 loc) · 2.5 KB
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
using System.Collections.Generic;
using System.Linq;
using ServiceStack.ServiceHost;
#if WINDOWS_PHONE && !WP
using ServiceStack.Text.WP;
#endif
namespace ServiceStack.Common.Web
{
public static class HttpMethods
{
static readonly string[] allVerbs = new[] {
"OPTIONS", "GET", "HEAD", "POST", "PUT", "DELETE", "TRACE", "CONNECT", // RFC 2616
"PROPFIND", "PROPPATCH", "MKCOL", "COPY", "MOVE", "LOCK", "UNLOCK", // RFC 2518
"VERSION-CONTROL", "REPORT", "CHECKOUT", "CHECKIN", "UNCHECKOUT",
"MKWORKSPACE", "UPDATE", "LABEL", "MERGE", "BASELINE-CONTROL", "MKACTIVITY", // RFC 3253
"ORDERPATCH", // RFC 3648
"ACL", // RFC 3744
"PATCH", // https://datatracker.ietf.org/doc/draft-dusseault-http-patch/
"SEARCH", // https://datatracker.ietf.org/doc/draft-reschke-webdav-search/
"BCOPY", "BDELETE", "BMOVE", "BPROPFIND", "BPROPPATCH", "NOTIFY",
"POLL", "SUBSCRIBE", "UNSUBSCRIBE" //MS Exchange WebDav: http://msdn.microsoft.com/en-us/library/aa142917.aspx
};
public static HashSet<string> AllVerbs = new HashSet<string>(allVerbs);
public static bool HasVerb(string httpVerb)
{
#if NETFX_CORE
return allVerbs.Any(p => p.Equals(httpVerb.ToUpper()));
#else
return AllVerbs.Contains(httpVerb.ToUpper());
#endif
}
public const string Get = "GET";
public const string Put = "PUT";
public const string Post = "POST";
public const string Delete = "DELETE";
public const string Options = "OPTIONS";
public const string Head = "HEAD";
public const string Patch = "PATCH";
public static EndpointAttributes GetEndpointAttribute(string httpMethod)
{
switch (httpMethod.ToUpper())
{
case Get:
return EndpointAttributes.HttpGet;
case Put:
return EndpointAttributes.HttpPut;
case Post:
return EndpointAttributes.HttpPost;
case Delete:
return EndpointAttributes.HttpDelete;
case Patch:
return EndpointAttributes.HttpPatch;
case Head:
return EndpointAttributes.HttpHead;
case Options:
return EndpointAttributes.HttpOptions;
}
return EndpointAttributes.HttpOther;
}
}
}