rippled
Loading...
Searching...
No Matches
HTTPClient.h
1//------------------------------------------------------------------------------
2/*
3 This file is part of rippled: https://github.com/ripple/rippled
4 Copyright (c) 2012, 2013 Ripple Labs Inc.
5
6 Permission to use, copy, modify, and/or distribute this software for any
7 purpose with or without fee is hereby granted, provided that the above
8 copyright notice and this permission notice appear in all copies.
9
10 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17*/
18//==============================================================================
19
20#ifndef RIPPLE_NET_HTTPCLIENT_H_INCLUDED
21#define RIPPLE_NET_HTTPCLIENT_H_INCLUDED
22
23#include <xrpl/basics/ByteUtilities.h>
24#include <xrpl/beast/utility/Journal.h>
25
26#include <boost/asio/io_context.hpp>
27#include <boost/asio/streambuf.hpp>
28
29#include <chrono>
30#include <deque>
31#include <functional>
32#include <string>
33
34namespace ripple {
35
39{
40public:
41 explicit HTTPClient() = default;
42
43 static constexpr auto maxClientHeaderBytes = kilobytes(32);
44
45 static void
47 std::string const& sslVerifyDir,
48 std::string const& sslVerifyFile,
49 bool sslVerify,
51
52 static void
53 get(bool bSSL,
54 boost::asio::io_context& io_context,
56 unsigned short const port,
57 std::string const& strPath,
58 std::size_t responseMax, // if no Content-Length header
60 std::function<bool(
61 boost::system::error_code const& ecResult,
62 int iStatus,
63 std::string const& strData)> complete,
65
66 static void
67 get(bool bSSL,
68 boost::asio::io_context& io_context,
69 std::string strSite,
70 unsigned short const port,
71 std::string const& strPath,
72 std::size_t responseMax, // if no Content-Length header
74 std::function<bool(
75 boost::system::error_code const& ecResult,
76 int iStatus,
77 std::string const& strData)> complete,
79
80 static void
81 request(
82 bool bSSL,
83 boost::asio::io_context& io_context,
84 std::string strSite,
85 unsigned short const port,
87 void(boost::asio::streambuf& sb, std::string const& strHost)> build,
88 std::size_t responseMax, // if no Content-Length header
90 std::function<bool(
91 boost::system::error_code const& ecResult,
92 int iStatus,
93 std::string const& strData)> complete,
95};
96
97} // namespace ripple
98
99#endif
A generic endpoint for log messages.
Definition Journal.h:60
Provides an asynchronous HTTP client implementation with optional SSL.
Definition HTTPClient.h:39
static void request(bool bSSL, boost::asio::io_context &io_context, std::string strSite, unsigned short const port, std::function< void(boost::asio::streambuf &sb, std::string const &strHost)> build, std::size_t responseMax, std::chrono::seconds timeout, std::function< bool(boost::system::error_code const &ecResult, int iStatus, std::string const &strData)> complete, beast::Journal &j)
static void initializeSSLContext(std::string const &sslVerifyDir, std::string const &sslVerifyFile, bool sslVerify, beast::Journal j)
HTTPClient()=default
static void get(bool bSSL, boost::asio::io_context &io_context, std::deque< std::string > deqSites, unsigned short const port, std::string const &strPath, std::size_t responseMax, std::chrono::seconds timeout, std::function< bool(boost::system::error_code const &ecResult, int iStatus, std::string const &strData)> complete, beast::Journal &j)
static constexpr auto maxClientHeaderBytes
Definition HTTPClient.h:43
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:25
constexpr auto kilobytes(T value) noexcept