https://github.com/abhaysp95/noob_http_server
A simple http server
https://github.com/abhaysp95/noob_http_server
http-server zig ziglang
Last synced: 4 months ago
JSON representation
A simple http server
- Host: GitHub
- URL: https://github.com/abhaysp95/noob_http_server
- Owner: abhaysp95
- Created: 2024-06-23T07:55:56.000Z (about 2 years ago)
- Default Branch: master
- Last Pushed: 2024-07-01T17:09:50.000Z (almost 2 years ago)
- Last Synced: 2025-01-08T00:21:14.435Z (over 1 year ago)
- Topics: http-server, zig, ziglang
- Language: Zig
- Homepage:
- Size: 62.5 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
[](https://app.codecrafters.io/users/codecrafters-bot?r=2qF)
# Noob Http Server
This is not like prod-ready server or anything. The purpose of this project was to learn the internal mechanism of how a typical HTTP server works. Here I have built a simple server for `HTTP/1.1` protocol.
### 📖 Learnings
Following are the things which I learned:
* Establishing connection via TCP server.
* Reading the client request.
* Parsing the client request (Request line, Headers & Body).
* Forming the response (Status line, Headers & Body).
* Sending the response back to the client.
* Handling multiple clients (i.e., concurrent connections)
* Handling signal sent from terminal running the server.
* Sending over the file to client upon request.
* Learn some bits about HTTP compression mechanism.
* Parsing for the multiple compression schemes.
* Support for Gzip compression.
### ⚡️ Requirements
The project is written in [Zig](https://ziglang.org/) programming language. The experience to use this language was pleasant. I would encourage for people to try it out. The comunity of the language although relatively small, has been a helping one. I would continue doing some other projects on this language.
Here are the steps to build the project:
* Follow the steps mentioned on the [zig's official site](https://ziglang.org/learn/getting-started/#installing-zig) and setup the language.
* Run the command `zig build-exe src/main.zig` to build the executable
* Simply run the executable as `./main`
---
The following project was done as part of **Codecrafters** challenge. You can read more about the codecrafters from below.
This is a starting point for Zig solutions to the
["Build Your Own HTTP server" Challenge](https://app.codecrafters.io/courses/http-server/overview).
[HTTP](https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol) is the
protocol that powers the web. In this challenge, you'll build a HTTP/1.1 server
that is capable of serving multiple clients.
Along the way you'll learn about TCP servers,
[HTTP request syntax](https://www.w3.org/Protocols/rfc2616/rfc2616-sec5.html),
and more.
**Note**: If you're viewing this repo on GitHub, head over to
[codecrafters.io](https://codecrafters.io) to try the challenge.
