More constexpr
This commit is contained in:
parent
7582640fd5
commit
34efc6b7a4
|
@ -69,8 +69,9 @@
|
|||
namespace nghttp2 {
|
||||
|
||||
namespace {
|
||||
const std::string DEFAULT_HTML = "index.html";
|
||||
const std::string NGHTTPD_SERVER = "nghttpd nghttp2/" NGHTTP2_VERSION;
|
||||
// TODO could be constexpr
|
||||
constexpr char DEFAULT_HTML[] = "index.html";
|
||||
constexpr char NGHTTPD_SERVER[] = "nghttpd nghttp2/" NGHTTP2_VERSION;
|
||||
} // namespace
|
||||
|
||||
namespace {
|
||||
|
@ -739,7 +740,7 @@ int Http2Handler::submit_file_response(const std::string &status,
|
|||
std::string content_length = util::utos(file_length);
|
||||
std::string last_modified_str;
|
||||
auto nva = make_array(http2::make_nv_ls(":status", status),
|
||||
http2::make_nv_ls("server", NGHTTPD_SERVER),
|
||||
http2::make_nv_ll("server", NGHTTPD_SERVER),
|
||||
http2::make_nv_ls("content-length", content_length),
|
||||
http2::make_nv_ll("cache-control", "max-age=3600"),
|
||||
http2::make_nv_ls("date", sessions_->get_cached_date()),
|
||||
|
@ -769,7 +770,7 @@ int Http2Handler::submit_response(const std::string &status, int32_t stream_id,
|
|||
auto nva = std::vector<nghttp2_nv>();
|
||||
nva.reserve(3 + headers.size());
|
||||
nva.push_back(http2::make_nv_ls(":status", status));
|
||||
nva.push_back(http2::make_nv_ls("server", NGHTTPD_SERVER));
|
||||
nva.push_back(http2::make_nv_ll("server", NGHTTPD_SERVER));
|
||||
nva.push_back(http2::make_nv_ls("date", sessions_->get_cached_date()));
|
||||
for (auto &nv : headers) {
|
||||
nva.push_back(http2::make_nv(nv.name, nv.value, nv.no_index));
|
||||
|
@ -782,7 +783,7 @@ int Http2Handler::submit_response(const std::string &status, int32_t stream_id,
|
|||
int Http2Handler::submit_response(const std::string &status, int32_t stream_id,
|
||||
nghttp2_data_provider *data_prd) {
|
||||
auto nva = make_array(http2::make_nv_ls(":status", status),
|
||||
http2::make_nv_ls("server", NGHTTPD_SERVER));
|
||||
http2::make_nv_ll("server", NGHTTPD_SERVER));
|
||||
return nghttp2_submit_response(session_, stream_id, nva.data(), nva.size(),
|
||||
data_prd);
|
||||
}
|
||||
|
|
|
@ -109,7 +109,7 @@ nghttp2_nv make_nv(const std::string &name, const std::string &value,
|
|||
|
||||
// Create nghttp2_nv from string literal |name| and |value|.
|
||||
template <size_t N, size_t M>
|
||||
nghttp2_nv make_nv_ll(const char (&name)[N], const char (&value)[M]) {
|
||||
constexpr nghttp2_nv make_nv_ll(const char (&name)[N], const char (&value)[M]) {
|
||||
return {(uint8_t *)name, (uint8_t *)value, N - 1, M - 1,
|
||||
NGHTTP2_NV_FLAG_NONE};
|
||||
}
|
||||
|
|
|
@ -89,7 +89,7 @@ enum {
|
|||
};
|
||||
|
||||
namespace {
|
||||
auto anchors = std::array<Anchor, 5>{{
|
||||
constexpr auto anchors = std::array<Anchor, 5>{{
|
||||
{3, 0, 201}, {5, 0, 101}, {7, 0, 1}, {9, 7, 1}, {11, 3, 1},
|
||||
}};
|
||||
} // namespace
|
||||
|
|
|
@ -59,7 +59,7 @@ class CertLookupTree;
|
|||
|
||||
} // namespace ssl
|
||||
|
||||
#define SHRPX_UNIX_PATH_PREFIX "unix:"
|
||||
constexpr char SHRPX_UNIX_PATH_PREFIX[] = "unix:";
|
||||
|
||||
extern const char SHRPX_OPT_PRIVATE_KEY_FILE[];
|
||||
extern const char SHRPX_OPT_PRIVATE_KEY_PASSWD_FILE[];
|
||||
|
|
|
@ -298,9 +298,9 @@ int alpn_select_proto_cb(SSL *ssl, const unsigned char **out,
|
|||
#endif // OPENSSL_VERSION_NUMBER >= 0x10002000L
|
||||
|
||||
namespace {
|
||||
const char *tls_names[] = {"TLSv1.2", "TLSv1.1", "TLSv1.0"};
|
||||
const size_t tls_namelen = array_size(tls_names);
|
||||
const long int tls_masks[] = {SSL_OP_NO_TLSv1_2, SSL_OP_NO_TLSv1_1,
|
||||
constexpr const char *tls_names[] = {"TLSv1.2", "TLSv1.1", "TLSv1.0"};
|
||||
constexpr size_t tls_namelen = array_size(tls_names);
|
||||
constexpr long int tls_masks[] = {SSL_OP_NO_TLSv1_2, SSL_OP_NO_TLSv1_1,
|
||||
SSL_OP_NO_TLSv1};
|
||||
} // namespace
|
||||
|
||||
|
|
Loading…
Reference in New Issue