nghttpx: Convert shrpx_cookie_secure to enum class

This commit is contained in:
Tatsuhiro Tsujikawa 2018-10-16 22:33:44 +09:00
parent 5e4f434fd8
commit e7b7b037f6
5 changed files with 14 additions and 14 deletions

View File

@ -927,11 +927,11 @@ int parse_downstream_params(DownstreamParams &out,
} else if (util::istarts_with_l(param, "affinity-cookie-secure=")) { } else if (util::istarts_with_l(param, "affinity-cookie-secure=")) {
auto valstr = StringRef{first + str_size("affinity-cookie-secure="), end}; auto valstr = StringRef{first + str_size("affinity-cookie-secure="), end};
if (util::strieq_l("auto", valstr)) { 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)) { } 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)) { } else if (util::strieq_l("no", valstr)) {
out.affinity.cookie.secure = COOKIE_SECURE_NO; out.affinity.cookie.secure = SessionAffinityCookieSecure::NO;
} else { } else {
LOG(ERROR) << "backend: affinity-cookie-secure: value must be one of " LOG(ERROR) << "backend: affinity-cookie-secure: value must be one of "
"auto, yes, and no"; "auto, yes, and no";

View File

@ -378,14 +378,14 @@ enum class SessionAffinity {
COOKIE, COOKIE,
}; };
enum shrpx_cookie_secure { enum class SessionAffinityCookieSecure {
// Secure attribute of session affinity cookie is determined by the // Secure attribute of session affinity cookie is determined by the
// request scheme. // request scheme.
COOKIE_SECURE_AUTO, AUTO,
// Secure attribute of session affinity cookie is always set. // Secure attribute of session affinity cookie is always set.
COOKIE_SECURE_YES, YES,
// Secure attribute of session affinity cookie is always unset. // Secure attribute of session affinity cookie is always unset.
COOKIE_SECURE_NO, NO,
}; };
struct AffinityConfig { struct AffinityConfig {
@ -397,7 +397,7 @@ struct AffinityConfig {
// Path which a cookie is applied to. // Path which a cookie is applied to.
StringRef path; StringRef path;
// Secure attribute // Secure attribute
shrpx_cookie_secure secure; SessionAffinityCookieSecure secure;
} cookie; } cookie;
}; };

View File

@ -199,12 +199,12 @@ StringRef create_affinity_cookie(BlockAllocator &balloc, const StringRef &name,
return StringRef{iov.base, p}; return StringRef{iov.base, p};
} }
bool require_cookie_secure_attribute(shrpx_cookie_secure secure, bool require_cookie_secure_attribute(SessionAffinityCookieSecure secure,
const StringRef &scheme) { const StringRef &scheme) {
switch (secure) { switch (secure) {
case COOKIE_SECURE_AUTO: case SessionAffinityCookieSecure::AUTO:
return scheme == "https"; return scheme == "https";
case COOKIE_SECURE_YES: case SessionAffinityCookieSecure::YES:
return true; return true;
default: default:
return false; return false;

View File

@ -76,7 +76,7 @@ StringRef create_affinity_cookie(BlockAllocator &balloc, const StringRef &name,
// Returns true if |secure| indicates that Secure attribute should be // Returns true if |secure| indicates that Secure attribute should be
// set. // set.
bool require_cookie_secure_attribute(shrpx_cookie_secure secure, bool require_cookie_secure_attribute(SessionAffinityCookieSecure secure,
const StringRef &scheme); const StringRef &scheme);
} // namespace http } // namespace http

View File

@ -77,8 +77,8 @@ DownstreamAddrGroup::~DownstreamAddrGroup() {}
using DownstreamKey = using DownstreamKey =
std::tuple<std::vector<std::tuple<StringRef, StringRef, size_t, size_t, std::tuple<std::vector<std::tuple<StringRef, StringRef, size_t, size_t,
Proto, uint16_t, bool, bool, bool, bool>>, Proto, uint16_t, bool, bool, bool, bool>>,
bool, SessionAffinity, StringRef, StringRef, int, int64_t, bool, SessionAffinity, StringRef, StringRef,
int64_t>; SessionAffinityCookieSecure, int64_t, int64_t>;
namespace { namespace {
DownstreamKey create_downstream_key( DownstreamKey create_downstream_key(