MCPcopy Create free account
hub / github.com/PurpleI2P/i2pd / parse_header_line

Function parse_header_line

libi2pd/HTTP.cpp:69–84  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

67 }
68
69 static std::pair<std::string, std::string> parse_header_line(std::string_view line)
70 {
71 std::size_t pos = 0;
72 std::size_t len = 1; /*: */
73 std::size_t max = line.length();
74 if ((pos = line.find(':', pos)) == std::string::npos)
75 return std::pair{"", ""}; // no ':' found
76 if (pos + 1 < max) // ':' at the end of header is valid
77 {
78 while ((pos + len) < max && isspace(line.at(pos + len)))
79 len++;
80 if (len == 1)
81 return std::pair{"", ""}; // no following space, but something else
82 }
83 return std::pair{std::string (line.substr(0, pos)), std::string (line.substr(pos + len))};
84 }
85
86 void gen_rfc7231_date(std::string & out) {
87 std::time_t now = std::time(nullptr);

Callers 1

parseMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected