Skip to content

flahertyb/my-simple-web-server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CS 3600 Project 4: An HTTP Web Server

When creating this web server, we started by getting the serve client function to parse just the first line of an HTTP get request, determine the filename, and serve the file back to the client.

We then added the HTTP response header.  We format it in a struct composed of several char *s.  Once formatted, we compose all the header fields and the file contents into a char * full_response, and call send using that buffer.  I think designing the code this way makes it more readable and obvious what is happening, instead of doing multiple send calls or just going through the header fields sequentially.  

The biggest challenge was a heap-smashing memory bug that apparently was caused by initializing the header structure as a pointer:

struct *header = malloc(...);
format_header(header, ...);

Switching this to 

struct header = malloc(...);
format_header(&header, ...);

seemed to solve the whole issue. 

Our code satisfies all general requirements except 404 errors.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages