networking · intermediate · ~15 min
Split an HTTP request line into fields.
Implement int parse_request_line(const char *line, char *method, int msz, char *path, int psz) splitting METHOD SP PATH SP VERSION into method and path. Return 1 on success, 0 if it doesn't have two spaces.
#include <string.h>
int parse_request_line(const char *line, char *method, int msz, char *path, int psz) {
/* TODO */
return 0;
}
Solve this exercise in the browser editor — compile and run against the test harness, no setup required.