networking · intermediate · ~15 min
Read the method off the request line.
Implement int request_method(const char *req, char *out, int outsz) copying the method (first token up to the first space) into out and returning its length, or -1 if there is no space.
#include <string.h>
int request_method(const char *req, char *out, int outsz) {
/* TODO */
return -1;
}
Solve this exercise in the browser editor — compile and run against the test harness, no setup required.