https://github.com/lamarrr/swish
C++ HTTP requests for humans
https://github.com/lamarrr/swish
cpp cpp17 http http-client http-proxy http-requests
Last synced: about 5 hours ago
JSON representation
C++ HTTP requests for humans
- Host: GitHub
- URL: https://github.com/lamarrr/swish
- Owner: lamarrr
- License: mit
- Created: 2018-11-25T22:46:27.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2021-11-24T11:33:00.000Z (over 4 years ago)
- Last Synced: 2024-05-02T02:37:10.201Z (almost 2 years ago)
- Topics: cpp, cpp17, http, http-client, http-proxy, http-requests
- Language: C++
- Homepage:
- Size: 51.8 KB
- Stars: 63
- Watchers: 2
- Forks: 8
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# Swish

## Overview
Swish is a Modern C++ 17 HTTP client library for Humans
Swish is for the most parts, A simple libcurl wrapper which provides, data structures and type safe OOP abstractions to make operating with libcurl much easier and pain free as compared to error-prone manual manipulation of net. sockets.
## Features
- Provides implementations for GET, POST (Multipart and Form Fields), DELETE, HEAD, TRACE etc.
- Fast file download
- Simple and expressive API (type safe OOP)
- Byte type customization
- Almost zero cost abstraction
- Supports local file://location
- Custom data structures for ease of use
- Proxy and OAuth support
## Installation
- Install libcurl (7.60.0 or higher)
- clone this repo
- build and install using cmake e.g. For linux users
```bash
user@pc:~$ cmake .
user@pc:~$ sudo make install
```
- *or* copy the *swish* directory to your project's local or global include path
## Quick Start
```cpp
/**
* @file: example.cc
*
*/
#include
using namespace swish;
int main() {
// create a new HTTP client
auto client = Client();
// Perform request
auto [response, status] = client.Get("https://github.com");
// Check if any errors occured
if (IsOK(status)) {
// convert body buffer to std::basic_string aka std::string
std::cout << response.body.ToString() << "\n";
} else {
// Interpret status code to english
std::cerr << "The following Error occured: " << InterpretStatusCode(status)
<< "\n";
}
return EXIT_SUCCESS;
}
```
## Building
Swish depends on libcurl, ensure you have an active installation.
Compile with the -lcurl postfix flag e.g in clang :
```bash
user@pc:~$ clang++ -std=c++17 example.cc -o example.o -lcurl
user@pc:~$ clang++ -std=c++17 example.cc -o example.o -lcurl
user@pc:~$ ./example.o
```