Merge pull request #3913 from omwok/master
[mono.git] / mcs / class / System / ReferenceSources / HttpApi.cs
1 using System.Collections;
2
3 namespace System.Net
4 {
5         static partial class UnsafeNclNativeMethods
6         {
7                 internal static unsafe class HttpApi 
8                 {
9                         const int HttpHeaderRequestMaximum  = (int)HttpRequestHeader.UserAgent + 1;
10                         const int HttpHeaderResponseMaximum = (int)HttpResponseHeader.WwwAuthenticate + 1;
11
12                         internal static class HTTP_REQUEST_HEADER_ID {
13                                 internal static string ToString(int position) {
14                                         return m_Strings[position];
15                                 }
16
17                                 private static string[] m_Strings = {
18                                         "Cache-Control",
19                                         "Connection",
20                                         "Date",
21                                         "Keep-Alive",
22                                         "Pragma",
23                                         "Trailer",
24                                         "Transfer-Encoding",
25                                         "Upgrade",
26                                         "Via",
27                                         "Warning",
28
29                                         "Allow",
30                                         "Content-Length",
31                                         "Content-Type",
32                                         "Content-Encoding",
33                                         "Content-Language",
34                                         "Content-Location",
35                                         "Content-MD5",
36                                         "Content-Range",
37                                         "Expires",
38                                         "Last-Modified",
39
40                                         "Accept",
41                                         "Accept-Charset",
42                                         "Accept-Encoding",
43                                         "Accept-Language",
44                                         "Authorization",
45                                         "Cookie",
46                                         "Expect",
47                                         "From",
48                                         "Host",
49                                         "If-Match",
50
51                                         "If-Modified-Since",
52                                         "If-None-Match",
53                                         "If-Range",
54                                         "If-Unmodified-Since",
55                                         "Max-Forwards",
56                                         "Proxy-Authorization",
57                                         "Referer",
58                                         "Range",
59                                         "Te",
60                                         "Translate",
61                                         "User-Agent",
62                                 };
63                         }
64
65                         internal static class HTTP_RESPONSE_HEADER_ID {
66                                 private static Hashtable m_Hashtable;
67
68                                 static HTTP_RESPONSE_HEADER_ID() {
69                                         m_Hashtable = new Hashtable((int)Enum.HttpHeaderResponseMaximum);
70                                         for (int i = 0; i < (int)Enum.HttpHeaderResponseMaximum; i++) {
71                                                 m_Hashtable.Add(m_Strings[i], i);
72                                         }
73                                 }
74
75                                 internal static int IndexOfKnownHeader(string HeaderName) {
76                                         object index = m_Hashtable[HeaderName];
77                                         return index==null ? -1 : (int)index;
78                                  }
79
80                                 internal static string ToString(int position) {
81                                         return m_Strings[position];
82                                 }
83                         }
84
85                         internal enum Enum {
86                                 HttpHeaderCacheControl          = 0,    // general-header [section 4.5]
87                                 HttpHeaderConnection            = 1,    // general-header [section 4.5]
88                                 HttpHeaderDate                  = 2,    // general-header [section 4.5]
89                                 HttpHeaderKeepAlive             = 3,    // general-header [not in rfc]
90                                 HttpHeaderPragma                = 4,    // general-header [section 4.5]
91                                 HttpHeaderTrailer               = 5,    // general-header [section 4.5]
92                                 HttpHeaderTransferEncoding      = 6,    // general-header [section 4.5]
93                                 HttpHeaderUpgrade               = 7,    // general-header [section 4.5]
94                                 HttpHeaderVia                   = 8,    // general-header [section 4.5]
95                                 HttpHeaderWarning               = 9,    // general-header [section 4.5]
96
97                                 HttpHeaderAllow                 = 10,   // entity-header  [section 7.1]
98                                 HttpHeaderContentLength         = 11,   // entity-header  [section 7.1]
99                                 HttpHeaderContentType           = 12,   // entity-header  [section 7.1]
100                                 HttpHeaderContentEncoding       = 13,   // entity-header  [section 7.1]
101                                 HttpHeaderContentLanguage       = 14,   // entity-header  [section 7.1]
102                                 HttpHeaderContentLocation       = 15,   // entity-header  [section 7.1]
103                                 HttpHeaderContentMd5            = 16,   // entity-header  [section 7.1]
104                                 HttpHeaderContentRange          = 17,   // entity-header  [section 7.1]
105                                 HttpHeaderExpires               = 18,   // entity-header  [section 7.1]
106                                 HttpHeaderLastModified          = 19,   // entity-header  [section 7.1]
107
108
109                                 // Response Headers
110
111                                 HttpHeaderAcceptRanges          = 20,   // response-header [section 6.2]
112                                 HttpHeaderAge                   = 21,   // response-header [section 6.2]
113                                 HttpHeaderEtag                  = 22,   // response-header [section 6.2]
114                                 HttpHeaderLocation              = 23,   // response-header [section 6.2]
115                                 HttpHeaderProxyAuthenticate     = 24,   // response-header [section 6.2]
116                                 HttpHeaderRetryAfter            = 25,   // response-header [section 6.2]
117                                 HttpHeaderServer                = 26,   // response-header [section 6.2]
118                                 HttpHeaderSetCookie             = 27,   // response-header [not in rfc]
119                                 HttpHeaderVary                  = 28,   // response-header [section 6.2]
120                                 HttpHeaderWwwAuthenticate       = 29,   // response-header [section 6.2]
121
122                                 HttpHeaderResponseMaximum       = 30,
123
124
125                                 HttpHeaderMaximum               = 41
126                         }
127
128                         private static string[] m_Strings = {
129                                 "Cache-Control",
130                                 "Connection",
131                                 "Date",
132                                 "Keep-Alive",
133                                 "Pragma",
134                                 "Trailer",
135                                 "Transfer-Encoding",
136                                 "Upgrade",
137                                 "Via",
138                                 "Warning",
139
140                                 "Allow",
141                                 "Content-Length",
142                                 "Content-Type",
143                                 "Content-Encoding",
144                                 "Content-Language",
145                                 "Content-Location",
146                                 "Content-MD5",
147                                 "Content-Range",
148                                 "Expires",
149                                 "Last-Modified",
150
151                                 "Accept-Ranges",
152                                 "Age",
153                                 "ETag",
154                                 "Location",
155                                 "Proxy-Authenticate",
156                                 "Retry-After",
157                                 "Server",
158                                 "Set-Cookie",
159                                 "Vary",
160                                 "WWW-Authenticate",
161                         };
162                 }
163         }
164 }