@@ -42,23 +42,27 @@ std::deque<std::string> ReplyImpl::GetHeaders(const std::string& name) {
4242ReplyImpl::ReplyImpl (Connection::ptr_t connection,
4343 Context& ctx,
4444 RestClient& owner,
45- Request::Properties::ptr_t & properties)
45+ Request::Properties::ptr_t & properties,
46+ Request::Type type)
4647: connection_{move (connection)}, ctx_{ctx}
4748, properties_{properties}
4849, owner_{owner}
4950, connection_id_(connection_ ? connection_->GetId ()
5051 : boost::uuids::random_generator()())
52+ , request_type_{type}
5153{
5254}
5355
5456ReplyImpl::ReplyImpl (Connection::ptr_t connection,
5557 Context& ctx,
56- RestClient& owner)
58+ RestClient& owner,
59+ Request::Type type)
5760: connection_{move (connection)}, ctx_{ctx}
5861, properties_{owner.GetConnectionProperties ()}
5962, owner_{owner}
6063, connection_id_(connection_ ? connection_->GetId ()
6164 : boost::uuids::random_generator()())
65+ , request_type_{type}
6266{
6367}
6468
@@ -107,7 +111,9 @@ void ReplyImpl::HandleContentType(unique_ptr<DataReaderStream>&& stream) {
107111 static const std::string transfer_encoding_name{" Transfer-Encoding" };
108112 static const std::string chunked_name{" chunked" };
109113
110- if (const auto cl = GetHeader (content_len_name)) {
114+ if (request_type_ == Request::Type::HEAD ) {
115+ reader_ = DataReader::CreateNoBodyReader ();
116+ } else if (const auto cl = GetHeader (content_len_name)) {
111117 content_length_ = stoi (*cl);
112118 reader_ = DataReader::CreatePlainReader (*content_length_, move (stream));
113119 } else {
@@ -225,9 +231,10 @@ std::unique_ptr<ReplyImpl>
225231ReplyImpl::Create (Connection::ptr_t connection,
226232 Context& ctx,
227233 RestClient& owner,
228- Request::Properties::ptr_t & properties) {
234+ Request::Properties::ptr_t & properties,
235+ Request::Type type) {
229236
230- return make_unique<ReplyImpl>(move (connection), ctx, owner, properties);
237+ return make_unique<ReplyImpl>(move (connection), ctx, owner, properties, type );
231238}
232239
233240} // restc_cpp
0 commit comments