From e7d052100cf26bb619f56ab45ef6b30834c1ecc9 Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Wed, 4 Mar 2015 21:53:11 +0900 Subject: [PATCH] asio: Utilize aggregate or value-initialization for header_value --- examples/asio-sv2.cc | 4 ++-- src/asio_client_session_impl.cc | 14 ++++++++------ src/asio_http2_handler.cc | 4 ++-- src/includes/nghttp2/asio_http2.h | 3 --- 4 files changed, 12 insertions(+), 13 deletions(-) diff --git a/examples/asio-sv2.cc b/examples/asio-sv2.cc index 07be841b..537fb3c3 100644 --- a/examples/asio-sv2.cc +++ b/examples/asio-sv2.cc @@ -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)); diff --git a/src/asio_client_session_impl.cc b/src/asio_client_session_impl.cc index 1803cf57..198827ec 100644 --- a/src/asio_client_session_impl.cc +++ b/src/asio_client_session_impl.cc @@ -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; diff --git a/src/asio_http2_handler.cc b/src/asio_http2_handler.cc index 6854bc4d..8ea9c645 100644 --- a/src/asio_http2_handler.cc +++ b/src/asio_http2_handler.cc @@ -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; diff --git a/src/includes/nghttp2/asio_http2.h b/src/includes/nghttp2/asio_http2.h index 97c1b5d0..0ac04d95 100644 --- a/src/includes/nghttp2/asio_http2.h +++ b/src/includes/nghttp2/asio_http2.h @@ -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; };