Add graceful handling of failed requests

This commit is contained in:
Nick Krichevsky 2018-09-02 20:57:48 -04:00
parent 735c399405
commit 28f5448b49

View file

@ -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);