1 /****************************************************************************** 2 3 HTTP header field name constants 4 5 Copyright: 6 Copyright (c) 2009-2016 dunnhumby Germany GmbH. 7 All rights reserved. 8 9 License: 10 Boost Software License Version 1.0. See LICENSE_BOOST.txt for details. 11 Alternatively, this file may be distributed under the terms of the Tango 12 3-Clause BSD License (see LICENSE_BSD.txt for details). 13 14 ******************************************************************************/ 15 16 module ocean.net.http.consts.HeaderFieldNames; 17 18 19 import ocean.meta.types.Qualifiers; 20 21 22 /******************************************************************************/ 23 24 struct HeaderFieldNames 25 { 26 /************************************************************************** 27 28 General header fields for request and response 29 @see http://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html#sec4.5 30 31 **************************************************************************/ 32 33 struct General 34 { 35 istring CacheControl, Connection, Date, 36 Pragma, Trailer, TransferEncoding, 37 Upgrade, Via, Warning; 38 39 alias HeaderFieldNames.GeneralNames Names; 40 alias HeaderFieldNames.GeneralNameList NameList; 41 } 42 43 /************************************************************************** 44 45 Constant instance holding field names 46 47 **************************************************************************/ 48 49 enum General GeneralNames = 50 { 51 CacheControl: "Cache-Control", 52 Connection: "Connection", 53 Date: "Date", 54 Pragma: "Pragma", 55 Trailer: "Trailer", 56 TransferEncoding: "Transfer-Encoding", 57 Upgrade: "Upgrade", 58 Via: "Via", 59 Warning: "Warning" 60 }; 61 62 /************************************************************************** 63 64 List of field names. 65 66 (Two arrays as a workaround for the issue that it is impossible to have 67 run-time initialised static array constants.) 68 69 **************************************************************************/ 70 71 public static istring[] GeneralNameList ( ) 72 { 73 return _GeneralNameList; 74 } 75 76 private static istring[] _GeneralNameList; 77 78 private static istring[GeneralNames.tupleof.length] GeneralNameList_; 79 80 /************************************************************************** 81 82 Request specific header fields in addition to the General fields 83 @see http://www.w3.org/Protocols/rfc2616/rfc2616-sec5.html#sec5.3 84 85 **************************************************************************/ 86 87 struct Request 88 { 89 istring Accept, AcceptCharset, AcceptEncoding, 90 AcceptLanguage, Authorization, Cookie, 91 Expect, From, Host, 92 IfMatch, IfModifiedSince, IfNoneMatch, 93 IfRange, IfUnmodifiedSince, MaxForwards, 94 ProxyAuthorization, Range, Referer, 95 TE, UserAgent; 96 97 alias HeaderFieldNames.RequestNames Names; 98 alias HeaderFieldNames.RequestNameList NameList; 99 } 100 101 /********************************************************************** 102 103 Constant instance holding field names 104 105 **********************************************************************/ 106 107 enum Request RequestNames = 108 { 109 Accept: "Accept", 110 AcceptCharset: "Accept-Charset", 111 AcceptEncoding: "Accept-Encoding", 112 AcceptLanguage: "Accept-Language", 113 Authorization: "Authorization", 114 Cookie: "Cookie", 115 Expect: "Expect", 116 From: "From", 117 Host: "Host", 118 IfMatch: "If-Match", 119 IfModifiedSince: "If-Modified-Since", 120 IfNoneMatch: "If-None-Match", 121 IfRange: "If-Range", 122 IfUnmodifiedSince: "If-Unmodified-Since", 123 MaxForwards: "Max-Forwards", 124 ProxyAuthorization: "Proxy-Authorization", 125 Range: "Range", 126 Referer: "Referer", 127 TE: "TE", 128 UserAgent: "User-Agent" 129 }; 130 131 /************************************************************************** 132 133 List of field names. 134 135 (Two arrays as a workaround for the issue that it is impossible to have 136 run-time initialised static array constants.) 137 138 **************************************************************************/ 139 140 public static istring[] RequestNameList; 141 142 private static istring[RequestNames.tupleof.length] RequestNameList_; 143 144 /************************************************************************** 145 146 Response specific header fields in addition to the Genereal fields 147 @see http://www.w3.org/Protocols/rfc2616/rfc2616-sec6.html#sec6.2 148 149 **************************************************************************/ 150 151 struct Response 152 { 153 istring AcceptRanges, Age, ETag, 154 Location, ProxyAuthenticate, RetryAfter, 155 Server, Vary, WwwAuthenticate, 156 Allow, ContentEncoding, ContentLanguage, 157 ContentLength, ContentLocation, ContentMD5, 158 ContentRange, ContentType, Expires, 159 LastModified, SetCookie; 160 161 alias HeaderFieldNames.ResponseNames Names; 162 alias HeaderFieldNames.ResponseNameList NameList; 163 } 164 165 /********************************************************************** 166 167 Constant instance holding field names 168 169 **********************************************************************/ 170 171 enum Response ResponseNames = 172 { 173 AcceptRanges: "Accept-Ranges", 174 Age: "Age", 175 ETag: "ETag", 176 Location: "Location", 177 ProxyAuthenticate: "Proxy-Authenticate", 178 RetryAfter: "Retry-After", 179 Server: "Server", 180 Vary: "Vary", 181 WwwAuthenticate: "WWW-Authenticate", 182 Allow: "Allow", 183 ContentEncoding: "Content-Encoding", 184 ContentLanguage: "Content-Language", 185 ContentLength: "Content-Length", 186 ContentLocation: "Content-Location", 187 ContentMD5: "Content-MD5", 188 ContentRange: "Content-Range", 189 ContentType: "Content-Type", 190 Expires: "Expires", 191 LastModified: "Last-Modified", 192 SetCookie: "Set-Cookie" 193 }; 194 195 /************************************************************************** 196 197 List of field names. 198 199 (Two arrays as a workaround for the issue that it is impossible to have 200 run-time initialised static array constants.) 201 202 **************************************************************************/ 203 204 public static istring[] ResponseNameList; 205 206 private static istring[ResponseNames.tupleof.length] ResponseNameList_; 207 208 /************************************************************************** 209 210 Entity header fields for requests/responses which support entities. 211 @see http://www.w3.org/Protocols/rfc2616/rfc2616-sec7.html#sec7.1 212 213 **************************************************************************/ 214 215 struct Entity 216 { 217 istring Allow, ContentEncoding, ContentLanguage, 218 ContentLength, ContentLocation, ContentMD5, 219 ContentRange, ContentType, Expires, 220 LastModified; 221 222 alias HeaderFieldNames.EntityNames Names; 223 alias HeaderFieldNames.EntityNameList NameList; 224 } 225 226 /********************************************************************** 227 228 Constant instance holding field names 229 230 **********************************************************************/ 231 232 enum Entity EntityNames = 233 { 234 Allow: "Allow", 235 ContentEncoding: "Content-Encoding", 236 ContentLanguage: "Content-Language", 237 ContentLength: "Content-Length", 238 ContentLocation: "Content-Location", 239 ContentMD5: "Content-MD5", 240 ContentRange: "Content-Range", 241 ContentType: "Content-Type", 242 Expires: "Expires", 243 LastModified: "Last-Modified" 244 }; 245 246 /************************************************************************** 247 248 List of field names. 249 250 (Two arrays as a workaround for the issue that it is impossible to have 251 run-time initialised static array constants.) 252 253 **************************************************************************/ 254 255 public static istring[] EntityNameList; 256 257 private static istring[EntityNames.tupleof.length] EntityNameList_; 258 259 /************************************************************************** 260 261 Static constructor, populates the lists of field names. 262 263 **************************************************************************/ 264 265 static this ( ) 266 { 267 foreach (i, name; GeneralNames.tupleof) 268 { 269 GeneralNameList_[i] = name; 270 } 271 272 _GeneralNameList = GeneralNameList_; 273 274 foreach (i, name; RequestNames.tupleof) 275 { 276 RequestNameList_[i] = name; 277 } 278 279 RequestNameList = RequestNameList_; 280 281 foreach (i, name; ResponseNames.tupleof) 282 { 283 ResponseNameList_[i] = name; 284 } 285 286 ResponseNameList = ResponseNameList_; 287 288 foreach (i, name; EntityNames.tupleof) 289 { 290 EntityNameList_[i] = name; 291 } 292 293 EntityNameList = EntityNameList_; 294 } 295 296 // Assertion check for the struct members 297 298 static assert(General.Names.CacheControl == "Cache-Control"); 299 static assert(General.Names.Connection == "Connection"); 300 static assert(General.Names.Date == "Date"); 301 static assert(General.Names.Pragma == "Pragma"); 302 static assert(General.Names.Trailer == "Trailer"); 303 static assert(General.Names.TransferEncoding == "Transfer-Encoding"); 304 static assert(General.Names.Upgrade == "Upgrade"); 305 static assert(General.Names.Via == "Via"); 306 static assert(General.Names.Warning == "Warning"); 307 308 static assert(Request.Names.Accept == "Accept"); 309 static assert(Request.Names.AcceptCharset == "Accept-Charset"); 310 static assert(Request.Names.AcceptEncoding == "Accept-Encoding"); 311 static assert(Request.Names.AcceptLanguage == "Accept-Language"); 312 static assert(Request.Names.Authorization == "Authorization"); 313 static assert(Request.Names.Cookie == "Cookie"); 314 static assert(Request.Names.Expect == "Expect"); 315 static assert(Request.Names.From == "From"); 316 static assert(Request.Names.Host == "Host"); 317 static assert(Request.Names.IfMatch == "If-Match"); 318 static assert(Request.Names.IfModifiedSince == "If-Modified-Since"); 319 static assert(Request.Names.IfNoneMatch == "If-None-Match"); 320 static assert(Request.Names.IfRange == "If-Range"); 321 static assert(Request.Names.IfUnmodifiedSince == "If-Unmodified-Since"); 322 static assert(Request.Names.MaxForwards == "Max-Forwards"); 323 static assert(Request.Names.ProxyAuthorization == "Proxy-Authorization"); 324 static assert(Request.Names.Range == "Range"); 325 static assert(Request.Names.Referer == "Referer"); 326 static assert(Request.Names.TE == "TE"); 327 static assert(Request.Names.UserAgent == "User-Agent"); 328 329 static assert(Response.Names.AcceptRanges == "Accept-Ranges"); 330 static assert(Response.Names.Age == "Age"); 331 static assert(Response.Names.ETag == "ETag"); 332 static assert(Response.Names.Location == "Location"); 333 static assert(Response.Names.ProxyAuthenticate == "Proxy-Authenticate"); 334 static assert(Response.Names.RetryAfter == "Retry-After"); 335 static assert(Response.Names.Server == "Server"); 336 static assert(Response.Names.Vary == "Vary"); 337 static assert(Response.Names.WwwAuthenticate == "WWW-Authenticate"); 338 static assert(Response.Names.Allow == "Allow"); 339 static assert(Response.Names.ContentEncoding == "Content-Encoding"); 340 static assert(Response.Names.ContentLanguage == "Content-Language"); 341 static assert(Response.Names.ContentLength == "Content-Length"); 342 static assert(Response.Names.ContentLocation == "Content-Location"); 343 static assert(Response.Names.ContentMD5 == "Content-MD5"); 344 static assert(Response.Names.ContentRange == "Content-Range"); 345 static assert(Response.Names.ContentType == "Content-Type"); 346 static assert(Response.Names.Expires == "Expires"); 347 static assert(Response.Names.LastModified == "Last-Modified"); 348 static assert(Response.Names.SetCookie == "Set-Cookie"); 349 350 static assert(Entity.Names.Allow == "Allow"); 351 static assert(Entity.Names.ContentEncoding == "Content-Encoding"); 352 static assert(Entity.Names.ContentLanguage == "Content-Language"); 353 static assert(Entity.Names.ContentLength == "Content-Length"); 354 static assert(Entity.Names.ContentLocation == "Content-Location"); 355 static assert(Entity.Names.ContentMD5 == "Content-MD5"); 356 static assert(Entity.Names.ContentRange == "Content-Range"); 357 static assert(Entity.Names.ContentType == "Content-Type"); 358 static assert(Entity.Names.Expires == "Expires"); 359 static assert(Entity.Names.LastModified == "Last-Modified"); 360 }