https://github.com/xirzo/httpparser
Http parser for recreational purposes
https://github.com/xirzo/httpparser
http parser
Last synced: about 1 year ago
JSON representation
Http parser for recreational purposes
- Host: GitHub
- URL: https://github.com/xirzo/httpparser
- Owner: xirzo
- License: bsd-3-clause
- Created: 2025-03-01T15:14:02.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-03-01T18:05:46.000Z (about 1 year ago)
- Last Synced: 2025-03-01T18:33:15.865Z (about 1 year ago)
- Topics: http, parser
- Language: C
- Homepage:
- Size: 1000 Bytes
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 🚀 HTTP Parser
## 🚧 Project Status
> **Currently Under Development** - Core functionality is being implemented
HTTP Parser is a C library made to parse HTTP requests. It was originally created to support [C-Website](https://github.com/xirzo/C-Website), a web server implementation written in C programming language. For recreational purposes only :).
## ✨ Current Features
- 🔹 HTTP request status line parsing
- 🔹 Support for standard HTTP methods (GET, POST, PUT, DELETE, etc.)
- 🔹 HTTP version detection (HTTP/0.9 through HTTP/3)
## 🔮 Roadmap
Enhancements planned for this library:
- 📋 Complete HTTP header parsing
- 📦 HTTP request body handling
## 📥 Installation Guide
To build and install the HTTP Parser library, follow these steps:
### Prerequisites
- **CMake** (version 3.31.4 or higher)
- **C Compiler** (e.g., `gcc`, `clang`)
- **Make**
### Step 1: Clone the Repository
Clone the repository to your local machine:
```bash
git clone https://github.com/your-username/http-parser.git
cd http-parser
```
### Step 2: Configure the Project with CMake
Create a build directory and configure the project:
```bash
mkdir build
cd build
cmake ..
```
#### Step 2.1: Optionally you can build examples/tests
```bash
cmake -DHTTP_PARSER_BUILD_EXAMPLES=ON -DHTTP_PARSER_BUILD_TESTS=ON ..
```
This will generate the necessary build files.
### Step 3: Build the Project
Compile the project using `make`:
```bash
make
```
This will build the library and any associated binaries or tests.
### Step 4: Install the Library (Optional)
To install the library system-wide, run:
```bash
sudo make install
```
### Step 5: Uninstall the Library (If needed)
If you need to remove the library from your system:
```bash
sudo make uninstall
```
### 🔗 Linking with Your Project
#### Using CMake
Add the following to your CMakeLists.txt:
```cmake
find_package(HttpParser REQUIRED)
# Link to your target
target_link_libraries(your_target PRIVATE HttpParser::http_parser)
```
---
## 🔧 Usage
```c
#include "http_parser.h"
void example() {
char request[] = "GET /index.html HTTP/1.1\r\n";
HttpRequest *req;
init_http_request(&req);
parse_request_line(req, request);
// Future versions will support full request parsing
// req = parse_http_request(request);
free_http_request(req);
}
```
## 🔗 Related Projects
- [C-Website](https://github.com/xirzo/C-Website) - A web server written entirely in C