Instrument Neutral Distributed Interface INDI 2.2.5
Classes | Namespaces | Macros | Typedefs | Enumerations | Functions
httplib.h File Reference
#include <arpa/inet.h>
#include <ifaddrs.h>
#include <net/if.h>
#include <netdb.h>
#include <netinet/in.h>
#include <csignal>
#include <netinet/tcp.h>
#include <poll.h>
#include <pthread.h>
#include <sys/mman.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <unistd.h>
#include <algorithm>
#include <array>
#include <atomic>
#include <cassert>
#include <cctype>
#include <climits>
#include <condition_variable>
#include <cstring>
#include <errno.h>
#include <exception>
#include <fcntl.h>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <mutex>
#include <random>
#include <regex>
#include <set>
#include <sstream>
#include <string>
#include <sys/stat.h>
#include <thread>
#include <unordered_map>
#include <unordered_set>
#include <utility>

Go to the source code of this file.

Classes

struct  httplib::detail::case_ignore::equal_to
 
struct  httplib::detail::case_ignore::hash
 
struct  httplib::detail::scope_exit
 
struct  httplib::FormData
 
struct  httplib::FormField
 
struct  httplib::MultipartFormData
 
struct  httplib::UploadFormData
 
class  httplib::DataSink
 
struct  httplib::FormDataProvider
 
class  httplib::ContentReader
 
struct  httplib::Request
 
struct  httplib::Response
 
class  httplib::Stream
 
class  httplib::TaskQueue
 
class  httplib::ThreadPool
 
class  httplib::detail::MatcherBase
 
class  httplib::detail::PathParamsMatcher
 
class  httplib::detail::RegexMatcher
 
class  httplib::Server
 
class  httplib::Result
 
struct  httplib::ClientConnection
 
struct  httplib::detail::BodyReader
 
class  httplib::ClientImpl
 
struct  httplib::ClientImpl::StreamHandle
 
struct  httplib::ClientImpl::Socket
 
class  httplib::Client
 

Namespaces

namespace  httplib
 
namespace  httplib::detail
 
namespace  httplib::detail::case_ignore
 
namespace  httplib::detail::fields
 
namespace  httplib::stream
 
namespace  httplib::sse
 
namespace  httplib::detail::udl
 

Macros

#define CPPHTTPLIB_VERSION   "0.29.0"
 
#define CPPHTTPLIB_VERSION_NUM   "0x001D00"
 
#define CPPHTTPLIB_KEEPALIVE_TIMEOUT_SECOND   5
 
#define CPPHTTPLIB_KEEPALIVE_TIMEOUT_CHECK_INTERVAL_USECOND   10000
 
#define CPPHTTPLIB_KEEPALIVE_MAX_COUNT   100
 
#define CPPHTTPLIB_CONNECTION_TIMEOUT_SECOND   300
 
#define CPPHTTPLIB_CONNECTION_TIMEOUT_USECOND   0
 
#define CPPHTTPLIB_SERVER_READ_TIMEOUT_SECOND   5
 
#define CPPHTTPLIB_SERVER_READ_TIMEOUT_USECOND   0
 
#define CPPHTTPLIB_SERVER_WRITE_TIMEOUT_SECOND   5
 
#define CPPHTTPLIB_SERVER_WRITE_TIMEOUT_USECOND   0
 
#define CPPHTTPLIB_CLIENT_READ_TIMEOUT_SECOND   300
 
#define CPPHTTPLIB_CLIENT_READ_TIMEOUT_USECOND   0
 
#define CPPHTTPLIB_CLIENT_WRITE_TIMEOUT_SECOND   5
 
#define CPPHTTPLIB_CLIENT_WRITE_TIMEOUT_USECOND   0
 
#define CPPHTTPLIB_CLIENT_MAX_TIMEOUT_MSECOND   0
 
#define CPPHTTPLIB_IDLE_INTERVAL_SECOND   0
 
#define CPPHTTPLIB_IDLE_INTERVAL_USECOND   0
 
#define CPPHTTPLIB_REQUEST_URI_MAX_LENGTH   8192
 
#define CPPHTTPLIB_HEADER_MAX_LENGTH   8192
 
#define CPPHTTPLIB_HEADER_MAX_COUNT   100
 
#define CPPHTTPLIB_REDIRECT_MAX_COUNT   20
 
#define CPPHTTPLIB_MULTIPART_FORM_DATA_FILE_MAX_COUNT   1024
 
#define CPPHTTPLIB_PAYLOAD_MAX_LENGTH   ((std::numeric_limits<size_t>::max)())
 
#define CPPHTTPLIB_FORM_URL_ENCODED_PAYLOAD_MAX_LENGTH   8192
 
#define CPPHTTPLIB_RANGE_MAX_COUNT   1024
 
#define CPPHTTPLIB_TCP_NODELAY   false
 
#define CPPHTTPLIB_IPV6_V6ONLY   false
 
#define CPPHTTPLIB_RECV_BUFSIZ   size_t(16384u)
 
#define CPPHTTPLIB_SEND_BUFSIZ   size_t(16384u)
 
#define CPPHTTPLIB_COMPRESSION_BUFSIZ   size_t(16384u)
 
#define CPPHTTPLIB_THREAD_POOL_COUNT
 
#define CPPHTTPLIB_RECV_FLAGS   0
 
#define CPPHTTPLIB_SEND_FLAGS   0
 
#define CPPHTTPLIB_LISTEN_BACKLOG   5
 
#define CPPHTTPLIB_MAX_LINE_LENGTH   32768
 
#define INVALID_SOCKET   (-1)
 
#define USE_IF2IP
 

Typedefs

using socket_t = int
 
template<typename T >
using httplib::detail::case_ignore::unordered_set = std::unordered_set< T, detail::case_ignore::hash, detail::case_ignore::equal_to >
 
using httplib::Headers = std::unordered_multimap< std::string, std::string, detail::case_ignore::hash, detail::case_ignore::equal_to >
 
using httplib::Params = std::multimap< std::string, std::string >
 
using httplib::Match = std::smatch
 
using httplib::DownloadProgress = std::function< bool(size_t current, size_t total)>
 
using httplib::UploadProgress = std::function< bool(size_t current, size_t total)>
 
using httplib::ResponseHandler = std::function< bool(const Response &response)>
 
using httplib::FormFields = std::multimap< std::string, FormField >
 
using httplib::FormFiles = std::multimap< std::string, FormData >
 
using httplib::UploadFormDataItems = std::vector< UploadFormData >
 
using httplib::ContentProvider = std::function< bool(size_t offset, size_t length, DataSink &sink)>
 
using httplib::ContentProviderWithoutLength = std::function< bool(size_t offset, DataSink &sink)>
 
using httplib::ContentProviderResourceReleaser = std::function< void(bool success)>
 
using httplib::FormDataProviderItems = std::vector< FormDataProvider >
 
using httplib::ContentReceiverWithProgress = std::function< bool(const char *data, size_t data_length, size_t offset, size_t total_length)>
 
using httplib::ContentReceiver = std::function< bool(const char *data, size_t data_length)>
 
using httplib::FormDataHeader = std::function< bool(const FormData &file)>
 
using httplib::Range = std::pair< ssize_t, ssize_t >
 
using httplib::Ranges = std::vector< Range >
 
using httplib::Logger = std::function< void(const Request &, const Response &)>
 
using httplib::ErrorLogger = std::function< void(const Error &, const Request *)>
 
using httplib::SocketOptions = std::function< void(socket_t sock)>
 

Enumerations

enum  httplib::SSLVerifierResponse { httplib::NoDecisionMade , httplib::CertificateAccepted , httplib::CertificateRejected }
 
