Skip to content

Gaivile/server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Server

Implementation of web server that knows how to serve static content (i.e., files ending in .html, .jpg, et al.) and dynamic content (i.e., files ending in .php).

CS50 Problem Set 6

Usage: ./server [-p port] /path/to/root

Listens for HTTP requests on specified port number (default is 8080 - if not specified). The program enters infinite while loop to first free any previously allocated memory, then checks for SIGINT to stop the server; if the client is connected, parses HTTP request storing its "absolute path" and "query" inside of two arrays that are passed into it by reference. The path is then decoded into local path to show the exact file requested on the server:

    • For directories (that don't have index file) shows the list of directory's contents;
    • For files ending in .php interprets it's content, loads the output into memory and responds to the browser with (dynamically generated) output;
    • For other (supported) files transfers file's content from the server to the client by loading it into memory and responding to the browser.
  • Handles and responds to most errors accordingly before listening to new requests.

    About

    Implementation of web server

    Resources

    Stars

    Watchers

    Forks

    Releases

    No releases published

    Packages

    No packages published

    Languages