Skip to content

This project is about writing our own HTTP server.

License

Notifications You must be signed in to change notification settings

saladuit/BuzingaServ

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

BuzingaServ: A Custom HTTP Sever

BuzingaServ is a custom web server application implemented in C++ that's designed to understand and process HTTP requests and responses.

URL Understanding:

BuzingaServ is capable of recognizing and processing Universal Resource Locators (URLs), ensuring accurate request routing.

HTTP Protocol:

The server handles plain text messages that conform to the Hypertext Transfer Protocol (HTTP) standards.

Transport Layer Integration:

All messages are transmitted through a transport layer. BuzingaServ makes use of the Transmission Control Protocol (TCP), ensuring reliable message delivery.

Protocol Suite:

Both HTTP and TCP are part of the internet protocol suite. It's worth noting that while our server is custom-built, these protocols' foundational support is provided by the operating system.

Definitions

HTTP:

A language for communicating between two computers. It specifies how to transfer documents that are interconnected by hyperlinks. A message is constructed as a request or a response.

TCP:

Transmission Control Protocol Used to establish host-to-host data transfer channels. It maintains communications between application processes between hosts (client and server), and they use port numbers to track sessions.

Internet Protocol Suite || TCP/IP:

A conceptual model to specify how data should be packetized,addressed, transmitted routed and received. It made up of 4 abstraction layers: application, transport, internet and link layers. An application like a web browser needs to receive data over the internet it communicates with the Trancport layer of the CP/IP stack using a specific port number. HTTP usually uses port 80.

Request / Response

HTTP Request
  1. A request line,
  2. Headers,
  3. Empty line,
  4. optional message body.

HTTP Response

  1. Status line,
  2. Headers,
  3. Empty line,
  4. optional message body.

When a request is made by the application layer, the message passes through the layerson one side, and back up through layer on the other side. Logically each layer talks to the corresponding layer on the other side.

man 4 tcp

SOCKET -> BIND -> LISTEN -> ACCEPT -> READ/WRITE

We need to implement a ‘socket’ on which we can ‘listen’ for incoming connections, Then we need to ‘bind’ the socket to a local address, and port. Then put the socket in a ‘listen’ state. After that we’re able to ‘accept’ incoming connections, for each accepted connection a new socket will be created, and we will be able to read and write to this socket. The following diagram gives a bit of an overview of what we need to implement.

man 4 socket

socket() creates an endpoint for communication and returns a descriptor.

Tools

References

Required Reading

Grammer


'WORD' |

Configfile | BLOCK ; BLOCK | BLOCK identifier '{' Body '}' | identifier '{' Body '}' ; Body | global | server location_BLOCK ; identifier | 'server' | 'global' ; global | Setting ; server | Setting ; location_BLOCK | location_BLOCK 'location' path '{' Setting '}' | 'location' path '{' Setting '}' ; Setting | Setting Option ';' | Option ';' ; Option | Key Value ; Key | WORD ; Value | Value WORD | WORD ; path | WORD ;