Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 4 additions & 8 deletions httpd.c
Original file line number Diff line number Diff line change
Expand Up @@ -160,15 +160,11 @@ void bad_request(int client)
* Parameters: the client socket descriptor
* FILE pointer for the file to cat */
/**********************************************************************/
void cat(int client, FILE *resource)
{
void cat(int client, FILE *resource) {
char buf[1024];

fgets(buf, sizeof(buf), resource);
while (!feof(resource))
{
send(client, buf, strlen(buf), 0);
fgets(buf, sizeof(buf), resource);
size_t n;
while ((n = fread(buf, 1, sizeof(buf), resource)) > 0) {
if (send(client, buf, n, 0) < 0) break;
}
}

Expand Down