MCPcopy Create free account
hub / github.com/bcndev/bytecoin / process_ready_header

Method process_ready_header

src/http/RequestParser.cpp:161–211  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

159}
160
161bool RequestParser::process_ready_header(RequestHeader &req) {
162 if (lowcase.name == "content-length") {
163 try {
164 req.content_length = common::integer_cast<decltype(req.content_length)>(lowcase.value); // std::stoull
165 req.headers.pop_back();
166 return true;
167 } catch (const std::exception &) {
168 }
169 return false;
170 }
171 if (lowcase.name == "host") {
172 req.host = lowcase.value;
173 req.headers.pop_back();
174 return true;
175 }
176 if (lowcase.name == "origin") {
177 req.origin = lowcase.value;
178 req.headers.pop_back();
179 return true;
180 }
181 if (lowcase.name == "connection") {
182 if (lowcase.value == "close") {
183 req.keep_alive = false;
184 req.headers.pop_back();
185 return true;
186 }
187 if (lowcase.value == "keep-alive") {
188 req.keep_alive = true;
189 req.headers.pop_back();
190 return true;
191 }
192 return false;
193 }
194 if (lowcase.name == "authorization") {
195 if (lowcase.value.find("basic") != 0)
196 return true;
197 size_t start = 5; // "basic".size()
198 const std::string &value = req.headers.back().value;
199 while (start < value.size() && (value[start] == ' ' || value[start] == '\t'))
200 start += 1;
201 // if( start == value.size())
202 // return false; // token required after basic
203 size_t finish = value.size();
204 while (finish > start && (value[finish - 1] == ' ' || value[finish - 1] == '\t'))
205 finish -= 1;
206 req.basic_authorization = value.substr(start, finish - start);
207 req.headers.pop_back();
208 return true;
209 }
210 return true;
211}

Callers

nothing calls this directly

Calls 1

sizeMethod · 0.45

Tested by

no test coverage detected