networking · intermediate · ~15 min
Construct a valid HTTP request line + Host header.
Implement int build_get(char *out, int outsz, const char *host, const char *path) writing a minimal HTTP/1.1 GET request: GET <path> HTTP/1.1\r\nHost: <host>\r\n\r\n. Return the length.
#include <stdio.h>
int build_get(char *out, int outsz, const char *host, const char *path) {
/* TODO */
return 0;
}
Solve this exercise in the browser editor — compile and run against the test harness, no setup required.