camcom 1.0.0-pre2
 
Loading...
Searching...
No Matches
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 <chrono>
#include <climits>
#include <condition_variable>
#include <cstdlib>
#include <cstring>
#include <errno.h>
#include <exception>
#include <fcntl.h>
#include <fstream>
#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 <system_error>
#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::detail::from_chars_result< T >
 
class  httplib::bad_any_cast
 
struct  httplib::detail::any_storage
 
struct  httplib::detail::any_value< T >
 
class  httplib::any
 
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
 
struct  httplib::detail::FileStat
 
class  httplib::detail::BufferStream
 
class  httplib::detail::compressor
 
class  httplib::detail::decompressor
 
class  httplib::detail::nocompressor
 
class  httplib::detail::stream_line_reader
 
struct  httplib::detail::ChunkedDecoder
 
class  httplib::detail::mmap
 
class  httplib::stream::Result
 
struct  httplib::sse::SSEMessage
 
class  httplib::sse::SSEClient
 
class  httplib::ws::WebSocket
 
class  httplib::ws::WebSocketClient
 
class  httplib::detail::SocketStream
 
class  httplib::detail::FormDataParser
 
struct  httplib::detail::MultipartSegment
 
class  httplib::detail::ContentProviderAdapter
 

Namespaces

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

Macros

#define CPPHTTPLIB_VERSION   "0.39.0"
 
#define CPPHTTPLIB_VERSION_NUM   "0x002700"
 
#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_EXPECT_100_THRESHOLD   1024
 
#define CPPHTTPLIB_EXPECT_100_TIMEOUT_MSECOND   1000
 
#define CPPHTTPLIB_WAIT_EARLY_SERVER_RESPONSE_THRESHOLD   (1024 * 1024)
 
#define CPPHTTPLIB_WAIT_EARLY_SERVER_RESPONSE_TIMEOUT_MSECOND   50
 
#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   (100 * 1024 * 1024)
 
#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_THREAD_POOL_MAX_COUNT   (CPPHTTPLIB_THREAD_POOL_COUNT * 4)
 
#define CPPHTTPLIB_THREAD_POOL_IDLE_TIMEOUT   3
 
#define CPPHTTPLIB_RECV_FLAGS   0
 
#define CPPHTTPLIB_SEND_FLAGS   0
 
#define CPPHTTPLIB_LISTEN_BACKLOG   5
 
#define CPPHTTPLIB_MAX_LINE_LENGTH   32768
 
#define CPPHTTPLIB_WEBSOCKET_MAX_PAYLOAD_LENGTH   16777216
 
#define CPPHTTPLIB_WEBSOCKET_READ_TIMEOUT_SECOND   300
 
#define CPPHTTPLIB_WEBSOCKET_CLOSE_TIMEOUT_SECOND   5
 
#define CPPHTTPLIB_WEBSOCKET_PING_INTERVAL_SECOND   30
 
#define INVALID_SOCKET   (-1)
 
#define USE_IF2IP
 

Typedefs

using socket_t = int
 
template<typename T>
using httplib::detail::case_ignore::unordered_set
 
using httplib::Headers
 
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::detail::any_type_id = const void *
 
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
 
using httplib::ContentProviderWithoutLength
 
using httplib::ContentProviderResourceReleaser = std::function<void(bool success)>
 
using httplib::FormDataProviderItems = std::vector<FormDataProvider>
 
using httplib::ContentReceiverWithProgress
 
using httplib::ContentReceiver
 
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_
}
 
enum class  httplib::detail::EncodingType { httplib::detail::None = 0 , httplib::detail::Gzip , httplib::detail::Brotli , httplib::detail::Zstd }
 
enum class  httplib::ws::Opcode : uint8_t {
  httplib::ws::Continuation = 0x0 , httplib::ws::Text = 0x1 , httplib::ws::Binary = 0x2 , httplib::ws::Close = 0x8 ,
  httplib::ws::Ping = 0x9 , httplib::ws::Pong = 0xA
}
 
enum class  httplib::ws::CloseStatus : uint16_t {
  httplib::ws::Normal = 1000 , httplib::ws::GoingAway = 1001 , httplib::ws::ProtocolError = 1002 , httplib::ws::UnsupportedData = 1003 ,
  httplib::ws::NoStatus = 1005 , httplib::ws::Abnormal = 1006 , httplib::ws::InvalidPayload = 1007 , httplib::ws::PolicyViolation = 1008 ,
  httplib::ws::MessageTooBig = 1009 , httplib::ws::MandatoryExtension = 1010 , httplib::ws::InternalError = 1011
}
 
