verb.hpp 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. //
  2. // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com)
  3. //
  4. // Distributed under the Boost Software License, Version 1.0. (See accompanying
  5. // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  6. //
  7. // Official repository: https://github.com/boostorg/beast
  8. //
  9. #ifndef BOOST_BEAST_HTTP_VERB_HPP
  10. #define BOOST_BEAST_HTTP_VERB_HPP
  11. #include <boost/beast/core/detail/config.hpp>
  12. #include <boost/beast/core/string.hpp>
  13. #include <iosfwd>
  14. namespace boost {
  15. namespace beast {
  16. namespace http {
  17. /** HTTP request method verbs
  18. Each verb corresponds to a particular method string
  19. used in HTTP request messages.
  20. */
  21. enum class verb
  22. {
  23. /** An unknown method.
  24. This value indicates that the request method string is not
  25. one of the recognized verbs. Callers interested in the method
  26. should use an interface which returns the original string.
  27. */
  28. unknown = 0,
  29. /// The DELETE method deletes the specified resource
  30. delete_,
  31. /** The GET method requests a representation of the specified resource.
  32. Requests using GET should only retrieve data and should have no other effect.
  33. */
  34. get,
  35. /** The HEAD method asks for a response identical to that of a GET request, but without the response body.
  36. This is useful for retrieving meta-information written in response
  37. headers, without having to transport the entire content.
  38. */
  39. head,
  40. /** The POST method requests that the server accept the entity enclosed in the request as a new subordinate of the web resource identified by the URI.
  41. The data POSTed might be, for example, an annotation for existing
  42. resources; a message for a bulletin board, newsgroup, mailing list,
  43. or comment thread; a block of data that is the result of submitting
  44. a web form to a data-handling process; or an item to add to a database
  45. */
  46. post,
  47. /** The PUT method requests that the enclosed entity be stored under the supplied URI.
  48. If the URI refers to an already existing resource, it is modified;
  49. if the URI does not point to an existing resource, then the server
  50. can create the resource with that URI.
  51. */
  52. put,
  53. /** The CONNECT method converts the request connection to a transparent TCP/IP tunnel.
  54. This is usually to facilitate SSL-encrypted communication (HTTPS)
  55. through an unencrypted HTTP proxy.
  56. */
  57. connect,
  58. /** The OPTIONS method returns the HTTP methods that the server supports for the specified URL.
  59. This can be used to check the functionality of a web server by requesting
  60. '*' instead of a specific resource.
  61. */
  62. options,
  63. /** The TRACE method echoes the received request so that a client can see what (if any) changes or additions have been made by intermediate servers.
  64. */
  65. trace,
  66. // WebDAV
  67. copy,
  68. lock,
  69. mkcol,
  70. move,
  71. propfind,
  72. proppatch,
  73. search,
  74. unlock,
  75. bind,
  76. rebind,
  77. unbind,
  78. acl,
  79. // subversion
  80. report,
  81. mkactivity,
  82. checkout,
  83. merge,
  84. // upnp
  85. msearch,
  86. notify,
  87. subscribe,
  88. unsubscribe,
  89. // RFC-5789
  90. patch,
  91. purge,
  92. // CalDAV
  93. mkcalendar,
  94. // RFC-2068, section 19.6.1.2
  95. link,
  96. unlink
  97. };
  98. /** Converts a string to the request method verb.
  99. If the string does not match a known request method,
  100. @ref verb::unknown is returned.
  101. */
  102. BOOST_BEAST_DECL
  103. verb
  104. string_to_verb(string_view s);
  105. /// Returns the text representation of a request method verb.
  106. BOOST_BEAST_DECL
  107. string_view
  108. to_string(verb v);
  109. /// Write the text for a request method verb to an output stream.
  110. inline
  111. std::ostream&
  112. operator<<(std::ostream& os, verb v)
  113. {
  114. return os << to_string(v);
  115. }
  116. } // http
  117. } // beast
  118. } // boost
  119. #ifdef BOOST_BEAST_HEADER_ONLY
  120. #include <boost/beast/http/impl/verb.ipp>
  121. #endif
  122. #endif