MCPcopy Create free account
hub / github.com/BernardoGiordano/Checkpoint / headerSlist

Function headerSlist

common/script/httpcall.cpp:105–124  ·  view source on GitHub ↗

"\n"-separated "Key: Value" lines into a curl slist (nullptr => none).

Source from the content-addressed store, hash-verified

103
104 // "\n"-separated "Key: Value" lines into a curl slist (nullptr => none).
105 struct curl_slist* headerSlist(const char* headers)
106 {
107 struct curl_slist* hl = nullptr;
108 if (headers && headers[0]) {
109 std::string all(headers);
110 size_t start = 0;
111 while (start < all.size()) {
112 const size_t nl = all.find('\n', start);
113 std::string line = all.substr(start, nl == std::string::npos ? std::string::npos : nl - start);
114 if (!line.empty()) {
115 hl = curl_slist_append(hl, line.c_str());
116 }
117 if (nl == std::string::npos) {
118 break;
119 }
120 start = nl + 1;
121 }
122 }
123 return hl;
124 }
125
126 // Everything the four bindings used to spell out one at a time. The only
127 // conditional options are the ones a transfer genuinely varies: verb,

Callers 1

performFunction · 0.85

Calls 3

findMethod · 0.80
sizeMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected