thttp_machine_message.rl 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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_message.rl
  21. * @brief Ragel file.
  22. */
  23. %%{
  24. machine thttp_machine_message;
  25. message_body = any*;
  26. HTTP_Version = ("HTTP"i "/" DIGIT+ "." DIGIT+)>tag %parse_httpversion;
  27. message_header = any+ >tag :>CRLF %parse_header;
  28. # HTTP RESPONSE
  29. Reason_Phrase = (( reserved | unreserved | escaped | UTF8_NONASCII | UTF8_CONT | SP | HTAB )*)>tag %parse_reason_phrase;
  30. Status_Line = HTTP_Version :>SP Status_Code>tag %parse_status_code :>SP Reason_Phrase :>CRLF;
  31. Response = Status_Line (message_header* :>CRLF);
  32. # HTTP REQUEST
  33. URI = (any+)>tag %parse_requesturl;
  34. Request_URI = URI;
  35. Request_Line = Method>tag %parse_method :>SP Request_URI :>SP HTTP_Version :>CRLF;
  36. Request = Request_Line (message_header* :>CRLF);
  37. # HTTP MESSAGE
  38. HTTP_message = (Response | Request)>1 @eoh message_body?>0;
  39. }%%