enum  httplib::StatusCode {
  httplib::Continue_100 = 100 , httplib::SwitchingProtocol_101 = 101 , httplib::Processing_102 = 102 , httplib::EarlyHints_103 = 103 ,
  httplib::OK_200 = 200 , httplib::Created_201 = 201 , httplib::Accepted_202 = 202 , httplib::NonAuthoritativeInformation_203 = 203 ,
  httplib::NoContent_204 = 204 , httplib::ResetContent_205 = 205 , httplib::PartialContent_206 = 206 , httplib::MultiStatus_207 = 207 ,
  httplib::AlreadyReported_208 = 208 , httplib::IMUsed_226 = 226 , httplib::MultipleChoices_300 = 300 , httplib::MovedPermanently_301 = 301 ,
  httplib::Found_302 = 302 , httplib::SeeOther_303 = 303 , httplib::NotModified_304 = 304 , httplib::UseProxy_305 = 305 ,
  httplib::unused_306 = 306 , httplib::TemporaryRedirect_307 = 307 , httplib::PermanentRedirect_308 = 308 , httplib::BadRequest_400 = 400 ,
  httplib::Unauthorized_401 = 401 , httplib::PaymentRequired_402 = 402 , httplib::Forbidden_403 = 403 , httplib::NotFound_404 = 404 ,
  httplib::MethodNotAllowed_405 = 405 , httplib::NotAcceptable_406 = 406 , httplib::ProxyAuthenticationRequired_407 = 407 , httplib::RequestTimeout_408 = 408 ,
  httplib::Conflict_409 = 409 , httplib::Gone_410 = 410 , httplib::LengthRequired_411 = 411 , httplib::PreconditionFailed_412 = 412 ,
  httplib::PayloadTooLarge_413 = 413 , httplib::UriTooLong_414 = 414 , httplib::UnsupportedMediaType_415 = 415 , httplib::RangeNotSatisfiable_416 = 416 ,
  httplib::ExpectationFailed_417 = 417 , httplib::ImATeapot_418 = 418 , httplib::MisdirectedRequest_421 = 421 , httplib::UnprocessableContent_422 = 422 ,
  httplib::Locked_423 = 423 , httplib::FailedDependency_424 = 424 , httplib::TooEarly_425 = 425 , httplib::UpgradeRequired_426 = 426 ,
  httplib::PreconditionRequired_428 = 428 , httplib::TooManyRequests_429 = 429 , httplib::RequestHeaderFieldsTooLarge_431 = 431 , httplib::UnavailableForLegalReasons_451 = 451 ,
  httplib::InternalServerError_500 = 500 , httplib::NotImplemented_501 = 501 , httplib::BadGateway_502 = 502 , httplib::ServiceUnavailable_503 = 503 ,
  httplib::GatewayTimeout_504 = 504 , httplib::HttpVersionNotSupported_505 = 505 , httplib::VariantAlsoNegotiates_506 = 506 , httplib::InsufficientStorage_507 = 507 ,
  httplib::LoopDetected_508 = 508 , httplib::NotExtended_510 = 510 , httplib::NetworkAuthenticationRequired_511 = 511
}
 
enum class  httplib::Error {
  httplib::Success = 0 , httplib::Unknown , httplib::Connection , httplib::BindIPAddress ,
  httplib::Read , httplib::Write , httplib::ExceedRedirectCount , httplib::Canceled ,
  httplib::SSLConnection , httplib::SSLLoadingCerts , httplib::SSLServerVerification , httplib::SSLServerHostnameVerification ,
  httplib::UnsupportedMultipartBoundaryChars , httplib::Compression , httplib::ConnectionTimeout , httplib::ProxyConnection ,
  httplib::ConnectionClosed , httplib::Timeout , httplib::ResourceExhaustion , httplib::TooManyFormDataFiles ,
  httplib::ExceedMaxPayloadSize , httplib::ExceedUriMaxLength , httplib::ExceedMaxSocketDescriptorCount , httplib::InvalidRequestLine ,
  httplib::InvalidHTTPMethod , httplib::InvalidHTTPVersion , httplib::InvalidHeaders , httplib::MultipartParsing ,
  httplib::OpenFile , httplib::Listen , httplib::GetSockName , httplib::UnsupportedAddressFamily ,
  httplib::HTTPParsing , httplib::InvalidRangeHeader , httplib::SSLPeerCouldBeClosed_
}
 

Functions

template<class T , class... Args>
std::enable_if<!std::is_array< T >::value, std::unique_ptr< T > >::type httplib::detail::make_unique (Args &&...args)
 
template<class T >
std::enable_if< std::is_array< T >::value, std::unique_ptr< T > >::type httplib::detail::make_unique (std::size_t n)
 
unsigned char httplib::detail::case_ignore::to_lower (int c)
 
bool httplib::detail::case_ignore::equal (const std::string &a, const std::string &b)
 
std::string httplib::to_string (Error error)
 
std::ostream & httplib::operator<< (std::ostream &os, const Error &obj)
 
void httplib::default_socket_options (socket_t sock)
 
const char * httplib::status_message (int status)
 
std::string httplib::get_bearer_token_auth (const Request &req)
 
int httplib::detail::close_socket (socket_t sock)
 
ssize_t httplib::detail::write_headers (Stream &strm, const Headers &headers)
 
ssize_t httplib::detail::read_body_content (Stream *stream, BodyReader &br, char *buf, size_t len)
 
std::string httplib::hosted_at (const std::string &hostname)
 
void httplib::hosted_at (const std::string &hostname, std::vector< std::string > &addrs)
 
std::string httplib::encode_uri_component (const std::string &value)
 
std::string httplib::encode_uri (const std::string &value)
 
