thttp_machine_header.rl 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /*
  2. * Copyright (C) 2010-2015 Mamadou Diop.
  3. *
  4. * This file is part of Open Source Doubango Framework.
  5. *
  6. * DOUBANGO is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * DOUBANGO is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with DOUBANGO.
  18. *
  19. */
  20. /**@file thttp_machine_headers.rl.
  21. * @brief Ragel file.
  22. */
  23. /*== Header pasrsing machine. Supports both full-length and compact mode. */
  24. %%{
  25. machine thttp_machine_header;
  26. Accept = "Accept"i SP* HCOLON SP*<: any* :>CRLF @parse_header_Accept;
  27. Accept_Charset = "Accept-Charset"i SP* HCOLON SP*<: any* :>CRLF @parse_header_Accept_Charset;
  28. Accept_Encoding = "Accept-Encoding"i SP* HCOLON SP*<: any* :>CRLF @parse_header_Accept_Encoding;
  29. Accept_Language = "Accept-Language"i SP* HCOLON SP*<: any* :>CRLF @parse_header_Accept_Language;
  30. Allow = "Allow"i SP* HCOLON SP*<: any* :>CRLF @parse_header_Allow;
  31. Authorization = "Authorization"i SP* HCOLON SP*<: any* :>CRLF @parse_header_Authorization;
  32. Cache_Control = "Cache-Control"i SP* HCOLON SP*<: any* :>CRLF @parse_header_Cache_Control;
  33. Connection = "Connection"i SP* HCOLON SP*<: any* :>CRLF @parse_header_Connection;
  34. Content_Encoding = ("Content-Encoding"i | "e") SP* HCOLON SP*<: any* :>CRLF @parse_header_Content_Encoding;
  35. Content_Language = "Content-Language"i SP* HCOLON SP*<: any* :>CRLF @parse_header_Content_Language;
  36. Content_Length = "Content-Length"i SP* HCOLON SP*<: any* :>CRLF @parse_header_Content_Length;
  37. Content_Location = "Content-Location"i SP* HCOLON SP*<: any* :>CRLF @parse_header_Content_Location;
  38. Content_MD5 = "Content-MD5"i SP* HCOLON SP*<: any* :>CRLF @parse_header_Content_MD5;
  39. Content_Range = "Content-Range"i SP* HCOLON SP*<: any* :>CRLF @parse_header_Content_Range;
  40. Content_Type = ("Content-Type"i | "c") SP* HCOLON SP*<: any* :>CRLF @parse_header_Content_Type;
  41. Date = "Date"i SP* HCOLON SP*<: any* :>CRLF @parse_header_Date;
  42. ETag = "ETag"i SP* HCOLON SP*<: any* :>CRLF @parse_header_ETag;
  43. Expect = "Expect"i SP* HCOLON SP*<: any* :>CRLF @parse_header_Expect;
  44. Expires = "Expires"i SP* HCOLON SP*<: any* :>CRLF @parse_header_Expires;
  45. From = "From"i SP* HCOLON SP*<: any* :>CRLF @parse_header_From;
  46. Host = "Host"i SP* HCOLON SP*<: any* :>CRLF @parse_header_Host;
  47. If_Match = "If-Match"i SP* HCOLON SP*<: any* :>CRLF @parse_header_If_Match;
  48. If_Modified_Since = "If-Modified-Since"i SP* HCOLON SP*<: any* :>CRLF @parse_header_If_Modified_Since;
  49. If_None_Match = "If-None-Match"i SP* HCOLON SP*<: any* :>CRLF @parse_header_If_None_Match;
  50. If_Range = "If-Range"i SP* HCOLON SP*<: any* :>CRLF @parse_header_If_Range;
  51. If_Unmodified_Since = "If-Unmodified-Since"i SP* HCOLON SP*<: any* :>CRLF @parse_header_If_Unmodified_Since;
  52. Last_Modified = "Last-Modified"i SP* HCOLON SP*<: any* :>CRLF @parse_header_Last_Modified;
  53. Max_Forwards = "Max-Forwards"i SP* HCOLON SP*<: any* :>CRLF @parse_header_Max_Forwards;
  54. Pragma = "Pragma"i SP* HCOLON SP*<: any* :>CRLF @parse_header_Pragma;
  55. Proxy_Authenticate = "Proxy-Authenticate"i SP* HCOLON SP*<: any* :>CRLF @parse_header_Proxy_Authenticate;
  56. Proxy_Authorization = "Proxy-Authorization"i SP* HCOLON SP*<: any* :>CRLF @parse_header_Proxy_Authorization;
  57. Range = "Range"i SP* HCOLON SP*<: any* :>CRLF @parse_header_Range;
  58. Referer = "Referer"i SP* HCOLON SP*<: any* :>CRLF @parse_header_Referer;
  59. Transfer_Encoding = "Transfer-Encoding"i SP* HCOLON SP*<: any* :>CRLF @parse_header_Transfer_Encoding;
  60. TE = "TE"i SP* HCOLON SP*<: any* :>CRLF @parse_header_TE;
  61. Trailer = "Trailer"i SP* HCOLON SP*<: any* :>CRLF @parse_header_Trailer;
  62. Upgrade = "Upgrade"i SP* HCOLON SP*<: any* :>CRLF @parse_header_Upgrade;
  63. User_Agent = "User-Agent"i SP* HCOLON SP*<: any* :>CRLF @parse_header_User_Agent;
  64. Via = "Via"i SP* HCOLON SP*<: any* :>CRLF @parse_header_Via;
  65. Warning = "Warning"i SP* HCOLON SP*<: any* :>CRLF @parse_header_Warning;
  66. WWW_Authenticate = "WWW-Authenticate"i SP* HCOLON SP*<: any* :>CRLF @parse_header_WWW_Authenticate;
  67. # WebSocket
  68. Sec_WebSocket_Accept = "Sec-WebSocket-Accept"i SP* HCOLON SP*<: any* :>CRLF @parse_header_Sec_WebSocket_Accept;
  69. Sec_WebSocket_Key = "Sec-WebSocket-Key"i SP* HCOLON SP*<: any* :>CRLF @parse_header_Sec_WebSocket_Key;
  70. Sec_WebSocket_Protocol = "Sec-WebSocket-Protocol"i SP* HCOLON SP*<: any* :>CRLF @parse_header_Sec_WebSocket_Protocol;
  71. Sec_WebSocket_Version = "Sec-WebSocket-Version"i SP* HCOLON SP*<: any* :>CRLF @parse_header_Sec_WebSocket_Version;
  72. ######
  73. extension_header = (token) SP* HCOLON SP*<: any* :>CRLF @parse_header_extension_header;
  74. general_header = Cache_Control | Connection | Date | Pragma | Trailer | Transfer_Encoding | Upgrade | Via | Warning;
  75. auth_header = Authorization | WWW_Authenticate | Proxy_Authorization | Proxy_Authenticate;
  76. request_header = Accept | Accept_Charset | Accept_Encoding | Accept_Language | Expect | From | Host | If_Match | If_Modified_Since | If_None_Match | If_Range | If_Unmodified_Since | Max_Forwards | Range | Referer | TE | User_Agent;
  77. entity_header = Allow | Content_Encoding | Content_Language | Content_Length | Content_Location | Content_MD5 | Content_Range | Content_Type | ETag | Expires | Last_Modified;
  78. ws_header = Sec_WebSocket_Accept | Sec_WebSocket_Key | Sec_WebSocket_Protocol | Sec_WebSocket_Version;
  79. HEADER = (general_header | auth_header | request_header | entity_header | ws_header)@1 | extension_header@0;
  80. }%%