enum  httplib::ws::ReadResult : int { httplib::ws::Fail = 0 , httplib::ws::Text = 1 , httplib::ws::Binary = 2 }
 
enum class  httplib::detail::ReadContentResult { httplib::detail::Success , httplib::detail::PayloadTooLarge , httplib::detail::Error }
 

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)
 
std::string httplib::detail::case_ignore::to_lower (const std::string &s)
 
bool httplib::detail::case_ignore::equal (const std::string &a, const std::string &b)
 
template<typename T>
from_chars_result< T > httplib::detail::from_chars (const char *first, const char *last, T &value, int base=10)
 
from_chars_result< double > httplib::detail::from_chars (const char *first, const char *last, double &value)
 
bool httplib::detail::parse_port (const char *s, size_t len, int &port)
 
bool httplib::detail::parse_port (const std::string &s, int &port)
 
template<typename T>
any_type_id httplib::detail::any_typeid () noexcept
 
template<typename T>
T * httplib::any_cast (any *a)
 
template<typename T>
const T * httplib::any_cast (const any *a)
 
template<typename T>
httplib::any_cast (const any &a)
 
template<typename T>
httplib::any_cast (any &a)
 
template<typename T>
httplib::any_cast (any &&a)
 
FormDataProvider httplib::make_file_provider (const std::string &name, const std::string &filepath, const std::string &filename=std::string(), const std::string &content_type=std::string())
 
std::pair< size_t, ContentProviderhttplib::make_file_body (const std::string &filepath)
 
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)
 
bool httplib::detail::set_socket_opt_time (socket_t sock, int level, int optname, time_t sec, time_t usec)
 
ssize_t httplib::detail::read_body_content (Stream *stream, BodyReader &br, char *buf, size_t len)
 
template<typename T, typename U>
void httplib::detail::duration_to_sec_and_usec (const T &duration, U callback)
 
template<size_t N>
constexpr size_t httplib::detail::str_len (const char(&)[N])
 
bool httplib::detail::is_numeric (const std::string &str)
 
size_t httplib::detail::get_header_value_u64 (const Headers &headers, const std::string &key, size_t def, size_t id, bool &is_invalid_value)
 
size_t httplib::detail::get_header_value_u64 (const Headers &headers, const std::string &key, size_t def, size_t id)
 
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::sanitize_filename (const std::string &filename)
 
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::string httplib::detail::make_host_and_port_string (const std::string &host, int port, bool is_ssl)
 
std::string httplib::detail::trim_copy (const std::string &s)
 
void httplib::detail::divide (const char *data, std::size_t size, char d, std::function< void(const char *, std::size_t, const char *, std::size_t)> fn)
 
void httplib::detail::divide (const std::string &str, char d, std::function< void(const char *, std::size_t, const char *, std::size_t)> fn)
 
void httplib::detail::split (const char *b, const char *e, char d, std::function< void(const char *, const char *)> fn)
 
void httplib::detail::split (const char *b, const char *e, char d, size_t m, std::function< void(const char *, const char *)> fn)
 
bool httplib::detail::process_client_socket (socket_t sock, time_t read_timeout_sec, time_t read_timeout_usec, time_t write_timeout_sec, time_t write_timeout_usec, time_t max_timeout_msec, std::chrono::time_point< std::chrono::steady_clock > start_time, std::function< bool(Stream &)> callback)
 
socket_t httplib::detail::create_client_socket (const std::string &host, const std::string &ip, int port, int address_family, bool tcp_nodelay, bool ipv6_v6only, SocketOptions socket_options, time_t connection_timeout_sec, time_t connection_timeout_usec, time_t read_timeout_sec, time_t read_timeout_usec, time_t write_timeout_sec, time_t write_timeout_usec, const std::string &intf, Error &error)
 
const char * httplib::detail::get_header_value (const Headers &headers, const std::string &key, const char *def, size_t id)
 
std::string httplib::detail::params_to_query_str (const Params &params)
 
void httplib::detail::parse_query_text (const char *data, std::size_t size, Params &params)
 
void httplib::detail::parse_query_text (const std::string &s, Params &params)
 
bool httplib::detail::parse_multipart_boundary (const std::string &content_type, std::string &boundary)
 
bool httplib::detail::parse_range_header (const std::string &s, Ranges &ranges)
 
bool httplib::detail::parse_accept_header (const std::string &s, std::vector< std::string > &content_types)
 
ssize_t httplib::detail::send_socket (socket_t sock, const void *ptr, size_t size, int flags)
 
ssize_t httplib::detail::read_socket (socket_t sock, void *ptr, size_t size, int flags)
 
EncodingType httplib::detail::encoding_type (const Request &req, const Response &res)
 
bool httplib::detail::parse_trailers (stream_line_reader &line_reader, Headers &dest, const Headers &src_headers)
 
bool httplib::detail::fields::is_token_char (char c)
 
bool httplib::detail::fields::is_token (const std::string &s)
 
bool httplib::detail::fields::is_field_name (const std::string &s)
 
bool httplib::detail::fields::is_vchar (char c)
 
bool httplib::detail::fields::is_obs_text (char c)
 
bool httplib::detail::fields::is_field_vchar (char c)
 
bool httplib::detail::fields::is_field_content (const std::string &s)
 
bool httplib::detail::fields::is_field_value (const std::string &s)
 
template<typename ClientType>
Result httplib::stream::Get (ClientType &cli, const std::string &path, size_t chunk_size=8192)
 
template<typename ClientType>
Result httplib::stream::Get (ClientType &cli, const std::string &path, const Headers &headers, size_t chunk_size=8192)
 
template<typename ClientType>
Result httplib::stream::Get (ClientType &cli, const std::string &path, const Params &params, size_t chunk_size=8192)
 
template<typename ClientType>
Result httplib::stream::Get (ClientType &cli, const std::string &path, const Params &params, const Headers &headers, size_t chunk_size=8192)
 
template<typename ClientType>
Result httplib::stream::Post (ClientType &cli, const std::string &path, const std::string &body, const std::string &content_type, size_t chunk_size=8192)
 
template<typename ClientType>
Result httplib::stream::Post (ClientType &cli, const std::string &path, const Headers &headers, const std::string &body, const std::string &content_type, size_t chunk_size=8192)
 
template<typename ClientType>
Result httplib::stream::Post (ClientType &cli, const std::string &path, const Params &params, const std::string &body, const std::string &content_type, size_t chunk_size=8192)
 
template<typename ClientType>
Result httplib::stream::Post (ClientType &cli, const std::string &path, const Params &params, const Headers &headers, const std::string &body, const std::string &content_type, size_t chunk_size=8192)
 
template<typename ClientType>
Result httplib::stream::Put (ClientType &cli, const std::string &path, const std::string &body, const std::string &content_type, size_t chunk_size=8192)
 
template<typename ClientType>
Result httplib::stream::Put (ClientType &cli, const std::string &path, const Headers &headers, const std::string &body, const std::string &content_type, size_t chunk_size=8192)
 
template<typename ClientType>
Result httplib::stream::Put (ClientType &cli, const std::string &path, const Params &params, const std::string &body, const std::string &content_type, size_t chunk_size=8192)
 
template<typename ClientType>
Result httplib::stream::Put (ClientType &cli, const std::string &path, const Params &params, const Headers &headers, const std::string &body, const std::string &content_type, size_t chunk_size=8192)
 
template<typename ClientType>
Result httplib::stream::Patch (ClientType &cli, const std::string &path, const std::string &body, const std::string &content_type, size_t chunk_size=8192)
 
template<typename ClientType>
Result httplib::stream::Patch (ClientType &cli, const std::string &path, const Headers &headers, const std::string &body, const std::string &content_type, size_t chunk_size=8192)
 
template<typename ClientType>
Result httplib::stream::Patch (ClientType &cli, const std::string &path, const Params &params, const std::string &body, const std::string &content_type, size_t chunk_size=8192)
 
template<typename ClientType>
Result httplib::stream::Patch (ClientType &cli, const std::string &path, const Params &params, const Headers &headers, const std::string &body, const std::string &content_type, size_t chunk_size=8192)
 
template<typename ClientType>
Result httplib::stream::Delete (ClientType &cli, const std::string &path, size_t chunk_size=8192)
 
template<typename ClientType>
Result httplib::stream::Delete (ClientType &cli, const std::string &path, const Headers &headers, size_t chunk_size=8192)
 
template<typename ClientType>
Result httplib::stream::Delete (ClientType &cli, const std::string &path, const std::string &body, const std::string &content_type, size_t chunk_size=8192)
 
template<typename ClientType>
Result httplib::stream::Delete (ClientType &cli, const std::string &path, const Headers &headers, const std::string &body, const std::string &content_type, size_t chunk_size=8192)
 
