Goby3 3.2.3
2025.05.13
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 <netinet/tcp.h>
#include <csignal>
#include <pthread.h>
#include <sys/mman.h>
#include <sys/select.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 <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 <thread>
#include <unordered_map>
#include <unordered_set>
#include <utility>

Go to the source code of this file.

Classes

struct  httplib::detail::ci
 
struct  httplib::detail::scope_exit
 
struct  httplib::MultipartFormData
 
class  httplib::DataSink
 
struct  httplib::MultipartFormDataProvider
 
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
 
class  httplib::ClientImpl
 
struct  httplib::ClientImpl::Socket
 
class  httplib::Client
 

Namespaces

namespace  httplib
 
namespace  httplib::detail
 
namespace  httplib::detail::udl
 

Macros

#define CPPHTTPLIB_VERSION   "0.14.0"
 
#define CPPHTTPLIB_KEEPALIVE_TIMEOUT_SECOND   5
 
#define CPPHTTPLIB_KEEPALIVE_MAX_COUNT   5
 
#define CPPHTTPLIB_CONNECTION_TIMEOUT_SECOND   300
 
#define CPPHTTPLIB_CONNECTION_TIMEOUT_USECOND   0
 
#define CPPHTTPLIB_READ_TIMEOUT_SECOND   5
 
#define CPPHTTPLIB_READ_TIMEOUT_USECOND   0
 
#define CPPHTTPLIB_WRITE_TIMEOUT_SECOND   5
 
#define CPPHTTPLIB_WRITE_TIMEOUT_USECOND   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_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_TCP_NODELAY   false
 
#define CPPHTTPLIB_RECV_BUFSIZ   size_t(4096u)
 
#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 INVALID_SOCKET   (-1)
 
#define USE_IF2IP
 

Typedefs

using socket_t = int
 
using httplib::Headers = std::multimap< std::string, std::string, detail::ci >
 
using httplib::Params = std::multimap< std::string, std::string >
 
using httplib::Match = std::smatch
 
using httplib::Progress = std::function< bool(uint64_t current, uint64_t total)>
 
using httplib::ResponseHandler = std::function< bool(const Response &response)>
 
using httplib::MultipartFormDataItems = std::vector< MultipartFormData >
 
using httplib::MultipartFormDataMap = std::multimap< std::string, MultipartFormData >
 
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::MultipartFormDataProviderItems = std::vector< MultipartFormDataProvider >
 
using httplib::ContentReceiverWithProgress = std::function< bool(const char *data, size_t data_length, uint64_t offset, uint64_t total_length)>
 
using httplib::ContentReceiver = std::function< bool(const char *data, size_t data_length)>
 
using httplib::MultipartContentHeader = std::function< bool(const MultipartFormData &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::SocketOptions = std::function< void(socket_t sock)>
 

Enumerations

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::UnsupportedMultipartBoundaryChars ,
  httplib::Compression , httplib::ConnectionTimeout , httplib::ProxyConnection , 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)
 
void httplib::default_socket_options (socket_t sock)
 
const char * httplib::status_message (int status)
 
std::string httplib::to_string (const Error error)
 
std::ostream & httplib::operator<< (std::ostream &os, const Error &obj)
 
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::append_query_params (const std::string &path, const Params &params)
 
std::pair< std::string, std::string > httplib::make_range_header (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)
 

Macro Definition Documentation

◆ CPPHTTPLIB_COMPRESSION_BUFSIZ

#define CPPHTTPLIB_COMPRESSION_BUFSIZ   size_t(16384u)

Definition at line 94 of file httplib.h.

◆ CPPHTTPLIB_CONNECTION_TIMEOUT_SECOND

#define CPPHTTPLIB_CONNECTION_TIMEOUT_SECOND   300

Definition at line 26 of file httplib.h.

◆ CPPHTTPLIB_CONNECTION_TIMEOUT_USECOND

#define CPPHTTPLIB_CONNECTION_TIMEOUT_USECOND   0

Definition at line 30 of file httplib.h.

◆ CPPHTTPLIB_FORM_URL_ENCODED_PAYLOAD_MAX_LENGTH

