AnCH Framework 0.2
Another C++ Hack: C++23 utility libraries
Loading...
Searching...
No Matches
transport.hpp
1/*
2 ANCH Framework: ANother C++ Hack is a C++ framework based on C++23 standard
3 Copyright (C) 2026 Vincent Lachenal
4
5 This file is part of ANCH Framework.
6
7 ANCH Framework is free software: you can redistribute it and/or modify
8 it under the terms of the GNU Lesser General Public License as published by
9 the Free Software Foundation, either version 3 of the License, or
10 (at your option) any later version.
11
12 ANCH Framework is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU Lesser General Public License for more details.
16
17 You should have received a copy of the GNU Lesser General Public License
18 along with ANCH Framework. If not, see <https://www.gnu.org/licenses/>.
19*/
20#pragma once
21
22#include "anch-rest-client-export.hpp"
23
24#include <chrono>
25#include <optional>
26#include <stdexcept>
27#include <string>
28
29#include "rest/request.hpp"
30#include "rest/response.hpp"
31
32namespace anch::rest {
33
41 struct ANCH_REST_CLIENT_EXPORT TransportConfig {
43 std::chrono::milliseconds connectTimeout{10000};
44
46 std::chrono::milliseconds timeout{30000};
47
49 std::optional<std::string> proxy;
50
52 bool followRedirects = false;
53
55 bool verifyTls = true;
56
58 std::optional<std::string> caFile;
59
66 std::size_t maxResponseSize = 64 * 1024 * 1024;
67 };
68
77 class ANCH_REST_CLIENT_EXPORT TransportError: public std::runtime_error {
78 public:
80 using std::runtime_error::runtime_error;
81 };
82
90 class ANCH_REST_CLIENT_EXPORT Transport {
91
92 // Destructor +
93 public:
97 virtual ~Transport();
98 // Destructor -
99
100 // Methods +
101 public:
112 virtual anch::rest::Response send(const std::string& url, const anch::rest::Request& request) = 0;
113 // Methods -
114
115 };
116
117}
Definition request.hpp:50
Definition response.hpp:47
Definition transport.hpp:77
Definition transport.hpp:90
virtual anch::rest::Response send(const std::string &url, const anch::rest::Request &request)=0
AnCH REST library namespace.
Definition auth.hpp:29
Definition transport.hpp:41
bool verifyTls
Definition transport.hpp:55
std::optional< std::string > caFile
Definition transport.hpp:58
std::optional< std::string > proxy
Definition transport.hpp:49
bool followRedirects
Definition transport.hpp:52
std::size_t maxResponseSize
Definition transport.hpp:66
std::chrono::milliseconds connectTimeout
Definition transport.hpp:43
std::chrono::milliseconds timeout
Definition transport.hpp:46