template<typename ClientType>
Result httplib::stream::Delete (ClientType &cli, const std::string &path, const Params &params, size_t chunk_size=8192)
 
template<typename ClientType>
Result httplib::stream::Delete (ClientType &cli, const std::string &path, const Params &params, const Headers &headers, size_t chunk_size=8192)
 
template<typename ClientType>
Result httplib::stream::Delete (ClientType &cli, const std::string &path, const Params &params, const std::string &body, const std::string &content_type, size_t chunk_size=8192)
 
template<typename ClientType>
Result httplib::stream::Delete (ClientType &cli, const std::string &path, const Params &params, const Headers &headers, const std::string &body, const std::string &content_type, size_t chunk_size=8192)
 
template<typename ClientType>
Result httplib::stream::Head (ClientType &cli, const std::string &path, size_t chunk_size=8192)
 
template<typename ClientType>
Result httplib::stream::Head (ClientType &cli, const std::string &path, const Headers &headers, size_t chunk_size=8192)
 
template<typename ClientType>
Result httplib::stream::Head (ClientType &cli, const std::string &path, const Params &params, size_t chunk_size=8192)
 
template<typename ClientType>
Result httplib::stream::Head (ClientType &cli, const std::string &path, const Params &params, const Headers &headers, size_t chunk_size=8192)
 
template<typename ClientType>
Result httplib::stream::Options (ClientType &cli, const std::string &path, size_t chunk_size=8192)
 
template<typename ClientType>
Result httplib::stream::Options (ClientType &cli, const std::string &path, const Headers &headers, size_t chunk_size=8192)
 
template<typename ClientType>
Result httplib::stream::Options (ClientType &cli, const std::string &path, const Params &params, size_t chunk_size=8192)
 
template<typename ClientType>
Result httplib::stream::Options (ClientType &cli, const std::string &path, const Params &params, const Headers &headers, size_t chunk_size=8192)
 
bool httplib::ws::impl::is_valid_utf8 (const std::string &s)
 
bool httplib::ws::impl::read_websocket_frame (Stream &strm, Opcode &opcode, std::string &payload, bool &fin, bool expect_masked, size_t max_len)
 
bool httplib::detail::set_socket_opt_impl (socket_t sock, int level, int optname, const void *optval, socklen_t optlen)
 
bool httplib::detail::set_socket_opt (socket_t sock, int level, int optname, int optval)
 
bool httplib::detail::is_hex (char c, int &v)
 
bool httplib::detail::from_hex_to_i (const std::string &s, size_t i, size_t cnt, int &val)
 
std::string httplib::detail::from_i_to_hex (size_t n)
 
std::string httplib::detail::compute_etag (const FileStat &fs)
 
std::string httplib::detail::file_mtime_to_http_date (time_t mtime)
 
time_t httplib::detail::parse_http_date (const std::string &date_str)
 
bool httplib::detail::is_weak_etag (const std::string &s)
 
bool httplib::detail::is_strong_etag (const std::string &s)
 
size_t httplib::detail::to_utf8 (int code, char *buff)
 
std::string httplib::detail::base64_encode (const std::string &in)
 
std::string httplib::detail::sha1 (const std::string &input)
 
std::string httplib::detail::websocket_accept_key (const std::string &client_key)
 
bool httplib::detail::is_websocket_upgrade (const Request &req)
 
bool httplib::detail::write_websocket_frame (Stream &strm, ws::Opcode opcode, const char *data, size_t len, bool fin, bool mask)
 
bool httplib::detail::is_valid_path (const std::string &path)
 
bool httplib::detail::canonicalize_path (const char *path, std::string &resolved)
 
bool httplib::detail::is_path_within_base (const std::string &resolved_path, const std::string &resolved_base)
 
std::string httplib::detail::encode_path (const std::string &s)
 
std::string httplib::detail::file_extension (const std::string &path)
 
bool httplib::detail::is_space_or_tab (char c)
 
template<typename T>
bool httplib::detail::parse_header (const char *beg, const char *end, T fn)
 
std::pair< size_t, size_t > httplib::detail::trim (const char *b, const char *e, size_t left, size_t right)
 
std::string httplib::detail::trim_double_quotes_copy (const std::string &s)
 
bool httplib::detail::split_find (const char *b, const char *e, char d, size_t m, std::function< bool(const char *, const char *)> fn)
 
bool httplib::detail::split_find (const char *b, const char *e, char d, std::function< bool(const char *, const char *)> fn)
 
