| 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 | |
| 10 | #ifndef BOOST_BEAST_HTTP_VERB_HPP |
| 11 | #define BOOST_BEAST_HTTP_VERB_HPP |
| 12 | |
| 13 | #include <boost/beast/core/detail/config.hpp> |
| 14 | #include <boost/beast/core/string.hpp> |
| 15 | #include <iosfwd> |
| 16 | |
| 17 | namespace boost { |
| 18 | namespace beast { |
| 19 | namespace http { |
| 20 | |
| 21 | /** HTTP request method verbs |
| 22 | |
| 23 | Each verb corresponds to a particular method string |
| 24 | used in HTTP request messages. |
| 25 | */ |
| 26 | enum class verb |
| 27 | { |
| 28 | /** An unknown method. |
| 29 | |
| 30 | This value indicates that the request method string is not |
| 31 | one of the recognized verbs. Callers interested in the method |
| 32 | should use an interface which returns the original string. |
| 33 | */ |
| 34 | unknown = 0, |
| 35 | |
| 36 | /// The DELETE method deletes the specified resource |
| 37 | delete_, |
| 38 | |
| 39 | /** The GET method requests a representation of the specified resource. |
| 40 | |
| 41 | Requests using GET should only retrieve data and should have no other effect. |
| 42 | */ |
| 43 | get, |
| 44 | |
| 45 | /** The HEAD method asks for a response identical to that of a GET request, but without the response body. |
| 46 | |
| 47 | This is useful for retrieving meta-information written in response |
| 48 | headers, without having to transport the entire content. |
| 49 | */ |
| 50 | head, |
| 51 | |
| 52 | /** 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. |
| 53 | |
| 54 | The data POSTed might be, for example, an annotation for existing |
| 55 | resources; a message for a bulletin board, newsgroup, mailing list, |
| 56 | or comment thread; a block of data that is the result of submitting |
| 57 | a web form to a data-handling process; or an item to add to a database |
| 58 | */ |
| 59 | post, |
| 60 | |
| 61 | /** The PUT method requests that the enclosed entity be stored under the supplied URI. |
| 62 | |
| 63 | If the URI refers to an already existing resource, it is modified; |
| 64 | if the URI does not point to an existing resource, then the server |
| 65 | can create the resource with that URI. |
| 66 | */ |
| 67 | put, |
| 68 | |
| 69 | /** The CONNECT method converts the request connection to a transparent TCP/IP tunnel. |
| 70 | |
| 71 | This is usually to facilitate SSL-encrypted communication (HTTPS) |
| 72 | through an unencrypted HTTP proxy. |
| 73 | */ |
| 74 | connect, |
| 75 | |
| 76 | /** The OPTIONS method returns the HTTP methods that the server supports for the specified URL. |
| 77 | |
| 78 | This can be used to check the functionality of a web server by requesting |
| 79 | '*' instead of a specific resource. |
| 80 | */ |
| 81 | options, |
| 82 | |
| 83 | /** 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. |
| 84 | */ |
| 85 | trace, |
| 86 | |
| 87 | // WebDAV |
| 88 | |
| 89 | copy, |
| 90 | lock, |
| 91 | mkcol, |
| 92 | move, |
| 93 | propfind, |
| 94 | proppatch, |
| 95 | search, |
| 96 | unlock, |
| 97 | bind, |
| 98 | rebind, |
| 99 | unbind, |
| 100 | acl, |
| 101 | |
| 102 | // subversion |
| 103 | |
| 104 | report, |
| 105 | mkactivity, |
| 106 | checkout, |
| 107 | merge, |
| 108 | |
| 109 | // upnp |
| 110 | |
| 111 | msearch, |
| 112 | notify, |
| 113 | subscribe, |
| 114 | unsubscribe, |
| 115 | |
| 116 | // RFC-5789 |
| 117 | |
| 118 | patch, |
| 119 | purge, |
| 120 | |
| 121 | // CalDAV |
| 122 | |
| 123 | mkcalendar, |
| 124 | |
| 125 | // RFC-2068, section 19.6.1.2 |
| 126 | |
| 127 | link, |
| 128 | unlink |
| 129 | }; |
| 130 | |
| 131 | /** Converts a string to the request method verb. |
| 132 | |
| 133 | If the string does not match a known request method, |
| 134 | @ref verb::unknown is returned. |
| 135 | */ |
| 136 | BOOST_BEAST_DECL |
| 137 | verb |
| 138 | string_to_verb(string_view s); |
| 139 | |
| 140 | /// Returns the text representation of a request method verb. |
| 141 | BOOST_BEAST_DECL |
| 142 | string_view |
| 143 | to_string(verb v); |
| 144 | |
| 145 | /// Write the text for a request method verb to an output stream. |
| 146 | inline |
| 147 | std::ostream& |
| 148 | operator<<(std::ostream& os, verb v) |
| 149 | { |
| 150 | return os << to_string(v); |
| 151 | } |
| 152 | |
| 153 | } // http |
| 154 | } // beast |
| 155 | } // boost |
| 156 | |
| 157 | #ifdef BOOST_BEAST_HEADER_ONLY |
| 158 | #include <boost/beast/http/impl/verb.ipp> |
| 159 | #endif |
| 160 | |
| 161 | #endif |
| 162 | |