Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

C-Web-Server - Scott Bren #303

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
8 changes: 4 additions & 4 deletions src/server.c
Original file line number Diff line number Diff line change
Expand Up @@ -140,12 +140,12 @@ void get_file(int fd, struct cache *cache, char *request_path)
mime_type = mime_type_get(filepath);

if(filedata == NULL) {
fprintf(stderr, "%s", request_path);
resp_404(fd);
} else {
send_response(fd, "HTTP/1.1 200 OK", mime_type, filedata->data, filedata->size);
file_free(filedata);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep it's an annoying pattern but whatever you allocate you must free.

}

//file_free(filedata);
}

/**
Expand All @@ -168,8 +168,8 @@ void handle_http_request(int fd, struct cache *cache)
{
const int request_buffer_size = 65536; // 64K
char request[request_buffer_size];
char *action;
char *endpoint;
char action[100];
char endpoint[100];

// Read request
int bytes_recvd = recv(fd, request, request_buffer_size - 1, 0);
Expand Down