Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.md

🌐 HTTP-based Web Server

An HTTP web server that can handle multiple simultaneous requests from users. An HTTP request from a client is received, processed, and those results are sent back to the client as a response. HTTP requests consist of three substrings: request method (GET, HEAD, POST, etc.), request URL (separated by '/', treated as a relative path), and request version ('HTTP/x,y', where x & y are numbers).

Program

C Language based program that sends TCP commands/requests to an HTTP server. The web server returns the response back to the client.

⚙️ SETUP

Web server testing

  • Launch the HTTP server within a commonly used web browser (i.e. Chome, Firefox) and direct requests to the server, port number, and index.html file. Example: http://localhost:3000/index.html.

📟 USE

HTTP User (client) Commands

The request consists of three parts (separated by spaces):

  1. method (GET, POST, HEAD)
  2. URL (directory)
  3. HTTP version Example: GET /Protocols/rfc1945/rfc1945 HTTP/1.1

Compiling

Note: If zipped, first unzip file before proceeding. tar -zxvf <zipfile>

  1. From root directory, run make echoserver from the terminal. This will generate a program called echoserver that is a simple server that responds back 'Hello World' in an h1 tag.
  2. To create the webserver, run make or make webserver to create a webserver executable object. Follow steps in next section for execution.
  3. Make clean will remove all files generated by make.

Executing

Once webserver objet is created, run ./webserver <PORT> in the terminal/console from the root directory of the executable file. Next, go to a web-browser and go to localhost:<PORT>. This will direct to the default index.html page, where links can be requested and transferred from the server.

Resources

  1. Socket - accept
  2. System Calls
  3. Graceful Exits
  4. TCP echo client and server with fork()
  5. TCP echo client and server with threads
  6. Echo server-client code with threads