httplib Namespace Reference

Namespaces

 detail
 

Classes

class  Client
 
class  ClientImpl
 
class  ContentReader
 
class  DataSink
 
struct  MultipartFormData
 
struct  MultipartFormDataProvider
 
struct  Request
 
struct  Response
 
class  Result
 
class  Server
 
class  Stream
 
class  TaskQueue
 
class  ThreadPool
 

Typedefs

using ContentProvider = std::function< bool(size_t offset, size_t length, DataSink &sink)>
 
using ContentProviderResourceReleaser = std::function< void(bool success)>
 
using ContentProviderWithoutLength = std::function< bool(size_t offset, DataSink &sink)>
 
using ContentReceiver = std::function< bool(const char *data, size_t data_length)>
 
using ContentReceiverWithProgress = std::function< bool(const char *data, size_t data_length, uint64_t offset, uint64_t total_length)>
 
using Headers = std::unordered_multimap< std::string, std::string, detail::case_ignore::hash, detail::case_ignore::equal_to >
 
using Logger = std::function< void(const Request &, const Response &)>
 
using Match = std::smatch
 
using MultipartContentHeader = std::function< bool(const MultipartFormData &file)>
 
using MultipartFormDataItems = std::vector< MultipartFormData >
 
using MultipartFormDataMap = std::multimap< std::string, MultipartFormData >
 
using MultipartFormDataProviderItems = std::vector< MultipartFormDataProvider >
 
using Params = std::multimap< std::string, std::string >
 
using Progress = std::function< bool(uint64_t current, uint64_t total)>
 
using Range = std::pair< ssize_t, ssize_t >
 
using Ranges = std::vector< Range >
 
using ResponseHandler = std::function< bool(const Response &response)>
 
using SocketOptions = std::function< void(socket_t sock)>
 

Enumerations

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

Functions

std::string append_query_params (const std::string &path, const Params &params)
 
void default_socket_options (socket_t sock)
 
std::string get_bearer_token_auth (const Request &req)
 
std::string hosted_at (const std::string &hostname)
 
void hosted_at (const std::string &hostname, std::vector< std::string > &addrs)
 
std::pair< std::string, std::string > make_basic_authentication_header (const std::string &username, const std::string &password, bool is_proxy=false)
 
std::pair< std::string, std::string > make_bearer_token_authentication_header (const std::string &token, bool is_proxy=false)
 
std::pair< std::string, std::string > make_range_header (const Ranges &ranges)
 
std::ostream & operator<< (std::ostream &os, const Error &obj)
 
const char * status_message (int status)
 
std::string to_string (Error error)
 

Typedef Documentation

◆ ContentProvider

using ContentProvider = std::function<bool(size_t offset, size_t length, DataSink &sink)>

Definition at line 561 of file httplib.h.

◆ ContentProviderResourceReleaser

using ContentProviderResourceReleaser = std::function<void(bool success)>

Definition at line 566 of file httplib.h.

◆ ContentProviderWithoutLength

using ContentProviderWithoutLength = std::function<bool(size_t offset, DataSink &sink)>

Definition at line 564 of file httplib.h.

◆ ContentReceiver

using ContentReceiver = std::function<bool(const char *data, size_t data_length)>

Definition at line 581 of file httplib.h.

◆ ContentReceiverWithProgress

using ContentReceiverWithProgress = std::function<bool(const char *data, size_t data_length, uint64_t offset, uint64_t total_length)>

Definition at line 578 of file httplib.h.

◆ Headers

using Headers = std::unordered_multimap<std::string, std::string, detail::case_ignore::hash, detail::case_ignore::equal_to>

Definition at line 508 of file httplib.h.

◆ Logger

using Logger = std::function<void(const Request &, const Response &)>

Definition at line 836 of file httplib.h.

◆ Match

using Match = std::smatch

Definition at line 511 of file httplib.h.

◆ MultipartContentHeader

using MultipartContentHeader = std::function<bool(const MultipartFormData &file)>

Definition at line 584 of file httplib.h.

◆ MultipartFormDataItems

Definition at line 524 of file httplib.h.

◆ MultipartFormDataMap

using MultipartFormDataMap = std::multimap<std::string, MultipartFormData>

Definition at line 525 of file httplib.h.

◆ MultipartFormDataProviderItems

Definition at line 574 of file httplib.h.

◆ Params

using Params = std::multimap<std::string, std::string>

Definition at line 510 of file httplib.h.

◆ Progress

using Progress = std::function<bool(uint64_t current, uint64_t total)>

Definition at line 513 of file httplib.h.

◆ Range

using Range = std::pair<ssize_t, ssize_t>

Definition at line 609 of file httplib.h.