template<typename T>
ssize_t httplib::detail::handle_EINTR (T fn)
 
int httplib::detail::poll_wrapper (struct pollfd *fds, nfds_t nfds, int timeout)
 
ssize_t httplib::detail::select_impl (socket_t sock, short events, time_t sec, time_t usec)
 
ssize_t httplib::detail::select_read (socket_t sock, time_t sec, time_t usec)
 
ssize_t httplib::detail::select_write (socket_t sock, time_t sec, time_t usec)
 
Error httplib::detail::wait_until_socket_is_ready (socket_t sock, time_t sec, time_t usec)
 
bool httplib::detail::is_socket_alive (socket_t sock)
 
bool httplib::detail::keep_alive (const std::atomic< socket_t > &svr_sock, socket_t sock, time_t keep_alive_timeout_sec)
 
template<typename T>
bool httplib::detail::process_server_socket_core (const std::atomic< socket_t > &svr_sock, socket_t sock, size_t keep_alive_max_count, time_t keep_alive_timeout_sec, T callback)
 
template<typename T>
bool httplib::detail::process_server_socket (const std::atomic< socket_t > &svr_sock, socket_t sock, size_t keep_alive_max_count, time_t keep_alive_timeout_sec, time_t read_timeout_sec, time_t read_timeout_usec, time_t write_timeout_sec, time_t write_timeout_usec, T callback)
 
int httplib::detail::shutdown_socket (socket_t sock)
 
std::string httplib::detail::escape_abstract_namespace_unix_domain (const std::string &s)
 
std::string httplib::detail::unescape_abstract_namespace_unix_domain (const std::string &s)
 
int httplib::detail::getaddrinfo_with_timeout (const char *node, const char *service, const struct addrinfo *hints, struct addrinfo **res, time_t timeout_sec)
 
template<typename BindOrConnect>
socket_t httplib::detail::create_socket (const std::string &host, const std::string &ip, int port, int address_family, int socket_flags, bool tcp_nodelay, bool ipv6_v6only, SocketOptions socket_options, BindOrConnect bind_or_connect, time_t timeout_sec=0)
 
void httplib::detail::set_nonblocking (socket_t sock, bool nonblocking)
 
bool httplib::detail::is_connection_error ()
 
bool httplib::detail::bind_ip_address (socket_t sock, const std::string &host)
 
std::string httplib::detail::if2ip (int address_family, const std::string &ifn)
 
bool httplib::detail::get_ip_and_port (const struct sockaddr_storage &addr, socklen_t addr_len, std::string &ip, int &port)
 
void httplib::detail::get_local_ip_and_port (socket_t sock, std::string &ip, int &port)
 
void httplib::detail::get_remote_ip_and_port (socket_t sock, std::string &ip, int &port)
 
constexpr unsigned int httplib::detail::str2tag_core (const char *s, size_t l, unsigned int h)
 
unsigned int httplib::detail::str2tag (const std::string &s)
 
constexpr unsigned int httplib::detail::udl::operator""_t (const char *s, size_t l)
 
std::string httplib::detail::find_content_type (const std::string &path, const std::map< std::string, std::string > &user_data, const std::string &default_content_type)
 
std::string httplib::detail::extract_media_type (const std::string &content_type, std::map< std::string, std::string > *params=nullptr)
 
bool httplib::detail::can_compress_content_type (const std::string &content_type)
 
bool httplib::detail::parse_quality (const char *b, const char *e, std::string &token, double &quality)
 
std::unique_ptr< decompressorhttplib::detail::create_decompressor (const std::string &encoding)
 
std::pair< std::unique_ptr< compressor >, const char * > httplib::detail::create_compressor ()
 
bool httplib::detail::is_prohibited_header_name (const std::string &name)
 
bool httplib::detail::has_header (const Headers &headers, const std::string &key)
 
bool httplib::detail::read_headers (Stream &strm, Headers &headers)
 
bool httplib::detail::read_websocket_upgrade_response (Stream &strm, const std::string &expected_accept, std::string &selected_subprotocol)
 
ReadContentResult httplib::detail::read_content_with_length (Stream &strm, size_t len, DownloadProgress progress, ContentReceiverWithProgress out, size_t payload_max_length=(std::numeric_limits< size_t >::max)())
 
ReadContentResult httplib::detail::read_content_without_length (Stream &strm, size_t payload_max_length, ContentReceiverWithProgress out)
 
