Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 9 additions & 14 deletions Release/include/cpprest/http_headers.h
Original file line number Diff line number Diff line change
Expand Up @@ -145,13 +145,15 @@ class http_headers
template<typename _t1>
void add(const key_type& name, const _t1& value)
{
if (has(name))
auto printedValue = utility::conversions::details::print_string(value);
auto& mapVal = m_headers[name];
if (mapVal.empty())
{
m_headers[name].append(_XPLATSTR(", ")).append(utility::conversions::details::print_string(value));
mapVal = std::move(printedValue);
}
else
{
m_headers[name] = utility::conversions::details::print_string(value);
mapVal.append(_XPLATSTR(", ")).append(std::move(printedValue));
}
}

Expand Down Expand Up @@ -212,20 +214,12 @@ class http_headers
bool match(const key_type &name, _t1 &value) const
{
auto iter = m_headers.find(name);
if (iter != m_headers.end())
{
// Check to see if doesn't have a value.
if(iter->second.empty())
{
bind_impl(iter->second, value);
return true;
}
return bind_impl(iter->second, value);
}
else
if (iter == m_headers.end())
{
return false;
}

return bind_impl(iter->second, value) || iter->second.empty();
}

/// <summary>
Expand Down Expand Up @@ -311,6 +305,7 @@ class http_headers
ref = utility::conversions::to_utf16string(text);
return true;
}

bool bind_impl(const key_type &text, std::string &ref) const
{
ref = utility::conversions::to_utf8string(text);
Expand Down