◆ Ranges

using Ranges = std::vector<Range>

Definition at line 610 of file httplib.h.

◆ ResponseHandler

using ResponseHandler = std::function<bool(const Response &response)>

Definition at line 516 of file httplib.h.

◆ SocketOptions

using SocketOptions = std::function<void(socket_t sock)>

Definition at line 838 of file httplib.h.

Enumeration Type Documentation

◆ Error

enum Error
strong
Enumerator
Success 
Unknown 
Connection 
BindIPAddress 
Read 
Write 
ExceedRedirectCount 
Canceled 
SSLConnection 
SSLLoadingCerts 
SSLServerVerification 
SSLServerHostnameVerification 
UnsupportedMultipartBoundaryChars 
Compression 
ConnectionTimeout 
ProxyConnection 
SSLPeerCouldBeClosed_ 

Definition at line 1131 of file httplib.h.

◆ StatusCode

enum StatusCode
Enumerator
Continue_100 
SwitchingProtocol_101 
Processing_102 
EarlyHints_103 
OK_200 
Created_201 
Accepted_202 
NonAuthoritativeInformation_203 
NoContent_204 
ResetContent_205 
PartialContent_206 
MultiStatus_207 
AlreadyReported_208 
IMUsed_226 
MultipleChoices_300 
MovedPermanently_301 
Found_302 
SeeOther_303 
NotModified_304 
UseProxy_305 
unused_306 
TemporaryRedirect_307 
PermanentRedirect_308 
BadRequest_400 
Unauthorized_401 
PaymentRequired_402 
Forbidden_403 
NotFound_404 
MethodNotAllowed_405 
NotAcceptable_406 
ProxyAuthenticationRequired_407 
RequestTimeout_408 
Conflict_409 
Gone_410 
LengthRequired_411 
PreconditionFailed_412 
PayloadTooLarge_413 
UriTooLong_414 
UnsupportedMediaType_415 
RangeNotSatisfiable_416 
ExpectationFailed_417 
ImATeapot_418 
MisdirectedRequest_421 
UnprocessableContent_422 
Locked_423 
FailedDependency_424 
TooEarly_425 
UpgradeRequired_426 
PreconditionRequired_428 
TooManyRequests_429 
RequestHeaderFieldsTooLarge_431 
UnavailableForLegalReasons_451 
InternalServerError_500 
NotImplemented_501 
BadGateway_502 
ServiceUnavailable_503 
GatewayTimeout_504 
HttpVersionNotSupported_505 
VariantAlsoNegotiates_506 
InsufficientStorage_507 
LoopDetected_508 
NotExtended_510 
NetworkAuthenticationRequired_511 

Definition at line 431 of file httplib.h.

Function Documentation

◆ append_query_params()

std::string append_query_params ( const std::string &  path,
const Params params 
)
inline

Definition at line 5634 of file httplib.h.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ default_socket_options()

void default_socket_options ( socket_t  sock)
inline

Definition at line 2039 of file httplib.h.

◆ get_bearer_token_auth()

std::string get_bearer_token_auth ( const Request req)
inline

Definition at line 2133 of file httplib.h.

+ Here is the call graph for this function:

◆ hosted_at() [1/2]

std::string hosted_at ( const std::string &  hostname)
inline

Definition at line 5597 of file httplib.h.

+ Here is the call graph for this function:

◆ hosted_at() [2/2]

void hosted_at ( const std::string &  hostname,
std::vector< std::string > &  addrs 
)
inline

Definition at line 5604 of file httplib.h.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ make_basic_authentication_header()

std::pair< std::string, std::string > make_basic_authentication_header ( const std::string &  username,
const std::string &  password,
bool  is_proxy = false 
)
inline

Definition at line 5659 of file httplib.h.

+ Here is the call graph for this function:

◆ make_bearer_token_authentication_header()

std::pair<std::string, std::string> httplib::make_bearer_token_authentication_header ( const std::string &  token,
bool  is_proxy = false 
)
inline

Definition at line 5667 of file httplib.h.

◆ make_range_header()

std::pair< std::string, std::string > make_range_header ( const Ranges ranges)
inline

Definition at line 5645 of file httplib.h.

+ Here is the call graph for this function:

◆ operator<<()

std::ostream & operator<< ( std::ostream &  os,
const Error obj 
)
inline

Definition at line 2192 of file httplib.h.

+ Here is the call graph for this function:

◆ status_message()

const char * status_message ( int  status)
inline

Definition at line 2057 of file httplib.h.

+ Here is the caller graph for this function:

◆ to_string()

std::string to_string ( Error  error)
inline

Definition at line 2166 of file httplib.h.

+ Here is the caller graph for this function: