mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-02-04 21:24:15 +00:00
allow HTTP headers without value
This commit is contained in:
parent
c4c896a833
commit
64d800427f
@ -55,12 +55,16 @@ namespace http {
|
|||||||
static std::pair<std::string, std::string> parse_header_line(const std::string& line)
|
static std::pair<std::string, std::string> parse_header_line(const std::string& line)
|
||||||
{
|
{
|
||||||
std::size_t pos = 0;
|
std::size_t pos = 0;
|
||||||
std::size_t len = 2; /* strlen(": ") */
|
std::size_t len = 1; /*: */
|
||||||
std::size_t max = line.length();
|
std::size_t max = line.length();
|
||||||
if ((pos = line.find(": ", pos)) == std::string::npos)
|
if ((pos = line.find(':', pos)) == std::string::npos)
|
||||||
return std::make_pair("", "");
|
return std::make_pair("", ""); // no ':' found
|
||||||
while ((pos + len) < max && isspace(line.at(pos + len)))
|
if (pos + 1 < max) // ':' at the end of header is valid
|
||||||
len++;
|
{
|
||||||
|
while ((pos + len) < max && isspace(line.at(pos + len)))
|
||||||
|
len++;
|
||||||
|
if (len == 1) return std::make_pair("", ""); // no following space, but something else
|
||||||
|
}
|
||||||
return std::make_pair(line.substr(0, pos), line.substr(pos + len));
|
return std::make_pair(line.substr(0, pos), line.substr(pos + len));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user