mirror of
https://github.com/cesanta/slre.git
synced 2025-03-12 16:55:30 +00:00
427 B
427 B
title |
---|
Parsing HTTP request line |
const char *request = " GET /index.html HTTP/1.0\r\n\r\n";
struct slre_cap caps[4];
if (slre_match("^\\s*(\\S+)\\s+(\\S+)\\s+HTTP/(\\d)\\.(\\d)",
request, strlen(request), caps, 4, 0) > 0) {
printf("Method: [%.*s], URI: [%.*s]\n",
caps[0].len, caps[0].ptr,
caps[1].len, caps[1].ptr);
} else {
printf("Error parsing [%s]\n", request);
}