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 <xrpld/core/Config.h>
24#include <xrpl/basics/ByteUtilities.h>
25#include <boost/asio/io_service.hpp>
26#include <boost/asio/streambuf.hpp>
27
28#include <chrono>
29#include <deque>
30#include <functional>
31#include <string>
32
33namespace ripple {
34
38{
39public:
40 explicit HTTPClient() = default;
41
42 static constexpr auto maxClientHeaderBytes = kilobytes(32);
43
44 static void
46
47 static void
48 get(bool bSSL,
49 boost::asio::io_service& io_service,
51 const unsigned short port,
52 std::string const& strPath,
53 std::size_t responseMax, // if no Content-Length header
55 std::function<bool(
56 const boost::system::error_code& ecResult,
57 int iStatus,
58 std::string const& strData)> complete,
60
61 static void
62 get(bool bSSL,
63 boost::asio::io_service& io_service,
64 std::string strSite,
65 const unsigned short port,
66 std::string const& strPath,
67 std::size_t responseMax, // if no Content-Length header
69 std::function<bool(
70 const boost::system::error_code& ecResult,
71 int iStatus,
72 std::string const& strData)> complete,
74
75 static void
76 request(
77 bool bSSL,
78 boost::asio::io_service& io_service,
79 std::string strSite,
80 const unsigned short port,
82 void(boost::asio::streambuf& sb, std::string const& strHost)> build,
83 std::size_t responseMax, // if no Content-Length header
85 std::function<bool(
86 const boost::system::error_code& ecResult,
87 int iStatus,
88 std::string const& strData)> complete,
90};
91
92} // namespace ripple
93
94#endif
A generic endpoint for log messages.
Definition: Journal.h:59
Provides an asynchronous HTTP client implementation with optional SSL.
Definition: HTTPClient.h:38
static void initializeSSLContext(Config const &config, beast::Journal j)
Definition: HTTPClient.cpp:38
static void request(bool bSSL, boost::asio::io_service &io_service, std::string strSite, const unsigned short port, std::function< void(boost::asio::streambuf &sb, std::string const &strHost)> build, std::size_t responseMax, std::chrono::seconds timeout, std::function< bool(const boost::system::error_code &ecResult, int iStatus, std::string const &strData)> complete, beast::Journal &j)
Definition: HTTPClient.cpp:585
static void get(bool bSSL, boost::asio::io_service &io_service, std::deque< std::string > deqSites, const unsigned short port, std::string const &strPath, std::size_t responseMax, std::chrono::seconds timeout, std::function< bool(const boost::system::error_code &ecResult, int iStatus, std::string const &strData)> complete, beast::Journal &j)
Definition: HTTPClient.cpp:543
HTTPClient()=default
static constexpr auto maxClientHeaderBytes
Definition: HTTPClient.h:42
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition: algorithm.h:26
constexpr auto kilobytes(T value) noexcept
Definition: ByteUtilities.h:27