nghttpx: Convert shrpx_cookie_secure to enum class
This commit is contained in:
parent
5e4f434fd8
commit
e7b7b037f6
|
@ -927,11 +927,11 @@ int parse_downstream_params(DownstreamParams &out,
|
|||
} else if (util::istarts_with_l(param, "affinity-cookie-secure=")) {
|
||||
auto valstr = StringRef{first + str_size("affinity-cookie-secure="), end};
|
||||
if (util::strieq_l("auto", valstr)) {
|
||||
out.affinity.cookie.secure = COOKIE_SECURE_AUTO;
|
||||
out.affinity.cookie.secure = SessionAffinityCookieSecure::AUTO;
|
||||
} else if (util::strieq_l("yes", valstr)) {
|
||||
out.affinity.cookie.secure = COOKIE_SECURE_YES;
|
||||
out.affinity.cookie.secure = SessionAffinityCookieSecure::YES;
|
||||
} else if (util::strieq_l("no", valstr)) {
|
||||
out.affinity.cookie.secure = COOKIE_SECURE_NO;
|
||||
out.affinity.cookie.secure = SessionAffinityCookieSecure::NO;
|
||||
} else {
|
||||
LOG(ERROR) << "backend: affinity-cookie-secure: value must be one of "
|
||||
"auto, yes, and no";
|
||||
|
|
|
@ -378,14 +378,14 @@ enum class SessionAffinity {
|
|||
COOKIE,
|
||||
};
|
||||
|
||||
enum shrpx_cookie_secure {
|
||||
enum class SessionAffinityCookieSecure {
|
||||
// Secure attribute of session affinity cookie is determined by the
|
||||
// request scheme.
|
||||
COOKIE_SECURE_AUTO,
|
||||
AUTO,
|
||||
// Secure attribute of session affinity cookie is always set.
|
||||
COOKIE_SECURE_YES,
|
||||
YES,
|
||||
// Secure attribute of session affinity cookie is always unset.
|
||||
COOKIE_SECURE_NO,
|
||||
NO,
|
||||
};
|
||||
|
||||
struct AffinityConfig {
|
||||
|
@ -397,7 +397,7 @@ struct AffinityConfig {
|
|||
// Path which a cookie is applied to.
|
||||
StringRef path;
|
||||
// Secure attribute
|
||||
shrpx_cookie_secure secure;
|
||||
SessionAffinityCookieSecure secure;
|
||||
} cookie;
|
||||
};
|
||||
|
||||
|
|
|
@ -199,12 +199,12 @@ StringRef create_affinity_cookie(BlockAllocator &balloc, const StringRef &name,
|
|||
return StringRef{iov.base, p};
|
||||
}
|
||||
|
||||
bool require_cookie_secure_attribute(shrpx_cookie_secure secure,
|
||||
bool require_cookie_secure_attribute(SessionAffinityCookieSecure secure,
|
||||
const StringRef &scheme) {
|
||||
switch (secure) {
|
||||
case COOKIE_SECURE_AUTO:
|
||||
case SessionAffinityCookieSecure::AUTO:
|
||||
return scheme == "https";
|
||||
case COOKIE_SECURE_YES:
|
||||
case SessionAffinityCookieSecure::YES:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
|
|
|
@ -76,7 +76,7 @@ StringRef create_affinity_cookie(BlockAllocator &balloc, const StringRef &name,
|
|||
|
||||
// Returns true if |secure| indicates that Secure attribute should be
|
||||
// set.
|
||||
bool require_cookie_secure_attribute(shrpx_cookie_secure secure,
|
||||
bool require_cookie_secure_attribute(SessionAffinityCookieSecure secure,
|
||||
const StringRef &scheme);
|
||||
|
||||
} // namespace http
|
||||
|
|
|
@ -77,8 +77,8 @@ DownstreamAddrGroup::~DownstreamAddrGroup() {}
|
|||
using DownstreamKey =
|
||||
std::tuple<std::vector<std::tuple<StringRef, StringRef, size_t, size_t,
|
||||
Proto, uint16_t, bool, bool, bool, bool>>,
|
||||
bool, SessionAffinity, StringRef, StringRef, int, int64_t,
|
||||
int64_t>;
|
||||
bool, SessionAffinity, StringRef, StringRef,
|
||||
SessionAffinityCookieSecure, int64_t, int64_t>;
|
||||
|
||||
namespace {
|
||||
DownstreamKey create_downstream_key(
|
||||
|
|
Loading…
Reference in New Issue