#define CPPHTTPLIB_FORM_URL_ENCODED_PAYLOAD_MAX_LENGTH   8192

Definition at line 82 of file httplib.h.

◆ CPPHTTPLIB_HEADER_MAX_LENGTH

#define CPPHTTPLIB_HEADER_MAX_LENGTH   8192

Definition at line 66 of file httplib.h.

◆ CPPHTTPLIB_IDLE_INTERVAL_SECOND

#define CPPHTTPLIB_IDLE_INTERVAL_SECOND   0

Definition at line 50 of file httplib.h.

◆ CPPHTTPLIB_IDLE_INTERVAL_USECOND

#define CPPHTTPLIB_IDLE_INTERVAL_USECOND   0

Definition at line 57 of file httplib.h.

◆ CPPHTTPLIB_KEEPALIVE_MAX_COUNT

#define CPPHTTPLIB_KEEPALIVE_MAX_COUNT   5

Definition at line 22 of file httplib.h.

◆ CPPHTTPLIB_KEEPALIVE_TIMEOUT_SECOND

#define CPPHTTPLIB_KEEPALIVE_TIMEOUT_SECOND   5

Definition at line 18 of file httplib.h.

◆ CPPHTTPLIB_LISTEN_BACKLOG

#define CPPHTTPLIB_LISTEN_BACKLOG   5

Definition at line 113 of file httplib.h.

◆ CPPHTTPLIB_MULTIPART_FORM_DATA_FILE_MAX_COUNT

#define CPPHTTPLIB_MULTIPART_FORM_DATA_FILE_MAX_COUNT   1024

Definition at line 74 of file httplib.h.

◆ CPPHTTPLIB_PAYLOAD_MAX_LENGTH

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

Definition at line 78 of file httplib.h.

◆ CPPHTTPLIB_READ_TIMEOUT_SECOND

#define CPPHTTPLIB_READ_TIMEOUT_SECOND   5

Definition at line 34 of file httplib.h.

◆ CPPHTTPLIB_READ_TIMEOUT_USECOND

#define CPPHTTPLIB_READ_TIMEOUT_USECOND   0

Definition at line 38 of file httplib.h.

◆ CPPHTTPLIB_RECV_BUFSIZ

#define CPPHTTPLIB_RECV_BUFSIZ   size_t(4096u)

Definition at line 90 of file httplib.h.

◆ CPPHTTPLIB_RECV_FLAGS

#define CPPHTTPLIB_RECV_FLAGS   0

Definition at line 105 of file httplib.h.

◆ CPPHTTPLIB_REDIRECT_MAX_COUNT

#define CPPHTTPLIB_REDIRECT_MAX_COUNT   20

Definition at line 70 of file httplib.h.

◆ CPPHTTPLIB_REQUEST_URI_MAX_LENGTH

#define CPPHTTPLIB_REQUEST_URI_MAX_LENGTH   8192

Definition at line 62 of file httplib.h.

◆ CPPHTTPLIB_SEND_FLAGS

#define CPPHTTPLIB_SEND_FLAGS   0

Definition at line 109 of file httplib.h.

◆ CPPHTTPLIB_TCP_NODELAY

#define CPPHTTPLIB_TCP_NODELAY   false

Definition at line 86 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 98 of file httplib.h.

◆ CPPHTTPLIB_VERSION

#define CPPHTTPLIB_VERSION   "0.14.0"

Definition at line 11 of file httplib.h.

◆ CPPHTTPLIB_WRITE_TIMEOUT_SECOND

#define CPPHTTPLIB_WRITE_TIMEOUT_SECOND   5

Definition at line 42 of file httplib.h.

◆ CPPHTTPLIB_WRITE_TIMEOUT_USECOND

#define CPPHTTPLIB_WRITE_TIMEOUT_USECOND   0

Definition at line 46 of file httplib.h.

◆ INVALID_SOCKET

#define INVALID_SOCKET   (-1)

Definition at line 204 of file httplib.h.

◆ USE_IF2IP

#define USE_IF2IP

Definition at line 3271 of file httplib.h.

Typedef Documentation

◆ socket_t

using socket_t = int

Definition at line 202 of file httplib.h.