asio: Utilize aggregate or value-initialization for header_value
This commit is contained in:
parent
fc2170e488
commit
e7d052100c
|
@ -92,9 +92,9 @@ int main(int argc, char *argv[]) {
|
|||
struct stat stbuf;
|
||||
if (stat(path.c_str(), &stbuf) == 0) {
|
||||
header.emplace("content-length",
|
||||
header_value(std::to_string(stbuf.st_size)));
|
||||
header_value{std::to_string(stbuf.st_size)});
|
||||
header.emplace("last-modified",
|
||||
header_value(http_date(stbuf.st_mtime)));
|
||||
header_value{http_date(stbuf.st_mtime)});
|
||||
}
|
||||
res.write_head(200, std::move(header));
|
||||
res.end(file_reader_from_fd(fd));
|
||||
|
|
|
@ -149,9 +149,10 @@ int on_header_callback(nghttp2_session *session, const nghttp2_frame *frame,
|
|||
res.content_length(util::parse_uint(value, valuelen));
|
||||
}
|
||||
|
||||
res.header().emplace(std::string(name, name + namelen),
|
||||
header_value(std::string(value, value + valuelen),
|
||||
flags & NGHTTP2_NV_FLAG_NO_INDEX));
|
||||
res.header().emplace(
|
||||
std::string(name, name + namelen),
|
||||
header_value{std::string(value, value + valuelen),
|
||||
(flags & NGHTTP2_NV_FLAG_NO_INDEX) != 0});
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -183,9 +184,10 @@ int on_header_callback(nghttp2_session *session, const nghttp2_frame *frame,
|
|||
}
|
||||
// fall through
|
||||
default:
|
||||
req.header().emplace(std::string(name, name + namelen),
|
||||
header_value(std::string(value, value + valuelen),
|
||||
flags & NGHTTP2_NV_FLAG_NO_INDEX));
|
||||
req.header().emplace(
|
||||
std::string(name, name + namelen),
|
||||
header_value{std::string(value, value + valuelen),
|
||||
(flags & NGHTTP2_NV_FLAG_NO_INDEX) != 0});
|
||||
}
|
||||
|
||||
break;
|
||||
|
|
|
@ -265,8 +265,8 @@ int on_header_callback(nghttp2_session *session, const nghttp2_frame *frame,
|
|||
// fall through
|
||||
default:
|
||||
req.header().emplace(std::string(name, name + namelen),
|
||||
header_value(std::string(value, value + valuelen),
|
||||
flags & NGHTTP2_NV_FLAG_NO_INDEX));
|
||||
header_value{std::string(value, value + valuelen),
|
||||
(flags & NGHTTP2_NV_FLAG_NO_INDEX) != 0});
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -63,9 +63,6 @@ struct header {
|
|||
};
|
||||
|
||||
struct header_value {
|
||||
header_value(std::string value, bool sensitive = false)
|
||||
: value(std::move(value)), sensitive(sensitive) {}
|
||||
|
||||
std::string value;
|
||||
bool sensitive;
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue