diff --git a/include/answer.hpp b/include/answer.hpp index 56a8324..b0cafdf 100644 --- a/include/answer.hpp +++ b/include/answer.hpp @@ -103,7 +103,9 @@ struct answer_type /*! * @brief Returns the value of a header field. * - * Case insensitive, only ASCII. + * Is only valid for as long as the answer_type is in scope. + * + * @param field Case insensitive, only ASCII. * * @since 0.1.0 */ diff --git a/src/answer.cpp b/src/answer.cpp index 8cc9236..0db9176 100644 --- a/src/answer.cpp +++ b/src/answer.cpp @@ -54,7 +54,7 @@ string_view answer_type::get_header(const string_view field) const auto pos{static_cast(it - headers.begin())}; pos = headers.find(':', pos) + 2; const auto endpos{headers.find('\n', pos)}; - return headers.substr(pos, endpos - pos); + return string_view(&headers[pos], endpos - pos); } return {};