template<typename T>
ReadContentResult httplib::detail::read_content_chunked (Stream &strm, T &x, size_t payload_max_length, ContentReceiverWithProgress out)
 
bool httplib::detail::is_chunked_transfer_encoding (const Headers &headers)
 
template<typename T, typename U>
bool httplib::detail::prepare_content_receiver (T &x, int &status, ContentReceiverWithProgress receiver, bool decompress, size_t payload_max_length, bool &exceed_payload_max_length, U callback)
 
template<typename T>
bool httplib::detail::read_content (Stream &strm, T &x, size_t payload_max_length, int &status, DownloadProgress progress, ContentReceiverWithProgress receiver, bool decompress)
 
ssize_t httplib::detail::write_request_line (Stream &strm, const std::string &method, const std::string &path)
 
ssize_t httplib::detail::write_response_line (Stream &strm, int status)
 
bool httplib::detail::write_data (Stream &strm, const char *d, size_t l)
 
template<typename T>
bool httplib::detail::write_content_with_progress (Stream &strm, const ContentProvider &content_provider, size_t offset, size_t length, T is_shutting_down, const UploadProgress &upload_progress, Error &error)
 
template<typename T>
bool httplib::detail::write_content (Stream &strm, const ContentProvider &content_provider, size_t offset, size_t length, T is_shutting_down, Error &error)
 
template<typename T>
bool httplib::detail::write_content (Stream &strm, const ContentProvider &content_provider, size_t offset, size_t length, const T &is_shutting_down)
 
template<typename T>
bool httplib::detail::write_content_without_length (Stream &strm, const ContentProvider &content_provider, const T &is_shutting_down)
 
template<typename T, typename U>
bool httplib::detail::write_content_chunked (Stream &strm, const ContentProvider &content_provider, const T &is_shutting_down, U &compressor, Error &error)
 
template<typename T, typename U>
bool httplib::detail::write_content_chunked (Stream &strm, const ContentProvider &content_provider, const T &is_shutting_down, U &compressor)
 
template<typename T>
bool httplib::detail::redirect (T &cli, Request &req, Response &res, const std::string &path, const std::string &location, Error &error)
 
std::string httplib::detail::normalize_query_string (const std::string &query)
 
void httplib::detail::parse_disposition_params (const std::string &s, Params &params)
 
std::string httplib::detail::random_string (size_t length)
 
std::string httplib::detail::make_multipart_data_boundary ()
 
bool httplib::detail::is_multipart_boundary_chars_valid (const std::string &boundary)
 
template<typename T>
std::string httplib::detail::serialize_multipart_formdata_item_begin (const T &item, const std::string &boundary)
 
std::string httplib::detail::serialize_multipart_formdata_item_end ()
 
std::string httplib::detail::serialize_multipart_formdata_finish (const std::string &boundary)
 
std::string httplib::detail::serialize_multipart_formdata_get_content_type (const std::string &boundary)
 
std::string httplib::detail::serialize_multipart_formdata (const UploadFormDataItems &items, const std::string &boundary, bool finish=true)
 
size_t httplib::detail::get_multipart_content_length (const UploadFormDataItems &items, const std::string &boundary)
 
ContentProvider httplib::detail::make_multipart_content_provider (const UploadFormDataItems &items, const std::string &boundary)
 
void httplib::detail::coalesce_ranges (Ranges &ranges, size_t content_length)
 
bool httplib::detail::range_error (Request &req, Response &res)
 
std::pair< size_t, size_t > httplib::detail::get_range_offset_and_length (Range r, size_t content_length)
 
std::string httplib::detail::make_content_range_header_field (const std::pair< size_t, size_t > &offset_and_length, size_t content_length)
 
template<typename SToken, typename CToken, typename Content>
bool httplib::detail::process_multipart_ranges_data (const Request &req, const std::string &boundary, const std::string &content_type, size_t content_length, SToken stoken, CToken ctoken, Content content)
 
void httplib::detail::make_multipart_ranges_data (const Request &req, Response &res, const std::string &boundary, const std::string &content_type, size_t content_length, std::string &data)
 
size_t httplib::detail::get_multipart_ranges_data_length (const Request &req, const std::string &boundary, const std::string &content_type, size_t content_length)
 
template<typename T>
bool httplib::detail::write_multipart_ranges_data (Stream &strm, const Request &req, Response &res, const std::string &boundary, const std::string &content_type, size_t content_length, const T &is_shutting_down)
 
bool httplib::detail::expect_content (const Request &req)
 
bool httplib::detail::parse_www_authenticate (const Response &res, std::map< std::string, std::string > &auth, bool is_proxy)
 
bool httplib::detail::perform_websocket_handshake (Stream &strm, const std::string &host, int port, const std::string &path, const Headers &headers, std::string &selected_subprotocol)
 
std::pair< std::string, std::string > httplib::make_bearer_token_authentication_header (const std::string &token, bool is_proxy=false)
 
void httplib::detail::calc_actual_timeout (time_t max_timeout_msec, time_t duration_msec, time_t timeout_sec, time_t timeout_usec, time_t &actual_timeout_sec, time_t &actual_timeout_usec)
 
std::string httplib::detail::prepare_host_string (const std::string &host)
 
std::string httplib::detail::make_host_and_port_string_always_port (const std::string &host, int port)
 
template<typename T>
bool httplib::detail::check_and_write_headers (Stream &strm, Headers &headers, T header_writer, Error &error)
 
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

◆ CPPHTTPLIB_CLIENT_READ_TIMEOUT_SECOND

#define CPPHTTPLIB_CLIENT_READ_TIMEOUT_SECOND   300

◆ CPPHTTPLIB_CLIENT_READ_TIMEOUT_USECOND

#define CPPHTTPLIB_CLIENT_READ_TIMEOUT_USECOND   0

◆ CPPHTTPLIB_CLIENT_WRITE_TIMEOUT_SECOND

#define CPPHTTPLIB_CLIENT_WRITE_TIMEOUT_SECOND   5

◆ CPPHTTPLIB_CLIENT_WRITE_TIMEOUT_USECOND

#define CPPHTTPLIB_CLIENT_WRITE_TIMEOUT_USECOND   0

◆ CPPHTTPLIB_COMPRESSION_BUFSIZ

#define CPPHTTPLIB_COMPRESSION_BUFSIZ   size_t(16384u)

◆ CPPHTTPLIB_CONNECTION_TIMEOUT_SECOND

#define CPPHTTPLIB_CONNECTION_TIMEOUT_SECOND   300

◆ CPPHTTPLIB_CONNECTION_TIMEOUT_USECOND

#define CPPHTTPLIB_CONNECTION_TIMEOUT_USECOND   0

◆ CPPHTTPLIB_EXPECT_100_THRESHOLD

#define CPPHTTPLIB_EXPECT_100_THRESHOLD   1024

◆ CPPHTTPLIB_EXPECT_100_TIMEOUT_MSECOND

#define CPPHTTPLIB_EXPECT_100_TIMEOUT_MSECOND   1000

◆ CPPHTTPLIB_FORM_URL_ENCODED_PAYLOAD_MAX_LENGTH

#define CPPHTTPLIB_FORM_URL_ENCODED_PAYLOAD_MAX_LENGTH   8192

◆ CPPHTTPLIB_HEADER_MAX_COUNT

#define CPPHTTPLIB_HEADER_MAX_COUNT   100

◆ CPPHTTPLIB_HEADER_MAX_LENGTH

#define CPPHTTPLIB_HEADER_MAX_LENGTH   8192

◆ CPPHTTPLIB_IDLE_INTERVAL_SECOND

#define CPPHTTPLIB_IDLE_INTERVAL_SECOND   0

◆ CPPHTTPLIB_IDLE_INTERVAL_USECOND

#define CPPHTTPLIB_IDLE_INTERVAL_USECOND   0

◆ CPPHTTPLIB_IPV6_V6ONLY

#define CPPHTTPLIB_IPV6_V6ONLY   false

◆ CPPHTTPLIB_KEEPALIVE_MAX_COUNT

#define CPPHTTPLIB_KEEPALIVE_MAX_COUNT   100

◆ CPPHTTPLIB_KEEPALIVE_TIMEOUT_CHECK_INTERVAL_USECOND

#define CPPHTTPLIB_KEEPALIVE_TIMEOUT_CHECK_INTERVAL_USECOND   10000

◆ CPPHTTPLIB_KEEPALIVE_TIMEOUT_SECOND

#define CPPHTTPLIB_KEEPALIVE_TIMEOUT_SECOND   5

◆ CPPHTTPLIB_LISTEN_BACKLOG

#define CPPHTTPLIB_LISTEN_BACKLOG   5

◆ CPPHTTPLIB_MAX_LINE_LENGTH

#define CPPHTTPLIB_MAX_LINE_LENGTH   32768

◆ CPPHTTPLIB_MULTIPART_FORM_DATA_FILE_MAX_COUNT

