File indexing completed on 2026-08-17 09:00:18
0001
0002
0003
0004
0005
0006
0007 #ifndef BOOST_REDIS_SETUP_REQUEST_UTILS_HPP
0008 #define BOOST_REDIS_SETUP_REQUEST_UTILS_HPP
0009
0010 #include <boost/redis/config.hpp>
0011 #include <boost/redis/request.hpp>
0012 #include <boost/redis/response.hpp>
0013
0014 namespace boost::redis::detail {
0015
0016
0017
0018 inline void compose_setup_request(config& cfg)
0019 {
0020 if (!cfg.use_setup) {
0021
0022
0023 auto& req = cfg.setup;
0024 req.clear();
0025
0026
0027
0028
0029
0030 bool send_auth = !(
0031 cfg.username.empty() || (cfg.username == "default" && cfg.password.empty()));
0032 bool send_setname = !cfg.clientname.empty();
0033
0034
0035 if (send_auth && send_setname)
0036 req.push("HELLO", "3", "AUTH", cfg.username, cfg.password, "SETNAME", cfg.clientname);
0037 else if (send_auth)
0038 req.push("HELLO", "3", "AUTH", cfg.username, cfg.password);
0039 else if (send_setname)
0040 req.push("HELLO", "3", "SETNAME", cfg.clientname);
0041 else
0042 req.push("HELLO", "3");
0043
0044
0045 if (cfg.database_index && cfg.database_index.value() != 0)
0046 req.push("SELECT", cfg.database_index.value());
0047 }
0048
0049
0050
0051
0052 request_access::set_priority(cfg.setup, true);
0053 cfg.setup.get_config().cancel_if_unresponded = true;
0054 cfg.setup.get_config().cancel_on_connection_lost = true;
0055 }
0056
0057 }
0058
0059 #endif