slre/docs/parse-http-request.md
Sergey Lyubka 568dae4af7 SLRE docs - README references real docs
PUBLISHED_FROM=7d86931eac76f353b13195fd31b269853aed1e05
2016-06-07 20:45:53 +00:00

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);
}