#define CPPHTTPLIB_MULTIPART_FORM_DATA_FILE_MAX_COUNT   1024

◆ CPPHTTPLIB_PAYLOAD_MAX_LENGTH

#define CPPHTTPLIB_PAYLOAD_MAX_LENGTH   (100 * 1024 * 1024)

◆ CPPHTTPLIB_RANGE_MAX_COUNT

#define CPPHTTPLIB_RANGE_MAX_COUNT   1024

◆ CPPHTTPLIB_RECV_BUFSIZ

#define CPPHTTPLIB_RECV_BUFSIZ   size_t(16384u)

◆ CPPHTTPLIB_RECV_FLAGS

#define CPPHTTPLIB_RECV_FLAGS   0

◆ CPPHTTPLIB_REDIRECT_MAX_COUNT

#define CPPHTTPLIB_REDIRECT_MAX_COUNT   20

◆ CPPHTTPLIB_REQUEST_URI_MAX_LENGTH

#define CPPHTTPLIB_REQUEST_URI_MAX_LENGTH   8192

◆ CPPHTTPLIB_SEND_BUFSIZ

#define CPPHTTPLIB_SEND_BUFSIZ   size_t(16384u)

◆ CPPHTTPLIB_SEND_FLAGS

#define CPPHTTPLIB_SEND_FLAGS   0

◆ CPPHTTPLIB_SERVER_READ_TIMEOUT_SECOND

#define CPPHTTPLIB_SERVER_READ_TIMEOUT_SECOND   5

◆ CPPHTTPLIB_SERVER_READ_TIMEOUT_USECOND

#define CPPHTTPLIB_SERVER_READ_TIMEOUT_USECOND   0

◆ CPPHTTPLIB_SERVER_WRITE_TIMEOUT_SECOND

#define CPPHTTPLIB_SERVER_WRITE_TIMEOUT_SECOND   5

◆ CPPHTTPLIB_SERVER_WRITE_TIMEOUT_USECOND

#define CPPHTTPLIB_SERVER_WRITE_TIMEOUT_USECOND   0

◆ CPPHTTPLIB_TCP_NODELAY

#define CPPHTTPLIB_TCP_NODELAY   false

◆ CPPHTTPLIB_THREAD_POOL_COUNT

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

◆ CPPHTTPLIB_THREAD_POOL_IDLE_TIMEOUT

#define CPPHTTPLIB_THREAD_POOL_IDLE_TIMEOUT   3

◆ CPPHTTPLIB_THREAD_POOL_MAX_COUNT

#define CPPHTTPLIB_THREAD_POOL_MAX_COUNT   (CPPHTTPLIB_THREAD_POOL_COUNT * 4)

◆ CPPHTTPLIB_VERSION

#define CPPHTTPLIB_VERSION   "0.39.0"

◆ CPPHTTPLIB_VERSION_NUM

#define CPPHTTPLIB_VERSION_NUM   "0x002700"

◆ CPPHTTPLIB_WAIT_EARLY_SERVER_RESPONSE_THRESHOLD

#define CPPHTTPLIB_WAIT_EARLY_SERVER_RESPONSE_THRESHOLD   (1024 * 1024)

◆ CPPHTTPLIB_WAIT_EARLY_SERVER_RESPONSE_TIMEOUT_MSECOND

#define CPPHTTPLIB_WAIT_EARLY_SERVER_RESPONSE_TIMEOUT_MSECOND   50

◆ CPPHTTPLIB_WEBSOCKET_CLOSE_TIMEOUT_SECOND

#define CPPHTTPLIB_WEBSOCKET_CLOSE_TIMEOUT_SECOND   5

◆ CPPHTTPLIB_WEBSOCKET_MAX_PAYLOAD_LENGTH

#define CPPHTTPLIB_WEBSOCKET_MAX_PAYLOAD_LENGTH   16777216

◆ CPPHTTPLIB_WEBSOCKET_PING_INTERVAL_SECOND

#define CPPHTTPLIB_WEBSOCKET_PING_INTERVAL_SECOND   30

◆ CPPHTTPLIB_WEBSOCKET_READ_TIMEOUT_SECOND

#define CPPHTTPLIB_WEBSOCKET_READ_TIMEOUT_SECOND   300

◆ INVALID_SOCKET

#define INVALID_SOCKET   (-1)

◆ USE_IF2IP

#define USE_IF2IP

Typedef Documentation

◆ socket_t

using socket_t = int