MCPcopy Create free account
hub / github.com/cutelyst/cutelyst / parseMethod

Method parseMethod

Cutelyst/Server/protocolhttp.cpp:226–269  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

224}
225
226void ProtocolHttp::parseMethod(const char *ptr, const char *end, Socket *sock) const
227{
228 auto protoRequest = static_cast<ProtoRequestHttp *>(sock->protoData);
229 const char *word_boundary = ptr;
230 while (*word_boundary != ' ' && word_boundary < end) {
231 ++word_boundary;
232 }
233 protoRequest->method = QByteArray(ptr, int(word_boundary - ptr));
234
235 // skip spaces
236 while (*word_boundary == ' ' && word_boundary < end) {
237 ++word_boundary;
238 }
239 ptr = word_boundary;
240
241 // find path end
242 while (*word_boundary != ' ' && *word_boundary != '?' && word_boundary < end) {
243 ++word_boundary;
244 }
245
246 // This will change the ptr but will only change less than size
247 protoRequest->setPath(const_cast<char *>(ptr), int(word_boundary - ptr));
248
249 if (*word_boundary == '?') {
250 ptr = word_boundary + 1;
251 while (*word_boundary != ' ' && word_boundary < end) {
252 ++word_boundary;
253 }
254 protoRequest->query = QByteArray(ptr, int(word_boundary - ptr));
255 } else {
256 protoRequest->query = QByteArray();
257 }
258
259 // skip spaces
260 while (*word_boundary == ' ' && word_boundary < end) {
261 ++word_boundary;
262 }
263 ptr = word_boundary;
264
265 while (*word_boundary != ' ' && word_boundary < end) {
266 ++word_boundary;
267 }
268 protoRequest->protocol = QByteArray(ptr, int(word_boundary - ptr));
269}
270
271void ProtocolHttp::parseHeader(const char *ptr, const char *end, Socket *sock) const
272{

Callers

nothing calls this directly

Calls 1

setPathMethod · 0.80

Tested by

no test coverage detected