std::string httplib::decode_uri_component (const std::string &value)
 
std::string httplib::decode_uri (const std::string &value)
 
std::string httplib::encode_path_component (const std::string &component)
 
std::string httplib::decode_path_component (const std::string &component)
 
std::string httplib::encode_query_component (const std::string &component, bool space_as_plus=true)
 
std::string httplib::decode_query_component (const std::string &component, bool plus_as_space=true)
 
std::string httplib::append_query_params (const std::string &path, const Params &params)
 
std::pair< std::string, std::string > httplib::make_range_header (const Ranges &ranges)
 
std::pair< std::string, std::string > httplib::make_basic_authentication_header (const std::string &username, const std::string &password, bool is_proxy=false)
 
std::pair< std::string, std::string > httplib::make_bearer_token_authentication_header (const std::string &token, bool is_proxy=false)
 
std::string httplib::get_client_ip (const std::string &x_forwarded_for, const std::vector< std::string > &trusted_proxies)
 

Macro Definition Documentation

◆ CPPHTTPLIB_CLIENT_MAX_TIMEOUT_MSECOND

#define CPPHTTPLIB_CLIENT_MAX_TIMEOUT_MSECOND   0

Definition at line 98 of file httplib.h.

◆ CPPHTTPLIB_CLIENT_READ_TIMEOUT_SECOND

#define CPPHTTPLIB_CLIENT_READ_TIMEOUT_SECOND   300

Definition at line 82 of file httplib.h.

◆ CPPHTTPLIB_CLIENT_READ_TIMEOUT_USECOND

#define CPPHTTPLIB_CLIENT_READ_TIMEOUT_USECOND   0

Definition at line 86 of file httplib.h.

◆ CPPHTTPLIB_CLIENT_WRITE_TIMEOUT_SECOND

#define CPPHTTPLIB_CLIENT_WRITE_TIMEOUT_SECOND   5

Definition at line 90 of file httplib.h.

◆ CPPHTTPLIB_CLIENT_WRITE_TIMEOUT_USECOND

#define CPPHTTPLIB_CLIENT_WRITE_TIMEOUT_USECOND   0

Definition at line 94 of file httplib.h.

◆ CPPHTTPLIB_COMPRESSION_BUFSIZ

#define CPPHTTPLIB_COMPRESSION_BUFSIZ   size_t(16384u)

Definition at line 162 of file httplib.h.

◆ CPPHTTPLIB_CONNECTION_TIMEOUT_SECOND

#define CPPHTTPLIB_CONNECTION_TIMEOUT_SECOND   300

Definition at line 58 of file httplib.h.

◆ CPPHTTPLIB_CONNECTION_TIMEOUT_USECOND

#define CPPHTTPLIB_CONNECTION_TIMEOUT_USECOND   0

Definition at line 62 of file httplib.h.

◆ CPPHTTPLIB_FORM_URL_ENCODED_PAYLOAD_MAX_LENGTH

#define CPPHTTPLIB_FORM_URL_ENCODED_PAYLOAD_MAX_LENGTH   8192

Definition at line 138 of file httplib.h.

◆ CPPHTTPLIB_HEADER_MAX_COUNT

#define CPPHTTPLIB_HEADER_MAX_COUNT   100

Definition at line 122 of file httplib.h.

◆ CPPHTTPLIB_HEADER_MAX_LENGTH

#define CPPHTTPLIB_HEADER_MAX_LENGTH   8192

Definition at line 118 of file httplib.h.

◆ CPPHTTPLIB_IDLE_INTERVAL_SECOND

#define CPPHTTPLIB_IDLE_INTERVAL_SECOND   0

Definition at line 102 of file httplib.h.

◆ CPPHTTPLIB_IDLE_INTERVAL_USECOND

#define CPPHTTPLIB_IDLE_INTERVAL_USECOND   0

Definition at line 109 of file httplib.h.

◆ CPPHTTPLIB_IPV6_V6ONLY

#define CPPHTTPLIB_IPV6_V6ONLY   false

Definition at line 150 of file httplib.h.

◆ CPPHTTPLIB_KEEPALIVE_MAX_COUNT

#define CPPHTTPLIB_KEEPALIVE_MAX_COUNT   100

Definition at line 54 of file httplib.h.

◆ CPPHTTPLIB_KEEPALIVE_TIMEOUT_CHECK_INTERVAL_USECOND

#define CPPHTTPLIB_KEEPALIVE_TIMEOUT_CHECK_INTERVAL_USECOND   10000

Definition at line 50 of file httplib.h.

