http_traits.hpp 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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_HTTP_TRAITS_HPP__
  11. #define __ASIO2_HTTP_TRAITS_HPP__
  12. #if defined(_MSC_VER) && (_MSC_VER >= 1200)
  13. #pragma once
  14. #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
  15. #include <asio2/base/detail/util.hpp>
  16. #include <asio2/base/detail/function_traits.hpp>
  17. #include <asio2/http/request.hpp>
  18. #include <asio2/http/response.hpp>
  19. namespace asio2::detail
  20. {
  21. template<class Proxy>
  22. struct http_proxy_checker
  23. {
  24. static constexpr bool value = true
  25. && (!std::is_same_v<detail::remove_cvref_t<Proxy>, error_code>)
  26. && (!detail::can_convert_to_http_request_v<detail::remove_cvref_t<Proxy>>)
  27. && (!detail::is_character_string_v<detail::remove_cvref_t<Proxy>>)
  28. ;
  29. };
  30. template<class T>
  31. inline constexpr bool http_proxy_checker_v = http_proxy_checker<detail::remove_cvref_t<T>>::value;
  32. template<class args_t>
  33. struct is_http_execute_download_enabled
  34. {
  35. template<class, class = void>
  36. struct has_member_enabled : std::false_type {};
  37. template<class T>
  38. struct has_member_enabled<T, std::void_t<decltype(T::http_execute_download_enabled)>> : std::true_type {};
  39. static constexpr bool value()
  40. {
  41. if constexpr (has_member_enabled<args_t>::value)
  42. {
  43. return args_t::http_execute_download_enabled;
  44. }
  45. else
  46. {
  47. return true;
  48. }
  49. }
  50. };
  51. template<class args_t>
  52. struct is_https_execute_download_enabled
  53. {
  54. template<class, class = void>
  55. struct has_member_enabled : std::false_type {};
  56. template<class T>
  57. struct has_member_enabled<T, std::void_t<decltype(T::https_execute_download_enabled)>> : std::true_type {};
  58. static constexpr bool value()
  59. {
  60. if constexpr (has_member_enabled<args_t>::value)
  61. {
  62. return args_t::https_execute_download_enabled;
  63. }
  64. else
  65. {
  66. return true;
  67. }
  68. }
  69. };
  70. }
  71. #endif // !__ASIO2_HTTP_TRAITS_HPP__