| 224 | } |
| 225 | |
| 226 | void 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 | |
| 271 | void ProtocolHttp::parseHeader(const char *ptr, const char *end, Socket *sock) const |
| 272 | { |