beast.hpp 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. /*
  2. * Copyright (c) 2017-2023 zhllxt
  3. *
  4. * author : zhllxt
  5. * email : 37792738@qq.com
  6. *
  7. * Distributed under the Boost Software License, Version 1.0. (See accompanying
  8. * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  9. */
  10. #ifndef __ASIO2_BEAST_HPP__
  11. #define __ASIO2_BEAST_HPP__
  12. #if defined(_MSC_VER) && (_MSC_VER >= 1200)
  13. #pragma once
  14. #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
  15. #include <asio2/config.hpp>
  16. #include <asio2/base/detail/push_options.hpp>
  17. #ifdef ASIO2_HEADER_ONLY
  18. #ifndef BEAST_HEADER_ONLY
  19. #define BEAST_HEADER_ONLY 1
  20. #endif
  21. #endif
  22. #ifdef ASIO2_HEADER_ONLY
  23. #include <asio2/bho/beast.hpp>
  24. #if defined(ASIO2_ENABLE_SSL) || defined(ASIO2_USE_SSL)
  25. // boost 1.72(107200) BOOST_BEAST_VERSION 277
  26. #if defined(BEAST_VERSION) && (BEAST_VERSION >= 277)
  27. #include <asio2/bho/beast/ssl.hpp>
  28. #endif
  29. #include <asio2/bho/beast/websocket/ssl.hpp>
  30. #endif
  31. #ifndef BEAST_VERSION
  32. #define BEAST_VERSION BHO_BEAST_VERSION
  33. #endif
  34. #ifndef BEAST_VERSION_STRING
  35. #define BEAST_VERSION_STRING BHO_BEAST_VERSION_STRING
  36. #endif
  37. #ifndef BHO_BEAST_VERSION
  38. #define BHO_BEAST_VERSION BHO_BEAST_VERSION
  39. #endif
  40. #ifndef BHO_BEAST_VERSION_STRING
  41. #define BHO_BEAST_VERSION_STRING BHO_BEAST_VERSION_STRING
  42. #endif
  43. #else
  44. #ifndef BOOST_BEAST_USE_STD_STRING_VIEW
  45. #define BOOST_BEAST_USE_STD_STRING_VIEW
  46. #endif
  47. #include <boost/beast.hpp>
  48. #if defined(ASIO2_ENABLE_SSL) || defined(ASIO2_USE_SSL)
  49. // boost 1.72(107200) BOOST_BEAST_VERSION 277
  50. #if defined(BOOST_BEAST_VERSION) && (BOOST_BEAST_VERSION >= 277)
  51. #include <boost/beast/ssl.hpp>
  52. #endif
  53. #include <boost/beast/websocket/ssl.hpp>
  54. #endif
  55. #ifndef BEAST_VERSION
  56. #define BEAST_VERSION BOOST_BEAST_VERSION
  57. #endif
  58. #ifndef BEAST_VERSION_STRING
  59. #define BEAST_VERSION_STRING BOOST_BEAST_VERSION_STRING
  60. #endif
  61. #ifndef BHO_BEAST_VERSION
  62. #define BHO_BEAST_VERSION BOOST_BEAST_VERSION
  63. #endif
  64. #ifndef BHO_BEAST_VERSION_STRING
  65. #define BHO_BEAST_VERSION_STRING BOOST_BEAST_VERSION_STRING
  66. #endif
  67. #endif
  68. #ifdef ASIO2_HEADER_ONLY
  69. namespace bho::beast::http
  70. {
  71. template<class Body, class Fields = fields>
  72. using request_t = request<Body, Fields>;
  73. template<class Body, class Fields = fields>
  74. using response_t = response<Body, Fields>;
  75. }
  76. namespace beast = ::bho::beast;
  77. #else
  78. namespace boost::beast::http
  79. {
  80. template<class Body, class Fields = fields>
  81. using request_t = request<Body, Fields>;
  82. template<class Body, class Fields = fields>
  83. using response_t = response<Body, Fields>;
  84. }
  85. namespace beast = ::boost::beast;
  86. namespace asio = ::boost::asio;
  87. namespace bho = ::boost; // bho means boost header only
  88. #endif
  89. namespace http = ::beast::http;
  90. namespace websocket = ::beast::websocket;
  91. namespace asio2
  92. {
  93. namespace http = ::beast::http;
  94. namespace websocket = ::beast::websocket;
  95. }
  96. #include <asio2/base/detail/pop_options.hpp>
  97. #endif // !__ASIO2_BEAST_HPP__