ゴミ箱
rfc6455.hpp
Go to the documentation of this file.
1 //
2 // Copyright (c) 2016-2017 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_WEBSOCKET_RFC6455_HPP
11 #define BOOST_BEAST_WEBSOCKET_RFC6455_HPP
12 
13 #include <boost/beast/config.hpp>
17 #include <array>
18 #include <cstdint>
19 
20 namespace boost {
21 namespace beast {
22 namespace websocket {
23 
56 template<class Allocator>
57 bool
58 is_upgrade(beast::http::header<true,
59  http::basic_fields<Allocator>> const& req);
60 
67 enum close_code : std::uint16_t
68 {
70  normal = 1000,
71 
73  going_away = 1001,
74 
77 
79  unknown_data = 1003,
80 
82  bad_payload = 1007,
83 
85  policy_error = 1008,
86 
88  too_big = 1009,
89 
92 
95 
98 
101 
102  //----
103  //
104  // The following are illegal on the wire
105  //
106 
111  none = 0,
112 
117  reserved1 = 1004,
118 
123  no_status = 1005,
124 
129  abnormal = 1006,
130 
135  reserved2 = 1014,
136 
141  reserved3 = 1015
142 
143  //
144  //----
145 
146  //last = 5000 // satisfy warnings
147 };
148 
151 
154 
161 {
163  std::uint16_t code = close_code::none;
164 
167 
173  close_reason() = default;
174 
176  close_reason(std::uint16_t code_)
177  : code(code_)
178  {
179  }
180 
183  : code(close_code::normal)
184  , reason(s)
185  {
186  }
187 
189  close_reason(char const* s)
190  : code(close_code::normal)
191  , reason(s)
192  {
193  }
194 
197  : code(code_)
198  , reason(s)
199  {
200  }
201 
203  operator bool() const
204  {
205  return code != close_code::none;
206  }
207 };
208 
209 } // websocket
210 } // beast
211 } // boost
212 
214 
215 #endif
The endpoint is going away, either because of a server failure or because the browser is navigating a...
Definition: rfc6455.hpp:73
The server is terminating the connection due to a temporary condition, e.g. it is overloaded and is c...
Definition: rfc6455.hpp:100
reason_string reason
The optional utf8-encoded reason string.
Definition: rfc6455.hpp:166
Definition: async_result.hpp:20
close_reason(char const *s)
Construct from a reason string literal. code is close_code::normal.
Definition: rfc6455.hpp:189
The connection is being terminated because the endpoint received data of a type it cannot accept (for...
Definition: rfc6455.hpp:79
Definition: rfc6455.hpp:129
Definition: rfc6455.hpp:160
The server is terminating the connection because it is restarting.
Definition: rfc6455.hpp:97
Definition: rfc6455.hpp:111
std::uint16_t code
The close code.
Definition: rfc6455.hpp:163
The server is terminating the connection because it encountered an unexpected condition that prevente...
Definition: rfc6455.hpp:94
The client is terminating the connection because it expected the server to negotiate one or more exte...
Definition: rfc6455.hpp:91
Definition: fields.hpp:53
The endpoint is terminating the connection because it received a message that violates its policy...
Definition: rfc6455.hpp:85
The endpoint is terminating the connection because a message was received that contained inconsistent...
Definition: rfc6455.hpp:82
close_code
Definition: rfc6455.hpp:67
Definition: rfc6455.hpp:141
Definition: rfc6455.hpp:123
close_reason(close_code code_, string_view s)
Construct from a close code and reason string.
Definition: rfc6455.hpp:196
The endpoint is terminating the connection because a data frame was received that is too large...
Definition: rfc6455.hpp:88
boost::string_ref string_view
The type of string view used by the library.
Definition: string.hpp:36
The endpoint is terminating the connection due to a protocol error.
Definition: rfc6455.hpp:76
Normal closure; the connection successfully completed whatever purpose for which it was created...
Definition: rfc6455.hpp:70
Definition: rfc6455.hpp:135
Definition: rfc6455.hpp:117
close_reason(string_view s)
Construct from a reason string. code is close_code::normal.
Definition: rfc6455.hpp:182
bool is_upgrade(http::header< true, http::basic_fields< Allocator >> const &req)
Definition: rfc6455.ipp:22
close_reason(std::uint16_t code_)
Construct from a code.
Definition: rfc6455.hpp:176