Fix answer_type::get_header().
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
The previous implementation returned a reference to an out-of-scope string.
This commit is contained in:
parent
913130b57d
commit
7ba967a36c
|
@ -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
|
||||
*/
|
||||
|
|
|
@ -54,7 +54,7 @@ string_view answer_type::get_header(const string_view field) const
|
|||
auto pos{static_cast<size_t>(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 {};
|
||||
|
|
Loading…
Reference in New Issue
Block a user