asio: Utilize aggregate or value-initialization for header_value

This commit is contained in:
Tatsuhiro Tsujikawa 2015-03-04 21:53:11 +09:00
parent fc2170e488
commit e7d052100c
4 changed files with 12 additions and 13 deletions

View File

@ -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));

View File

@ -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;

View File

@ -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;

View File

@ -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;
};