MCPcopy Create free account
hub / github.com/Huntereb/Awoo-Installer / ParseHTMLHeader

Method ParseHTMLHeader

source/util/network_util.cpp:46–73  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

44 }
45
46 size_t HTTPHeader::ParseHTMLHeader(char* bytes, size_t size, size_t numItems, void* userData)
47 {
48 HTTPHeader* header = reinterpret_cast<HTTPHeader*>(userData);
49 size_t numBytes = size * numItems;
50 std::string line(bytes, numBytes);
51
52 // Remove any newlines or carriage returns
53 line.erase(std::remove(line.begin(), line.end(), '\n'), line.end());
54 line.erase(std::remove(line.begin(), line.end(), '\r'), line.end());
55
56 // Split into key and value
57 if (!line.empty())
58 {
59 auto keyEnd = line.find(": ");
60
61 if (keyEnd != 0)
62 {
63 std::string key = line.substr(0, keyEnd);
64 std::string value = line.substr(keyEnd + 2);
65
66 // Make key lowercase
67 std::transform(key.begin(), key.end(), key.begin(), ::tolower);
68 header->m_values[key] = value;
69 }
70 }
71
72 return numBytes;
73 }
74
75 void HTTPHeader::PerformRequest()
76 {

Callers

nothing calls this directly

Calls 3

beginMethod · 0.80
endMethod · 0.80
emptyMethod · 0.80

Tested by

no test coverage detected