Add graceful handling of failed requests
This commit is contained in:
parent
735c399405
commit
28f5448b49
|
@ -34,7 +34,11 @@ int main(int argc, char* argv[]) {
|
|||
printf("%s\n%s\n", path_buffer, host_buffer);
|
||||
struct http_message req = build_basic_request("GET", host_buffer, path_buffer, port_num);
|
||||
char * req_result = send_request(req);
|
||||
printf("%s", req_result);
|
||||
if (req_result == NULL) {
|
||||
printf("An error occured while opening the socket. Please try again.\n");
|
||||
} else {
|
||||
printf("%s\n", req_result);
|
||||
}
|
||||
free_basic_request(req);
|
||||
free(req_result);
|
||||
free(host_buffer);
|
||||
|
|
Loading…
Reference in a new issue