◆ CPPHTTPLIB_KEEPALIVE_TIMEOUT_SECOND

#define CPPHTTPLIB_KEEPALIVE_TIMEOUT_SECOND   5

Definition at line 46 of file httplib.h.

◆ CPPHTTPLIB_LISTEN_BACKLOG

#define CPPHTTPLIB_LISTEN_BACKLOG   5

Definition at line 181 of file httplib.h.

◆ CPPHTTPLIB_MAX_LINE_LENGTH

#define CPPHTTPLIB_MAX_LINE_LENGTH   32768

Definition at line 185 of file httplib.h.

◆ CPPHTTPLIB_MULTIPART_FORM_DATA_FILE_MAX_COUNT

#define CPPHTTPLIB_MULTIPART_FORM_DATA_FILE_MAX_COUNT   1024

Definition at line 130 of file httplib.h.

◆ CPPHTTPLIB_PAYLOAD_MAX_LENGTH

#define CPPHTTPLIB_PAYLOAD_MAX_LENGTH   ((std::numeric_limits<size_t>::max)())

Definition at line 134 of file httplib.h.

◆ CPPHTTPLIB_RANGE_MAX_COUNT

#define CPPHTTPLIB_RANGE_MAX_COUNT   1024

Definition at line 142 of file httplib.h.

◆ CPPHTTPLIB_RECV_BUFSIZ

#define CPPHTTPLIB_RECV_BUFSIZ   size_t(16384u)

Definition at line 154 of file httplib.h.

◆ CPPHTTPLIB_RECV_FLAGS

#define CPPHTTPLIB_RECV_FLAGS   0

Definition at line 173 of file httplib.h.

◆ CPPHTTPLIB_REDIRECT_MAX_COUNT

#define CPPHTTPLIB_REDIRECT_MAX_COUNT   20

Definition at line 126 of file httplib.h.

◆ CPPHTTPLIB_REQUEST_URI_MAX_LENGTH

#define CPPHTTPLIB_REQUEST_URI_MAX_LENGTH   8192

Definition at line 114 of file httplib.h.

◆ CPPHTTPLIB_SEND_BUFSIZ

#define CPPHTTPLIB_SEND_BUFSIZ   size_t(16384u)

Definition at line 158 of file httplib.h.

◆ CPPHTTPLIB_SEND_FLAGS

#define CPPHTTPLIB_SEND_FLAGS   0

Definition at line 177 of file httplib.h.

◆ CPPHTTPLIB_SERVER_READ_TIMEOUT_SECOND

#define CPPHTTPLIB_SERVER_READ_TIMEOUT_SECOND   5

Definition at line 66 of file httplib.h.

◆ CPPHTTPLIB_SERVER_READ_TIMEOUT_USECOND

#define CPPHTTPLIB_SERVER_READ_TIMEOUT_USECOND   0

Definition at line 70 of file httplib.h.

◆ CPPHTTPLIB_SERVER_WRITE_TIMEOUT_SECOND

#define CPPHTTPLIB_SERVER_WRITE_TIMEOUT_SECOND   5

Definition at line 74 of file httplib.h.

◆ CPPHTTPLIB_SERVER_WRITE_TIMEOUT_USECOND

#define CPPHTTPLIB_SERVER_WRITE_TIMEOUT_USECOND   0

Definition at line 78 of file httplib.h.

◆ CPPHTTPLIB_TCP_NODELAY

#define CPPHTTPLIB_TCP_NODELAY   false

Definition at line 146 of file httplib.h.

◆ CPPHTTPLIB_THREAD_POOL_COUNT

#define CPPHTTPLIB_THREAD_POOL_COUNT
Value:
((std::max)(8u, std::thread::hardware_concurrency() > 0 \
? std::thread::hardware_concurrency() - 1 \
: 0))

Definition at line 166 of file httplib.h.

◆ CPPHTTPLIB_VERSION

#define CPPHTTPLIB_VERSION   "0.29.0"

Definition at line 11 of file httplib.h.

◆ CPPHTTPLIB_VERSION_NUM

#define CPPHTTPLIB_VERSION_NUM   "0x001D00"

Definition at line 12 of file httplib.h.

◆ INVALID_SOCKET

#define INVALID_SOCKET   (-1)

Definition at line 273 of file httplib.h.

◆ USE_IF2IP

#define USE_IF2IP

Definition at line 5958 of file httplib.h.

Typedef Documentation

◆ socket_t

using socket_t = int

Definition at line 271 of file httplib.h.