An open API service indexing awesome lists of open source software.

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

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)