networking · intermediate · ~15 min
Look up an HTTP header value.
Implement int header_value(const char *req, const char *name, char *out, int outsz) finding a header line Name: value and copying value (after ": ") into out, returning its length, or -1 if not found.
#include <string.h>
int header_value(const char *req, const char *name, char *out, int outsz) {
/* TODO */
return -1;
}
Solve this exercise in the browser editor — compile and run against the test harness, no setup required.