https://github.com/xirzo/httpparser
Http parser for recreational purposes
https://github.com/xirzo/httpparser
http parser
Last synced: 10 days 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-05-08T20:58:06.000Z (12 months ago)
- Last Synced: 2025-05-08T21:47:07.669Z (12 months ago)
- Topics: http, parser
- Language: C
- Homepage:
- Size: 19.5 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
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). For recreational purposes only :).
## 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)
## Building
Clone the repository
```sh
git clone https://github.com/xirzo/httpparser.git
cd httpparser
```
```sh
cmake -DHTTP_PARSER_BUILD_EXAMPLES=ON -DHTTP_PARSER_BUILD_TESTS=ON -B build/
```
```sh
cmake --build build/
```
## Install
To install the library system-wide use
```sh
cd build
sudo make install
```
### Finding with CMake
Add the following to your CMakeLists.txt:
```cmake
find_package(HttpParser REQUIRED)
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);
// req = parse_http_request(request);
free_http_request(req);
}
```
## 🔗 Related Projects
- [WebsiteInC](https://github.com/xirzo/WebsiteInC)