Darknet/YOLO v3.0-88-gdee7eef
Object Detection Framework
 
Loading...
Searching...
No Matches
httplib::Server Class Reference

#include "httplib.hpp"

Collaboration diagram for httplib::Server:

Public Types

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

Public Member Functions

 Server ()
 
virtual ~Server ()
 
int bind_to_any_port (const char *host, int socket_flags=0)
 
bool bind_to_port (const char *host, int port, int socket_flags=0)
 
ServerDelete (const char *pattern, Handler handler)
 
ServerGet (const char *pattern, Handler handler)
 
bool is_running () const
 
virtual bool is_valid () const
 
bool listen (const char *host, int port, int socket_flags=0)
 
bool listen_after_bind ()
 
ServerOptions (const char *pattern, Handler handler)
 
ServerPatch (const char *pattern, Handler handler)
 
ServerPatch (const char *pattern, HandlerWithContentReader handler)
 
ServerPost (const char *pattern, Handler handler)
 
ServerPost (const char *pattern, HandlerWithContentReader handler)
 
ServerPut (const char *pattern, Handler handler)
 
ServerPut (const char *pattern, HandlerWithContentReader handler)
 
bool set_base_dir (const char *dir, const char *mount_point=nullptr)
 
void set_error_handler (Handler handler)
 
void set_file_request_handler (Handler handler)
 
void set_keep_alive_max_count (size_t count)
 
void set_logger (Logger logger)
 
void set_payload_max_length (size_t length)
 
void set_read_timeout (time_t sec, time_t usec)
 
void stop ()
 

Public Attributes

std::function< TaskQueue *(void)> new_task_queue
 

Protected Member Functions

bool process_request (Stream &strm, bool last_connection, bool &connection_close, const std::function< void(Request &)> &setup_request)
 

Protected Attributes

size_t keep_alive_max_count_
 
size_t payload_max_length_
 
time_t read_timeout_sec_
 
time_t read_timeout_usec_
 

Private Types

using HandersForContentReader = std::vector< std::pair< std::regex, HandlerWithContentReader > >
 
using Handlers = std::vector< std::pair< std::regex, Handler > >
 

Private Member Functions

int bind_internal (const char *host, int port, int socket_flags)
 
socket_t create_server_socket (const char *host, int port, int socket_flags) const
 
bool dispatch_request (Request &req, Response &res, Handlers &handlers)
 
bool dispatch_request_for_content_reader (Request &req, Response &res, ContentReader content_reader, HandersForContentReader &handlers)
 
bool handle_file_request (Request &req, Response &res)
 
bool listen_internal ()
 
bool parse_request_line (const char *s, Request &req)
 
virtual bool process_and_close_socket (socket_t sock)
 
bool read_content (Stream &strm, bool last_connection, Request &req, Response &res)
 
bool read_content_with_content_receiver (Stream &strm, bool last_connection, Request &req, Response &res, ContentReceiver reveiver)
 
bool routing (Request &req, Response &res, Stream &strm, bool last_connection)
 
bool write_content_with_provider (Stream &strm, const Request &req, Response &res, const std::string &boundary, const std::string &content_type)
 
bool write_response (Stream &strm, bool last_connection, const Request &req, Response &res)
 

Private Attributes

std::vector< std::pair< std::string, std::string > > base_dirs_
 
Handlers delete_handlers_
 
Handler error_handler_
 
Handler file_request_handler_
 
Handlers get_handlers_
 
std::atomic< bool > is_running_
 
Logger logger_
 
Handlers options_handlers_
 
Handlers patch_handlers_
 
HandersForContentReader patch_handlers_for_content_reader
 
Handlers post_handlers_
 
HandersForContentReader post_handlers_for_content_reader
 
Handlers put_handlers_
 
HandersForContentReader put_handlers_for_content_reader
 
std::atomic< socket_tsvr_sock_
 

Member Typedef Documentation

◆ HandersForContentReader

using httplib::Server::HandersForContentReader = std::vector<std::pair<std::regex, HandlerWithContentReader> >
private

