src: Don't compare against c-string
This commit is contained in:
parent
0875e66aab
commit
17ccbae084
|
@ -1354,7 +1354,7 @@ void prepare_response(Stream *stream, Http2Handler *hd,
|
|||
}
|
||||
|
||||
auto method = stream->header.method;
|
||||
if (method == "HEAD") {
|
||||
if (method == StringRef::from_lit("HEAD")) {
|
||||
hd->submit_file_response(StringRef::from_lit("200"), stream,
|
||||
file_ent->mtime, file_ent->length,
|
||||
file_ent->content_type, nullptr);
|
||||
|
@ -1512,7 +1512,8 @@ int hd_on_frame_recv_callback(nghttp2_session *session,
|
|||
|
||||
auto method = stream->header.method;
|
||||
if (hd->get_config()->echo_upload &&
|
||||
(method == "POST" || method == "PUT")) {
|
||||
(method == StringRef::from_lit("POST") ||
|
||||
method == StringRef::from_lit("PUT"))) {
|
||||
if (!prepare_upload_temp_store(stream, hd)) {
|
||||
hd->submit_rst_stream(stream, NGHTTP2_INTERNAL_ERROR);
|
||||
return 0;
|
||||
|
|
|
@ -524,7 +524,8 @@ int create_tcp_server_socket(UpstreamAddr &faddr,
|
|||
hints.ai_flags |= AI_ADDRCONFIG;
|
||||
#endif // AI_ADDRCONFIG
|
||||
|
||||
auto node = faddr.host == "*" ? nullptr : faddr.host.c_str();
|
||||
auto node =
|
||||
faddr.host == StringRef::from_lit("*") ? nullptr : faddr.host.c_str();
|
||||
|
||||
addrinfo *res, *rp;
|
||||
rv = getaddrinfo(node, service.c_str(), &hints, &res);
|
||||
|
@ -720,7 +721,7 @@ int create_acceptor_socket() {
|
|||
auto type = StringRef(env, end_type);
|
||||
auto value = end_type + 1;
|
||||
|
||||
if (type == "unix") {
|
||||
if (type == StringRef::from_lit("unix")) {
|
||||
auto endfd = strchr(value, ',');
|
||||
if (!endfd) {
|
||||
continue;
|
||||
|
@ -752,7 +753,7 @@ int create_acceptor_socket() {
|
|||
iaddrs.push_back(std::move(addr));
|
||||
}
|
||||
|
||||
if (type == "tcp") {
|
||||
if (type == StringRef::from_lit("tcp")) {
|
||||
auto fd = util::parse_uint(value);
|
||||
if (fd == -1) {
|
||||
LOG(WARN) << "Could not parse file descriptor from " << value;
|
||||
|
@ -2132,7 +2133,7 @@ void process_options(int argc, char **argv,
|
|||
ssize_t catch_all_group = -1;
|
||||
for (size_t i = 0; i < addr_groups.size(); ++i) {
|
||||
auto &g = addr_groups[i];
|
||||
if (g.pattern == "/") {
|
||||
if (g.pattern == StringRef::from_lit("/")) {
|
||||
catch_all_group = i;
|
||||
}
|
||||
if (LOG_ENABLED(INFO)) {
|
||||
|
|
|
@ -831,7 +831,7 @@ int parse_error_page(std::vector<ErrorPage> &error_pages, const StringRef &opt,
|
|||
auto codestr = StringRef{std::begin(optarg), eq};
|
||||
unsigned int code;
|
||||
|
||||
if (codestr == "*") {
|
||||
if (codestr == StringRef::from_lit("*")) {
|
||||
code = 0;
|
||||
} else {
|
||||
auto n = util::parse_uint(codestr);
|
||||
|
|
|
@ -325,7 +325,8 @@ int Http2Upstream::on_request_headers(Downstream *downstream,
|
|||
}
|
||||
|
||||
if (path) {
|
||||
if (method_token == HTTP_OPTIONS && path->value == "*") {
|
||||
if (method_token == HTTP_OPTIONS &&
|
||||
path->value == StringRef::from_lit("*")) {
|
||||
// Server-wide OPTIONS request. Path is empty.
|
||||
} else if (get_config()->http2_proxy) {
|
||||
req.path = path->value;
|
||||
|
|
|
@ -354,7 +354,7 @@ int htp_hdrs_completecb(http_parser *htp) {
|
|||
|
||||
req.no_authority = true;
|
||||
|
||||
if (method == HTTP_OPTIONS && req.path == "*") {
|
||||
if (method == HTTP_OPTIONS && req.path == StringRef::from_lit("*")) {
|
||||
req.path = StringRef{};
|
||||
} else {
|
||||
req.path = http2::rewrite_clean_path(balloc, req.path);
|
||||
|
|
|
@ -272,7 +272,8 @@ void on_ctrl_recv_callback(spdylay_session *session, spdylay_frame_type type,
|
|||
req.authority = host->value;
|
||||
if (get_config()->http2_proxy) {
|
||||
req.path = path->value;
|
||||
} else if (method_token == HTTP_OPTIONS && path->value == "*") {
|
||||
} else if (method_token == HTTP_OPTIONS &&
|
||||
path->value == StringRef::from_lit("*")) {
|
||||
// Server-wide OPTIONS request. Path is empty.
|
||||
} else {
|
||||
req.path = http2::rewrite_clean_path(balloc, path->value);
|
||||
|
|
Loading…
Reference in New Issue