codecrafters-http-server-c

Serve (HTTP Server with headers compression)

progress-banner

image

Introduction

This project is a custom HTTP server implemented in C that supports gzip compression. The server is designed to handle HTTP requests, respond with appropriate content, and compress responses using gzip when requested by the client. The main goal of this project is to demonstrate the implementation of HTTP protocols, multi-threading, and data compression techniques.

Installation

To set up the project locally, follow these steps:

  1. Clone the repository: ```sh git clone https://github.com/Mohamed-Aladdin/codecrafters-http-server-c.git cd codecrafters-http-server-c
  2. Install required dependencies: Ensure you have the zlib library installed. On a Debian-based system, you can install it using: ```sh sudo apt-get install zlib1g-dev
  3. Compile the project: ```sh gcc -o server app/server.c -pthread -lz

Usage

To run the server, use the following command:

   ./server --directory <directory_path>

Replace with the path to the directory where your files are stored.

Example:

   ./server --directory /var/www/html

Making Requests:

To test the server, you can use curl or any other HTTP client. For example:

   curl -v -H "Accept-Encoding: gzip" http://localhost:4221/echo/abc

Contributing

Contributions are welcome! Please follow these steps to contribute:

  1. Fork the repository.
  2. Create a new branch (git checkout -b feature/your-feature).
  3. Commit your changes (git commit -am ‘Add some feature’).
  4. Push to the branch (git push origin feature/your-feature).
  5. Open a pull request.

Here are some related projects that you might find interesting:

Codecrafter’s HTTP Server: CodeCrafters

Licensing

This project is licensed under the MIT License. See the LICENSE file for more details.

This README.md provides a comprehensive guide for users and contributors.