◆ Handler

using httplib::Server::Handler = std::function<void(const Request &, Response &)>

◆ Handlers

using httplib::Server::Handlers = std::vector<std::pair<std::regex, Handler> >
private

◆ HandlerWithContentReader

using httplib::Server::HandlerWithContentReader = std::function<void(const Request &, Response &, const ContentReader &content_reader)>

◆ Logger

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

Constructor & Destructor Documentation

◆ Server()

httplib::Server::Server ( )
inline

◆ ~Server()

httplib::Server::~Server ( )
inlinevirtual

Member Function Documentation

◆ bind_internal()

int httplib::Server::bind_internal ( const char *  host,
int  port,
int  socket_flags 
)
inlineprivate
Here is the call graph for this function:
Here is the caller graph for this function:

◆ bind_to_any_port()

int httplib::Server::bind_to_any_port ( const char *  host,
int  socket_flags = 0 
)
inline
Here is the call graph for this function:

◆ bind_to_port()

bool httplib::Server::bind_to_port ( const char *  host,
int  port,
int  socket_flags = 0 
)
inline
Here is the call graph for this function:
Here is the caller graph for this function:

◆ create_server_socket()

socket_t httplib::Server::create_server_socket ( const char *  host,
int  port,
int  socket_flags 
) const
inlineprivate
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Delete()

Server & httplib::Server::Delete ( const char *  pattern,
Handler  handler 
)
inline

◆ dispatch_request()

bool httplib::Server::dispatch_request ( Request req,
Response res,
Handlers handlers 
)
inlineprivate
Here is the caller graph for this function:

◆ dispatch_request_for_content_reader()

bool httplib::Server::dispatch_request_for_content_reader ( Request req,
Response res,
ContentReader  content_reader,
HandersForContentReader handlers 
)
inlineprivate
Here is the caller graph for this function:

◆ Get()

Server & httplib::Server::Get ( const char *  pattern,
Handler  handler 
)
inline

◆ handle_file_request()

bool httplib::Server::handle_file_request ( Request req,
Response res 
)
inlineprivate
Here is the call graph for this function:
Here is the caller graph for this function:

◆ is_running()

bool httplib::Server::is_running ( ) const
inline

◆ is_valid()

bool httplib::Server::is_valid ( ) const
inlinevirtual
Here is the caller graph for this function:

◆ listen()

bool httplib::Server::listen ( const char *  host,
int  port,
int  socket_flags = 0 
)
inline
Here is the call graph for this function:
Here is the caller graph for this function:

◆ listen_after_bind()

bool httplib::Server::listen_after_bind ( )
inline
Here is the call graph for this function:

◆ listen_internal()

bool httplib::Server::listen_internal ( )
inlineprivate
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Options()

Server & httplib::Server::Options ( const char *  pattern,
Handler  handler 
)
inline

◆ parse_request_line()

bool httplib::Server::parse_request_line ( const char *  s,
Request req 
)
inlineprivate
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Patch() [1/2]

Server & httplib::Server::Patch ( const char *  pattern,
Handler  handler 
)
inline

◆ Patch() [2/2]

Server & httplib::Server::Patch ( const char *  pattern,
HandlerWithContentReader  handler 
)
inline

◆ Post() [1/2]

Server & httplib::Server::Post ( const char *  pattern,
Handler  handler 
)
inline

◆ Post() [2/2]

Server & httplib::Server::Post ( const char *  pattern,
HandlerWithContentReader  handler 
)
inline

◆ process_and_close_socket()

bool httplib::Server::process_and_close_socket ( socket_t  sock)
inlineprivatevirtual
Here is the call graph for this function:
Here is the caller graph for this function:

◆ process_request()

bool httplib::Server::process_request ( Stream strm,
bool  last_connection,
bool &  connection_close,
const std::function< void(Request &)> &  setup_request 
)
inlineprotected
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Put() [1/2]

Server & httplib::Server::Put ( const char *  pattern,
Handler  handler 
)
inline

