Light-City / http-server

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool


HTTP SERVER

A basic implementation of an HTTP server done in c++! Linux and Windows friendly too 🙂.
Explore the docs »

Report Bug · Request Feature

Table of Contents
  1. About The Project
  2. Getting Started
  3. Usage
  4. Roadmap
  5. Contributing
  6. Contact

About The Project

This is basically a mini project showing one of the major ways in which HTTP servers are implemented. In summary, it uses a TCP socket to listen for incoming requests and sends back a basic HTTP response based on standards set by the RFC documents.

As previously mentioned, this implementation of an HTTP web server basically creates a TCP socket which:

  • listens for incoming requests on a particular socket address (which is mostly a combination of an IP address and a network port)
  • synchronously processes network connections from a queue of threads built up from the listening
  • reads the message sent by a client over the network connection and sends some dummy HTTP response.

Of course, there are many many many ways in which this code can be improved and/or extended, so this is an FYI saying that this is mainly for educational purposes. Do not go off trying to build your own server from scratch for use within production-level projects. Asides from the obvious "try not to re-invent the wheel rhethoric", chances are (with almost a certainty) you will end up with very serious security-related problems.

Jump to Roadmap to see more details about the project structure and its implementation overview.

(back to top)

Built With

(back to top)

Getting Started

This is a pretty simple project with just one requirement:

  • Docker (unless you want to build it manually, then you'd be needing C/C++ compiler).

Prerequisites

You will need to have docker setup on your computer, which can be done fairly easily by following the steps on their official documentation. The version run with docker is the linux version of the HTTP server implementation.

Building and Running

With docker fully setup on your system:

  1. navigate to your desired project directory
  2. Clone the repo
    git clone https://github.com/OsasAzamegbe/http-server.git
    (if you do not have git installed, take a brief detour and follow these instructions).
  3. navigate to the project folder http-server/ and build the docker image
    docker-compose build
  4. start the server
    docker-compose up

When you're done with the server and need it shut down:

  1. open up a second terminal window and navigate to the project folder
  2. bring down the docker container
    docker-compose down

NOTE: if you make any changes to the code, you will have to re-compile as well by simply running step 3 again.

Windows Version

instructions coming soon

(back to top)

Usage

Once your server is up and running with docker-compose up, you can pop into any web browser and navigate to localhost:8080/ to see the default HTTP response sent from the server. There will be an article coming soon where I'll talk more indept about the development of this HTTP server.

For more details, please refer to the Roadmap or the article (link coming soon)

(back to top)

Roadmap

instructions coming soon

(back to top)

Contributing

Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.

If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

(back to top)

Contact

Osamudiamen Azamegbe
Medium
osas.azamegbe@gmail.com

Project Link: https://github.com/OsasAzamegbe/http-server

(back to top)

About


Languages

Language:C++ 94.7%Language:CMake 2.7%Language:Dockerfile 2.6%