Skip to content

A C++ async HTTP client library to use in asynchronous applications while communicating with REST services.

License

LGPL-3.0, GPL-3.0 licenses found

Licenses found

LGPL-3.0
COPYING.LESSER
GPL-3.0
COPYING
Notifications You must be signed in to change notification settings

alowoa/libashttp

This branch is up to date with tghosgor/libashttp:master.

Folders and files

NameName
Last commit message
Last commit date

Latest commit

73ccfe1 · Feb 4, 2015

History

12 Commits
Feb 4, 2015
Feb 4, 2015
Jan 30, 2015
Jan 30, 2015
Feb 4, 2015

Repository files navigation

libashttp

An asynchronous HTTP library using Boost.ASIO as the backend.

This project is licensed under:

LGPLv3

Usage

Here is a example usage which is taken from the repository:

auto client = ClientHTTPS::create("www.google.com", ioService);

{
  auto request = client->get("/");

  {
    request->onHeader([](const ErrorCode& ec, const Header& header) {
      std::cout << "request onheader " << ec << std::endl;

      std::cout << std::endl << "Header received; ec: " << ec << std::endl;

      std::cout << header.field() << std::endl;
    }).onBodyChunk([](const ErrorCode& ec, std::istream& is, std::size_t chunkSize) {
      std::cout << "request onbodychunk chunksize: " << chunkSize << ", ec: " << ec << std::endl;

      if (!ec) {
        std::cout << std::endl << "Body chunk received; ec: " << ec << std::endl;

        std::copy_n(std::istreambuf_iterator<char>{is}, chunkSize, std::ostreambuf_iterator<char>{std::cout});

        std::cout << std::endl;

        if (chunkSize == 0)// this is the last chunk
          std::cout << "all chunks received" << std::endl;
      }
    }).onTimeout([]() {
      std::cout << "timeout" << ec << std::endl;
    }).onComplete([client, request](const ErrorCode& ec) {
      std::cout << "oncomplete" << ec << std::endl;

      ioService.stop();
    });

    client->schedule(request);
  }
}

More through examples can be found in the repository.

About

A C++ async HTTP client library to use in asynchronous applications while communicating with REST services.

Resources

License

LGPL-3.0, GPL-3.0 licenses found

Licenses found

LGPL-3.0
COPYING.LESSER
GPL-3.0
COPYING

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C++ 100.0%