HttpRequestParse
Description
Parse an HTTP/1.1 request out of in into req. req must already be initialized with HttpRequestInit(...) so the parser has an allocator to write into.
Success
Returns a pointer past the parsed request line + headers (start of the body).
Failure
Returns in unchanged when the input is malformed.
Usage example (Cross-references)
Usage examples (Cross-references)
- In
Beam.c:253:
HttpRequest req = HttpRequestInit(scope);
Zstr end = HttpRequestParse(&req, (Zstr)StrBegin(&raw));
if (end == StrBegin(&raw)) {
LOG_INFO("[{}] (unparseable request, {} bytes)", client_addr, (u64)prefix_len);- In
Http.Leak.c:91:
HttpRequest req = HttpRequestInit(adbg);
Zstr next = HttpRequestParse(&req, raw);
bool ok = (next != raw) && (StrLen(&req.url) > 0);
ok = ok && (DebugAllocatorLiveCount(&dbg) > 0);- In
Http.c:23:
HttpRequest req = HttpRequestInit(alloc_base);
Zstr next = HttpRequestParse(&req, raw);
bool ok = (next != raw) && (req.method == HTTP_REQUEST_METHOD_GET) && (StrLen(&req.url) == 11) &&- In
Http.c:89:
for (u64 i = 0; i < sizeof(cases) / sizeof(cases[0]); i++) {
HttpRequest req = HttpRequestInit(alloc_base);
Zstr next = HttpRequestParse(&req, cases[i].raw);
ok = ok && (next != cases[i].raw) && (req.method == cases[i].method);
HttpRequestDeinit(&req);- In
Http.c:113:
for (u64 i = 0; i < sizeof(cases) / sizeof(cases[0]); i++) {
HttpRequest req = HttpRequestInit(alloc_base);
Zstr next = HttpRequestParse(&req, cases[i]);
ok = ok && (next == cases[i]) && (req.method == HTTP_REQUEST_METHOD_UNKNOWN);
HttpRequestDeinit(&req);- In
Http.c:136:
for (u64 i = 0; i < sizeof(cases) / sizeof(cases[0]); i++) {
HttpRequest req = HttpRequestInit(alloc_base);
Zstr next = HttpRequestParse(&req, cases[i]);
ok = ok && (next == cases[i]) && (req.method == HTTP_REQUEST_METHOD_UNKNOWN);
HttpRequestDeinit(&req);- In
Http.c:165:
HttpRequest req = HttpRequestInit(alloc_base);
Zstr in = StrBegin(&raw);
Zstr next = HttpRequestParse(&req, in);
// Real code rejects: cursor returned unchanged (== in).
- In
Http.c:192:
HttpRequest req = HttpRequestInit(alloc_base);
Zstr in = StrBegin(&raw);
Zstr next = HttpRequestParse(&req, in);
bool ok = (next != in) && (VecLen(&req.headers) == 100);
Last updated on