◆ Put() [2/2]

Server & httplib::Server::Put ( const char *  pattern,
HandlerWithContentReader  handler 
)
inline

◆ read_content()

bool httplib::Server::read_content ( Stream strm,
bool  last_connection,
Request req,
Response res 
)
inlineprivate
Here is the call graph for this function:
Here is the caller graph for this function:

◆ read_content_with_content_receiver()

bool httplib::Server::read_content_with_content_receiver ( Stream strm,
bool  last_connection,
Request req,
Response res,
ContentReceiver  reveiver 
)
inlineprivate
Here is the call graph for this function:
Here is the caller graph for this function:

◆ routing()

bool httplib::Server::routing ( Request req,
Response res,
Stream strm,
bool  last_connection 
)
inlineprivate
Here is the call graph for this function:
Here is the caller graph for this function:

◆ set_base_dir()

bool httplib::Server::set_base_dir ( const char *  dir,
const char *  mount_point = nullptr 
)
inline
Here is the call graph for this function:

◆ set_error_handler()

void httplib::Server::set_error_handler ( Handler  handler)
inline

◆ set_file_request_handler()

void httplib::Server::set_file_request_handler ( Handler  handler)
inline

◆ set_keep_alive_max_count()

void httplib::Server::set_keep_alive_max_count ( size_t  count)
inline

◆ set_logger()

void httplib::Server::set_logger ( Logger  logger)
inline

◆ set_payload_max_length()

void httplib::Server::set_payload_max_length ( size_t  length)
inline

◆ set_read_timeout()

void httplib::Server::set_read_timeout ( time_t  sec,
time_t  usec 
)
inline
Here is the call graph for this function:

◆ stop()

void httplib::Server::stop ( )
inline
Here is the call graph for this function:

◆ write_content_with_provider()

bool httplib::Server::write_content_with_provider ( Stream strm,
const Request req,
Response res,
const std::string &  boundary,
const std::string &  content_type 
)
inlineprivate
Here is the call graph for this function:
Here is the caller graph for this function:

◆ write_response()

bool httplib::Server::write_response ( Stream strm,
bool  last_connection,
const Request req,
Response res 
)
inlineprivate
Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ base_dirs_

std::vector<std::pair<std::string, std::string> > httplib::Server::base_dirs_
private

◆ delete_handlers_

Handlers httplib::Server::delete_handlers_
private

◆ error_handler_

Handler httplib::Server::error_handler_
private

◆ file_request_handler_

Handler httplib::Server::file_request_handler_
private

◆ get_handlers_

Handlers httplib::Server::get_handlers_
private

◆ is_running_

std::atomic<bool> httplib::Server::is_running_
private

◆ keep_alive_max_count_

size_t httplib::Server::keep_alive_max_count_
protected

◆ logger_

Logger httplib::Server::logger_
private

◆ new_task_queue

std::function<TaskQueue *(void)> httplib::Server::new_task_queue

◆ options_handlers_

Handlers httplib::Server::options_handlers_
private

◆ patch_handlers_

Handlers httplib::Server::patch_handlers_
private

◆ patch_handlers_for_content_reader

HandersForContentReader httplib::Server::patch_handlers_for_content_reader
private

◆ payload_max_length_

size_t httplib::Server::payload_max_length_
protected

◆ post_handlers_

Handlers httplib::Server::post_handlers_
private

◆ post_handlers_for_content_reader

HandersForContentReader httplib::Server::post_handlers_for_content_reader
private

◆ put_handlers_

Handlers httplib::Server::put_handlers_
private

◆ put_handlers_for_content_reader

HandersForContentReader httplib::Server::put_handlers_for_content_reader
private

◆ read_timeout_sec_

time_t httplib::Server::read_timeout_sec_
protected

◆ read_timeout_usec_

time_t httplib::Server::read_timeout_usec_
protected

◆ svr_sock_

std::atomic<socket_t> httplib::Server::svr_sock_
private

The documentation for this class was generated from the following file: