Skip to content

tim37021/http_request

Repository files navigation

C++ Asynchronous HTTP Client

This project is a C++ application demonstrating an asynchronous HTTP client built using libcurl. It provides a simple framework for making non-blocking HTTP requests.

Features

  • Asynchronous GET and POST requests.
  • Streaming request and response bodies.
  • Modern C++ (C++23) implementation.
  • Dependency management with Conan.
  • Building with CMake.

Dependencies

  • C++23 compatible compiler (e.g., GCC, Clang)
  • CMake (version 3.10+)
  • Conan

Building the Project

  1. Install Dependencies: Ensure you have CMake and Conan installed on your system. The C++ dependencies (absl, gtest, libcurl) will be fetched by Conan.

  2. Configure and Build: Use the following commands to configure the project with Conan and build it with CMake:

    mkdir -p build
    cd build
    conan install .. --build=missing
    cmake .. -DCMAKE_TOOLCHAIN_FILE=build/Release/generators/conan_toolchain.cmake -DCMAKE_BUILD_TYPE=Release
    cmake --build .

Usage

The project builds two main executables: download and upload.

Download

The download executable performs a GET request to a specified URL.

./build/bin/download --url <URL>

Example:

./build/bin/download --url https://www.google.com

Upload

The upload executable performs a POST request, streaming a generated body to the target URL.

./build/bin/upload --url <URL>

Example:

./build/bin/upload --url https://httpbin.org/post

Running Tests

The project includes unit tests using GoogleTest. To run the tests, execute the following command from the build directory:

ctest

Fun Fact

Despite the help of Gemini-cli, this project is carefully designed and written by human. But I highly recommend you to try it out.

About

An attempt to design async http request class.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors