MLIB
Loading...
Searching...
No Matches
httpd.h File Reference

Implementation of http::server and http::connection classes. More...

#include "tcpserver.h"
#include <string>
#include <map>
#include <deque>
#include <typeindex>
#include <filesystem>

Go to the source code of this file.

Data Structures

struct  mlib::http::ci_less
 Case insensitive comparison function. More...
 
class  mlib::http::connection
 Representation of a HTTP client connection request. More...
 
class  mlib::http::server
 Small multi-threaded HTTP server. More...
 

Macros

#define HTTPD_MAX_HEADER   8192
 Maximum size of HTTP header.
 
Error codes
#define HTTP_OK   0
 Success.
 
#define HTTP_ERR_WRITE   -1
 Socket write failure.
 
#define HTTP_ERR_FOPEN   -2
 File open failure.
 
#define HTTP_ERR_FREAD   -3
 File read failure.
 
#define HTTP_NO_HANDLER   -4
 No handler found.
 

Typedefs

typedef std::map< std::string, std::string, ci_lessmlib::http::str_pairs
 
typedef std::function< int(connection &client, void *info)> mlib::http::uri_handler
 User defined URL handler function.
 

Functions

std::ostream & mlib::http::operator<< (std::ostream &os, const str_pairs &hdrs)
 Stream out a headers map as a sequence of lines.
 

Detailed Description

Implementation of http::server and http::connection classes.

Typedef Documentation

◆ str_pairs

typedef std::map<std::string, std::string, ci_less> mlib::http::str_pairs

Key-value string pairs used for headers, URL-encoded data, etc. Keys are case insensitive.

Function Documentation

◆ operator<<()

std::ostream & mlib::http::operator<< ( std::ostream & os,
const str_pairs & hdrs )
inline

Stream out a headers map as a sequence of lines.

<key>: <value><CR><LF>