ゴミ箱
stream.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_STREAM_HPP
11 #define BOOST_BEAST_WEBSOCKET_STREAM_HPP
12 
13 #include <boost/beast/config.hpp>
34 #include <boost/asio/error.hpp>
35 #include <algorithm>
36 #include <cstdint>
37 #include <functional>
38 #include <limits>
39 #include <type_traits>
40 
41 namespace boost {
42 namespace beast {
43 namespace websocket {
44 
45 namespace detail {
46 class frame_test;
47 }
48 
51 
54 
60 enum class frame_type
61 {
63  close,
64 
66  ping,
67 
69  pong
70 };
71 
72 //--------------------------------------------------------------------
73 
116 template<class NextLayer>
117 class stream
118 {
119  friend class close_test;
120  friend class frame_test;
121  friend class ping_test;
122  friend class read_test;
123  friend class stream_test;
124  friend class write_test;
125 
126  /* The read buffer has to be at least as large
127  as the largest possible control frame including
128  the frame header.
129  */
130  static std::size_t constexpr max_control_frame_size = 2 + 8 + 4 + 125;
131  static std::size_t constexpr tcp_frame_size = 1536;
132 
133  struct op {};
134 
135  using control_cb_type =
136  std::function<void(frame_type, string_view)>;
137 
138  // tokens are used to order reads and writes
139  class token
140  {
141  unsigned char id_ = 0;
142  public:
143  token() = default;
144  token(token const&) = default;
145  explicit token(unsigned char id) : id_(id) {}
146  operator bool() const { return id_ != 0; }
147  bool operator==(token const& t) { return id_ == t.id_; }
148  bool operator!=(token const& t) { return id_ != t.id_; }
149  token unique() { token t{id_++}; if(id_ == 0) ++id_; return t; }
150  void reset() { id_ = 0; }
151  };
152 
153  // State information for the permessage-deflate extension
154  struct pmd_t
155  {
156  // `true` if current read message is compressed
157  bool rd_set = false;
158 
161  };
162 
163  enum class status
164  {
165  open,
166  closing,
167  closed,
168  failed
169  };
170 
171  NextLayer stream_; // the wrapped stream
172  close_reason cr_; // set from received close frame
173  control_cb_type ctrl_cb_; // control callback
174 
175  std::size_t rd_msg_max_ // max message size
176  = 16 * 1024 * 1024;
177  std::uint64_t rd_size_ // total size of current message so far
178  = 0;
179  std::uint64_t rd_remain_ // message frame bytes left in current frame
180  = 0;
181  detail::frame_header rd_fh_; // current frame header
182  detail::prepared_key rd_key_ // current stateful mask key
183  = 0;
184  detail::frame_buffer rd_fb_; // to write control frames (during reads)
185  detail::utf8_checker rd_utf8_; // to validate utf8
187  +tcp_frame_size> rd_buf_; // buffer for reads
188  detail::opcode rd_op_ // current message binary or text
190  bool rd_cont_ // `true` if the next frame is a continuation
191  = false;
192  bool rd_done_ // set when a message is done
193  = true;
194  bool rd_close_ // did we read a close frame?
195  = false;
196  token rd_block_; // op currenly reading
197 
198  token tok_; // used to order asynchronous ops
199  role_type role_ // server or client
201  status status_
202  = status::closed;
203 
204  token wr_block_; // op currenly writing
205  bool wr_close_ // did we write a close frame?
206  = false;
207  bool wr_cont_ // next write is a continuation
208  = false;
209  bool wr_frag_ // autofrag the current message
210  = false;
211  bool wr_frag_opt_ // autofrag option setting
212  = true;
213  bool wr_compress_ // compress current message
214  = false;
215  detail::opcode wr_opcode_ // message type
217  std::unique_ptr<
218  std::uint8_t[]> wr_buf_; // write buffer
219  std::size_t wr_buf_size_ // write buffer size (current message)
220  = 0;
221  std::size_t wr_buf_opt_ // write buffer size option setting
222  = 4096;
223  detail::fh_buffer wr_fb_; // header buffer used for writes
224  detail::maskgen wr_gen_; // source of mask keys
225 
226  detail::pausation paused_rd_; // paused read op
227  detail::pausation paused_wr_; // paused write op
228  detail::pausation paused_ping_; // paused ping op
229  detail::pausation paused_close_; // paused close op
230  detail::pausation paused_r_rd_; // paused read op (read)
231  detail::pausation paused_r_close_;// paused close op (read)
232 
233  std::unique_ptr<pmd_t> pmd_; // pmd settings or nullptr
234  permessage_deflate pmd_opts_; // local pmd options
235  detail::pmd_offer pmd_config_; // offer (client) or negotiation (server)
236 
237 public:
239  using next_layer_type =
240  typename std::remove_reference<NextLayer>::type;
241 
243  using lowest_layer_type =
245 
253  ~stream() = default;
254 
263  stream(stream&&) = default;
264 
273  stream& operator=(stream&&) = default;
274 
286  template<class... Args>
287  explicit
288  stream(Args&&... args);
289 
290  //--------------------------------------------------------------------------
291 
301  boost::asio::io_service&
303  {
304  return stream_.get_io_service();
305  }
306 
317  {
318  return stream_;
319  }
320 
329  next_layer_type const&
330  next_layer() const
331  {
332  return stream_;
333  }
334 
345  {
346  return stream_.lowest_layer();
347  }
348 
357  lowest_layer_type const&
358  lowest_layer() const
359  {
360  return stream_.lowest_layer();
361  }
362 
363  //--------------------------------------------------------------------------
364  //
365  // Observers
366  //
367  //--------------------------------------------------------------------------
368 
374  bool
375  is_open() const
376  {
377  return status_ == status::open;
378  }
379 
389  bool
390  got_binary() const
391  {
392  return rd_op_ == detail::opcode::binary;
393  }
394 
404  bool
405  got_text() const
406  {
407  return ! got_binary();
408  }
409 
411  bool
413  {
414  return rd_done_;
415  }
416 
421  close_reason const&
422  reason() const
423  {
424  return cr_;
425  }
426 
440  std::size_t
441  read_size_hint(
442  std::size_t initial_size = +tcp_frame_size) const;
443 
457  template<class DynamicBuffer
458 #if ! BOOST_BEAST_DOXYGEN
459  , class = typename std::enable_if<
460  ! std::is_integral<DynamicBuffer>::value>::type
461 #endif
462  >
463  std::size_t
464  read_size_hint(
465  DynamicBuffer& buffer) const;
466 
467  //--------------------------------------------------------------------------
468  //
469  // Settings
470  //
471  //--------------------------------------------------------------------------
472 
474  void
475  set_option(permessage_deflate const& o);
476 
478  void
480  {
481  o = pmd_opts_;
482  }
483 
503  void
504  auto_fragment(bool value)
505  {
506  wr_frag_opt_ = value;
507  }
508 
510  bool
512  {
513  return wr_frag_opt_;
514  }
515 
535  void
536  binary(bool value)
537  {
538  wr_opcode_ = value ?
541  }
542 
544  bool
545  binary() const
546  {
547  return wr_opcode_ == detail::opcode::binary;
548  }
549 
590  template<class Callback>
591  void
592  control_callback(Callback& cb)
593  {
594  // Callback may not be constant, caller is responsible for
595  // managing the lifetime of the callback. Copies are not made.
596  BOOST_STATIC_ASSERT(! std::is_const<Callback>::value);
597 
598  ctrl_cb_ = std::ref(cb);
599  }
600 
605  void
607  {
608  ctrl_cb_ = {};
609  }
610 
628  void
629  read_message_max(std::size_t amount)
630  {
631  rd_msg_max_ = amount;
632  }
633 
635  std::size_t
637  {
638  return rd_msg_max_;
639  }
640 
666  void
667  write_buffer_size(std::size_t amount)
668  {
669  if(amount < 8)
670  BOOST_THROW_EXCEPTION(std::invalid_argument{
671  "write buffer size underflow"});
672  wr_buf_opt_ = amount;
673  };
674 
676  std::size_t
678  {
679  return wr_buf_opt_;
680  }
681 
701  void
702  text(bool value)
703  {
704  wr_opcode_ = value ?
707  }
708 
710  bool
711  text() const
712  {
713  return wr_opcode_ == detail::opcode::text;
714  }
715 
716  //--------------------------------------------------------------------------
717  //
718  // Handshaking (Client)
719  //
720  //--------------------------------------------------------------------------
721 
761  void
762  handshake(
763  string_view host,
764  string_view target);
765 
809  void
810  handshake(
811  response_type& res,
812  string_view host,
813  string_view target);
814 
867  template<class RequestDecorator>
868  void
869  handshake_ex(
870  string_view host,
871  string_view target,
872  RequestDecorator const& decorator);
873 
930  template<class RequestDecorator>
931  void
932  handshake_ex(
933  response_type& res,
934  string_view host,
935  string_view target,
936  RequestDecorator const& decorator);
937 
975  void
976  handshake(
977  string_view host,
978  string_view target,
979  error_code& ec);
980 
1022  void
1023  handshake(
1024  response_type& res,
1025  string_view host,
1026  string_view target,
1027  error_code& ec);
1028 
1080  template<class RequestDecorator>
1081  void
1082  handshake_ex(
1083  string_view host,
1084  string_view target,
1085  RequestDecorator const& decorator,
1086  error_code& ec);
1087 
1143  template<class RequestDecorator>
1144  void
1145  handshake_ex(
1146  response_type& res,
1147  string_view host,
1148  string_view target,
1149  RequestDecorator const& decorator,
1150  error_code& ec);
1151 
1192  template<class HandshakeHandler>
1193 #if BOOST_BEAST_DOXYGEN
1194  void_or_deduced
1195 #else
1197  HandshakeHandler, void(error_code)>
1198 #endif
1199  async_handshake(
1200  string_view host,
1201  string_view target,
1202  HandshakeHandler&& handler);
1203 
1248  template<class HandshakeHandler>
1249 #if BOOST_BEAST_DOXYGEN
1250  void_or_deduced
1251 #else
1253  HandshakeHandler, void(error_code)>
1254 #endif
1255  async_handshake(
1256  response_type& res,
1257  string_view host,
1258  string_view target,
1259  HandshakeHandler&& handler);
1260 
1310  template<class RequestDecorator, class HandshakeHandler>
1311 #if BOOST_BEAST_DOXYGEN
1312  void_or_deduced
1313 #else
1315  HandshakeHandler, void(error_code)>
1316 #endif
1317  async_handshake_ex(
1318  string_view host,
1319  string_view target,
1320  RequestDecorator const& decorator,
1321  HandshakeHandler&& handler);
1322 
1376  template<class RequestDecorator, class HandshakeHandler>
1377 #if BOOST_BEAST_DOXYGEN
1378  void_or_deduced
1379 #else
1381  HandshakeHandler, void(error_code)>
1382 #endif
1383  async_handshake_ex(
1384  response_type& res,
1385  string_view host,
1386  string_view target,
1387  RequestDecorator const& decorator,
1388  HandshakeHandler&& handler);
1389 
1390  //--------------------------------------------------------------------------
1391  //
1392  // Handshaking (Server)
1393  //
1394  //--------------------------------------------------------------------------
1395 
1427  void
1428  accept();
1429 
1470  template<class ResponseDecorator>
1471  void
1472  accept_ex(ResponseDecorator const& decorator);
1473 
1505  void
1506  accept(error_code& ec);
1507 
1548  template<class ResponseDecorator>
1549  void
1550  accept_ex(
1551  ResponseDecorator const& decorator,
1552  error_code& ec);
1553 
1589  template<class ConstBufferSequence>
1590 #if BOOST_BEAST_DOXYGEN
1591  void
1592 #else
1593  typename std::enable_if<! http::detail::is_header<
1594  ConstBufferSequence>::value>::type
1595 #endif
1596  accept(ConstBufferSequence const& buffers);
1597 
1642  template<class ConstBufferSequence,
1643  class ResponseDecorator>
1644 #if BOOST_BEAST_DOXYGEN
1645  void
1646 #else
1647  typename std::enable_if<! http::detail::is_header<
1648  ConstBufferSequence>::value>::type
1649 #endif
1650  accept_ex(
1651  ConstBufferSequence const& buffers,
1652  ResponseDecorator const& decorator);
1653 
1689  template<class ConstBufferSequence>
1690 #if BOOST_BEAST_DOXYGEN
1691  void
1692 #else
1693  typename std::enable_if<! http::detail::is_header<
1694  ConstBufferSequence>::value>::type
1695 #endif
1696  accept(
1697  ConstBufferSequence const& buffers,
1698  error_code& ec);
1699 
1744  template<class ConstBufferSequence, class ResponseDecorator>
1745 #if BOOST_BEAST_DOXYGEN
1746  void
1747 #else
1748  typename std::enable_if<! http::detail::is_header<
1749  ConstBufferSequence>::value>::type
1750 #endif
1751  accept_ex(
1752  ConstBufferSequence const& buffers,
1753  ResponseDecorator const& decorator,
1754  error_code& ec);
1755 
1783  template<class Body, class Allocator>
1784  void
1785  accept(http::request<Body,
1786  http::basic_fields<Allocator>> const& req);
1787 
1824  template<class Body, class Allocator,
1825  class ResponseDecorator>
1826  void
1827  accept_ex(http::request<Body,
1828  http::basic_fields<Allocator>> const& req,
1829  ResponseDecorator const& decorator);
1830 
1858  template<class Body, class Allocator>
1859  void
1860  accept(http::request<Body,
1861  http::basic_fields<Allocator>> const& req,
1862  error_code& ec);
1863 
1900  template<class Body, class Allocator,
1901  class ResponseDecorator>
1902  void
1903  accept_ex(http::request<Body,
1904  http::basic_fields<Allocator>> const& req,
1905  ResponseDecorator const& decorator,
1906  error_code& ec);
1907 
1955  template<class AcceptHandler>
1956 #if BOOST_BEAST_DOXYGEN
1957  void_or_deduced
1958 #else
1960  AcceptHandler, void(error_code)>
1961 #endif
1962  async_accept(AcceptHandler&& handler);
1963 
2020  template<
2021  class ResponseDecorator,
2022  class AcceptHandler>
2023 #if BOOST_BEAST_DOXYGEN
2024  void_or_deduced
2025 #else
2027  AcceptHandler, void(error_code)>
2028 #endif
2029  async_accept_ex(
2030  ResponseDecorator const& decorator,
2031  AcceptHandler&& handler);
2032 
2087  template<
2088  class ConstBufferSequence,
2089  class AcceptHandler>
2090 #if BOOST_BEAST_DOXYGEN
2091  void_or_deduced
2092 #else
2093  typename std::enable_if<
2096 #endif
2097  async_accept(
2098  ConstBufferSequence const& buffers,
2099  AcceptHandler&& handler);
2100 
2164  template<
2165  class ConstBufferSequence,
2166  class ResponseDecorator,
2167  class AcceptHandler>
2168 #if BOOST_BEAST_DOXYGEN
2169  void_or_deduced
2170 #else
2171  typename std::enable_if<
2174 #endif
2175  async_accept_ex(
2176  ConstBufferSequence const& buffers,
2177  ResponseDecorator const& decorator,
2178  AcceptHandler&& handler);
2179 
2224  template<
2225  class Body, class Allocator,
2226  class AcceptHandler>
2227 #if BOOST_BEAST_DOXYGEN
2228  void_or_deduced
2229 #else
2231  AcceptHandler, void(error_code)>
2232 #endif
2233  async_accept(
2234  http::request<Body,
2235  http::basic_fields<Allocator>> const& req,
2236  AcceptHandler&& handler);
2237 
2291  template<
2292  class Body, class Allocator,
2293  class ResponseDecorator,
2294  class AcceptHandler>
2295 #if BOOST_BEAST_DOXYGEN
2296  void_or_deduced
2297 #else
2299  AcceptHandler, void(error_code)>
2300 #endif
2301  async_accept_ex(
2302  http::request<Body,
2303  http::basic_fields<Allocator>> const& req,
2304  ResponseDecorator const& decorator,
2305  AcceptHandler&& handler);
2306 
2307  //--------------------------------------------------------------------------
2308  //
2309  // Control Frames
2310  //
2311  //--------------------------------------------------------------------------
2312 
2339  void
2340  close(close_reason const& cr);
2341 
2368  void
2369  close(close_reason const& cr, error_code& ec);
2370 
2414  template<class CloseHandler>
2415 #if BOOST_BEAST_DOXYGEN
2416  void_or_deduced
2417 #else
2419  CloseHandler, void(error_code)>
2420 #endif
2421  async_close(close_reason const& cr, CloseHandler&& handler);
2422 
2439  void
2440  ping(ping_data const& payload);
2441 
2458  void
2459  ping(ping_data const& payload, error_code& ec);
2460 
2496  template<class WriteHandler>
2497 #if BOOST_BEAST_DOXYGEN
2498  void_or_deduced
2499 #else
2501  WriteHandler, void(error_code)>
2502 #endif
2503  async_ping(ping_data const& payload, WriteHandler&& handler);
2504 
2526  void
2527  pong(ping_data const& payload);
2528 
2550  void
2551  pong(ping_data const& payload, error_code& ec);
2552 
2593  template<class WriteHandler>
2594 #if BOOST_BEAST_DOXYGEN
2595  void_or_deduced
2596 #else
2598  WriteHandler, void(error_code)>
2599 #endif
2600  async_pong(ping_data const& payload, WriteHandler&& handler);
2601 
2602  //--------------------------------------------------------------------------
2603  //
2604  // Reading
2605  //
2606  //--------------------------------------------------------------------------
2607 
2648  template<class DynamicBuffer>
2649  std::size_t
2650  read(DynamicBuffer& buffer);
2651 
2691  template<class DynamicBuffer>
2692  std::size_t
2693  read(DynamicBuffer& buffer, error_code& ec);
2694 
2756  template<class DynamicBuffer, class ReadHandler>
2757 #if BOOST_BEAST_DOXYGEN
2758  void_or_deduced
2759 #else
2761  ReadHandler,
2762  void(error_code, std::size_t)>
2763 #endif
2764  async_read(
2765  DynamicBuffer& buffer,
2766  ReadHandler&& handler);
2767 
2768  //--------------------------------------------------------------------------
2769 
2816  template<class DynamicBuffer>
2817  std::size_t
2818  read_some(
2819  DynamicBuffer& buffer,
2820  std::size_t limit);
2821 
2867  template<class DynamicBuffer>
2868  std::size_t
2869  read_some(
2870  DynamicBuffer& buffer,
2871  std::size_t limit,
2872  error_code& ec);
2873 
2941  template<class DynamicBuffer, class ReadHandler>
2942 #if BOOST_BEAST_DOXYGEN
2943  void_or_deduced
2944 #else
2946  ReadHandler, void(error_code, std::size_t)>
2947 #endif
2949  DynamicBuffer& buffer,
2950  std::size_t limit,
2951  ReadHandler&& handler);
2952 
2953  //--------------------------------------------------------------------------
2954 
2998  template<class MutableBufferSequence>
2999  std::size_t
3000  read_some(
3001  MutableBufferSequence const& buffers);
3002 
3045  template<class MutableBufferSequence>
3046  std::size_t
3047  read_some(
3048  MutableBufferSequence const& buffers,
3049  error_code& ec);
3050 
3118  template<class MutableBufferSequence, class ReadHandler>
3119 #if BOOST_BEAST_DOXYGEN
3120  void_or_deduced
3121 #else
3123 #endif
3125  MutableBufferSequence const& buffers,
3126  ReadHandler&& handler);
3127 
3128  //--------------------------------------------------------------------------
3129  //
3130  // Writing
3131  //
3132  //--------------------------------------------------------------------------
3133 
3169  template<class ConstBufferSequence>
3170  std::size_t
3171  write(ConstBufferSequence const& buffers);
3172 
3210  template<class ConstBufferSequence>
3211  std::size_t
3212  write(ConstBufferSequence const& buffers, error_code& ec);
3213 
3262  template<
3263  class ConstBufferSequence,
3264  class WriteHandler>
3265 #if BOOST_BEAST_DOXYGEN
3266  void_or_deduced
3267 #else
3269  WriteHandler,
3270  void(error_code, std::size_t)>
3271 #endif
3272  async_write(
3273  ConstBufferSequence const& buffers,
3274  WriteHandler&& handler);
3275 
3306  template<class ConstBufferSequence>
3307  std::size_t
3308  write_some(bool fin, ConstBufferSequence const& buffers);
3309 
3340  template<class ConstBufferSequence>
3341  std::size_t
3342  write_some(bool fin,
3343  ConstBufferSequence const& buffers, error_code& ec);
3344 
3389  template<class ConstBufferSequence, class WriteHandler>
3390 #if BOOST_BEAST_DOXYGEN
3391  void_or_deduced
3392 #else
3394  void(error_code, std::size_t)>
3395 #endif
3396  async_write_some(bool fin,
3397  ConstBufferSequence const& buffers, WriteHandler&& handler);
3398 
3399 private:
3400  template<class, class> class accept_op;
3401  template<class> class close_op;
3402  template<class> class fail_op;
3403  template<class> class handshake_op;
3404  template<class> class ping_op;
3405  template<class> class read_fh_op;
3406  template<class, class> class read_some_op;
3407  template<class, class> class read_op;
3408  template<class> class response_op;
3409  template<class, class> class write_some_op;
3410  template<class, class> class write_op;
3411 
3412  static void default_decorate_req(request_type&) {}
3413  static void default_decorate_res(response_type&) {}
3414 
3415  void open(role_type role);
3416  void close();
3417  void reset();
3418  void begin_msg();
3419 
3420  bool
3421  check_open(error_code& ec)
3422  {
3423  if(status_ != status::open)
3424  {
3425  ec = boost::asio::error::operation_aborted;
3426  return false;
3427  }
3428  ec.assign(0, ec.category());
3429  return true;
3430  }
3431 
3432  bool
3433  check_ok(error_code& ec)
3434  {
3435  if(ec)
3436  {
3437  if(status_ != status::closed)
3438  status_ = status::failed;
3439  return false;
3440  }
3441  return true;
3442  }
3443 
3444  template<class DynamicBuffer>
3445  bool
3446  parse_fh(detail::frame_header& fh,
3447  DynamicBuffer& b, close_code& code);
3448 
3449  template<class DynamicBuffer>
3450  void
3451  write_close(DynamicBuffer& b, close_reason const& rc);
3452 
3453  template<class DynamicBuffer>
3454  void
3455  write_ping(DynamicBuffer& b,
3456  detail::opcode op, ping_data const& data);
3457 
3458  template<class Decorator>
3459  request_type
3460  build_request(detail::sec_ws_key_type& key,
3461  string_view host,
3462  string_view target,
3463  Decorator const& decorator);
3464 
3465  template<class Body,
3466  class Allocator, class Decorator>
3468  build_response(http::request<Body,
3469  http::basic_fields<Allocator>> const& req,
3470  Decorator const& decorator);
3471 
3472  void
3473  on_response(response_type const& resp,
3474  detail::sec_ws_key_type const& key, error_code& ec);
3475 
3476  template<class Decorator>
3477  void
3478  do_accept(Decorator const& decorator,
3479  error_code& ec);
3480 
3481  template<class Body, class Allocator,
3482  class Decorator>
3483  void
3484  do_accept(http::request<Body,
3485  http::basic_fields<Allocator>> const& req,
3486  Decorator const& decorator, error_code& ec);
3487 
3488  template<class RequestDecorator>
3489  void
3490  do_handshake(response_type* res_p,
3491  string_view host, string_view target,
3492  RequestDecorator const& decorator,
3493  error_code& ec);
3494 
3495  void
3496  do_fail(
3497  std::uint16_t code,
3498  error_code ev,
3499  error_code& ec);
3500 };
3501 
3502 } // websocket
3503 } // beast
3504 } // boost
3505 
3513 
3514 #endif
BufferSequence< boost::asio::const_buffer > ConstBufferSequence
Definition: type_traits.hpp:280
StreamHandler WriteHandler
Definition: type_traits.hpp:357
Definition: inflate_stream.hpp:64
StreamHandler ReadHandler
Definition: type_traits.hpp:356
void binary(bool value)
Definition: stream.hpp:536
Definition: async_result.hpp:20
std::size_t write_some(SyncWriteStream &stream, serializer< isRequest, Body, Fields > &sr, error_code &ec)
Definition: write.ipp:468
typename get_lowest_layer< next_layer_type >::type lowest_layer_type
The type of the lowest layer.
Definition: stream.hpp:244
role_type
Definition: role.hpp:46
Definition: type_traits.hpp:25
bool got_text() const
Definition: stream.hpp:405
detail::buffers_helper< ConstBufferSequence > buffers(ConstBufferSequence const &b)
Definition: ostream.hpp:50
The stream is operating as a client.
void write_buffer_size(std::size_t amount)
Definition: stream.hpp:667
void read_message_max(std::size_t amount)
Definition: stream.hpp:629
async_return_type< ReadHandler, void(error_code, std::size_t)> async_read_some(AsyncReadStream &stream, DynamicBuffer &buffer, basic_parser< isRequest, Derived > &parser, ReadHandler &&handler)
Definition: read.ipp:546
Definition: deflate_stream.hpp:59
T type
Definition: type_traits.hpp:302
async_return_type< WriteHandler, void(error_code, std::size_t)> async_write(AsyncWriteStream &stream, serializer< isRequest, Body, Fields > &sr, WriteHandler &&handler)
Definition: write.ipp:730
bool auto_fragment() const
Returns true if the automatic fragmentation option is set.
Definition: stream.hpp:511
void write(DynamicBuffer &db, frame_header const &fh)
Definition: frame.hpp:185
Both sides performed a WebSocket close.
Definition: rfc6455.hpp:160
next_layer_type const & next_layer() const
Definition: stream.hpp:330
lowest_layer_type & lowest_layer()
Definition: stream.hpp:344
lowest_layer_type const & lowest_layer() const
Definition: stream.hpp:358
boost::system::error_code error_code
The type of error code used by the library.
Definition: error.hpp:21
Definition: static_buffer.hpp:166
bool binary() const
Returns true if the binary message option is set.
Definition: stream.hpp:545
Definition: fields.hpp:53
next_layer_type & next_layer()
Definition: stream.hpp:316
std::size_t read_message_max() const
Returns the maximum incoming message size setting.
Definition: stream.hpp:636
bool is_open() const
Definition: stream.hpp:375
bool got_binary() const
Definition: stream.hpp:390
Definition: pmd_extension.hpp:33
boost::asio::io_service & get_io_service()
Definition: stream.hpp:302
bool is_message_done() const
Returns true if the last completed read finished the current message.
Definition: stream.hpp:412
typename is_header_impl< T >::type is_header
Definition: type_traits.hpp:44
Definition: pausation.hpp:30
void control_callback(Callback &cb)
Definition: stream.hpp:592
close_code
Definition: rfc6455.hpp:67
Definition: stream.hpp:117
void control_callback()
Definition: stream.hpp:606
async_return_type< WriteHandler, void(error_code, std::size_t)> async_write_some(AsyncWriteStream &stream, serializer< isRequest, Body, Fields > &sr, WriteHandler &&handler)
Definition: write.ipp:500
std::size_t read_some(SyncReadStream &stream, DynamicBuffer &buffer, basic_parser< isRequest, Derived > &parser)
Definition: read.ipp:454
frame_type
Definition: stream.hpp:60
async_return_type< ReadHandler, void(error_code, std::size_t)> async_read(AsyncReadStream &stream, DynamicBuffer &buffer, basic_parser< isRequest, Derived > &parser, ReadHandler &&handler)
Definition: read.ipp:715
void text(bool value)
Definition: stream.hpp:702
boost::string_ref string_view
The type of string view used by the library.
Definition: string.hpp:36
typename beast::async_result< typename std::decay< CompletionToken >::type, Signature >::return_type async_return_type
Definition: async_result.hpp:204
std::size_t write_buffer_size() const
Returns the size of the write buffer.
Definition: stream.hpp:677
Definition: static_string.hpp:44
close_reason const & reason() const
Definition: stream.hpp:422
opcode
Definition: frame.hpp:79
void get_option(permessage_deflate &o)
Get the permessage-deflate extension options.
Definition: stream.hpp:479
std::conditional< sizeof(void *)==8, std::uint64_t, std::uint32_t >::type prepared_key
Definition: mask.hpp:87
bool operator!=(static_string< N, CharT, Traits > const &lhs, static_string< M, CharT, Traits > const &rhs)
Definition: static_string.hpp:875
typename std::remove_reference< NextLayer >::type next_layer_type
The type of the next layer.
Definition: stream.hpp:240
bool text() const
Returns true if the text message option is set.
Definition: stream.hpp:711
bool operator==(static_string< N, CharT, Traits > const &lhs, static_string< M, CharT, Traits > const &rhs)
Definition: static_string.hpp:865
void auto_fragment(bool value)
Definition: stream.hpp:504
WebSocket connection failed, protocol violation.
BufferSequence< boost::asio::mutable_buffer > MutableBufferSequence
Definition: type_traits.hpp:282