5MP Motion Camera JPEG Image and Movie Catcher  1.1.1.1
A CGI interface to capture and display pictures and movies using OpenCV.
Http_parser Class Reference

#include <http_parser.hpp>

Public Member Functions

 Http_parser (map< string, string > &env_ptr)
 
 ~Http_parser ()
 
void parse_raw_content_type ()
 
void parse_query_string ()
 
void parse_json ()
 
void parse_multipart_form ()
 
void print_all (ostream &o_stream, http_io &io, bool hex_dump=false)
 
void print_file (ostream &o_stream, bool hex_dump=false)
 
void print_get (ostream &o_stream, bool hex_dump=false)
 
void print_post (ostream &o_stream, bool hex_dump=false)
 

Public Attributes

string boundary
 
string charset
 
string content_type
 
const string cr_nl {"\r\n"}
 
const string cr_nl_2 {"\r\n\r\n"}
 
map< string, vector< string > > get
 
map< string, vector< string > > post
 
map< string, vector< map< string, string > > > file
 
void * curl
 
string_util su
 
map< string, string > env
 

Static Public Attributes

static const int cr_nl_s = 2
 
static const int cr_nl_2s = 4
 

Private Attributes

const char http_content_type [24] = R"END(^(.*?);\s(.*)$)END"
 
regex content_type_regex {http_content_type, regex_constants::optimize}
 
const string file_regex_line1 = R"END(Content-Disposition: form-data; name="(.*?)"; filename="(.*?)")END"
 
regex multipart_form_file_l1 {file_regex_line1, regex_constants::optimize}
 
const string file_regex_line2 = R"END(Content-Type: (.*))END"
 
regex multipart_form_file_l2 {file_regex_line2, regex_constants::optimize}
 
const string data_regex = R"END(Content-Disposition: form-data; name="(.*)")END"
 
regex multipart_form_data {data_regex, regex_constants::optimize}
 

Constructor & Destructor Documentation

◆ Http_parser()

Http_parser::Http_parser ( map< string, string > &  env_ptr)
explicit

A class for parsing the stdin passed to us by the CGI web server.

Note that the order of operations is dependent.

Parameters
env_ptrThe web server CGI shell environment passed into main() and parsed into Http_io::env

◆ ~Http_parser()

Http_parser::~Http_parser ( )

Member Function Documentation

◆ parse_json()

void Http_parser::parse_json ( )

Parse an HTTP message body in JSON format.

Stores key:value pairs in Http_parser::post and Http_parser::file objects.

< jsonxx::Settings; Parser = Strict, Assertions = Disabled.

◆ parse_multipart_form()

void Http_parser::parse_multipart_form ( )

Parse an HTTP message body in multipart/form-data format.

Stores key:value pairs in Http_parser::post and file objects in Http_parser::file.

◆ parse_query_string()

void Http_parser::parse_query_string ( )

Sets Http_parser::get from values found in the raw HTTP query string.

◆ parse_raw_content_type()

void Http_parser::parse_raw_content_type ( )

Sets Http_parser::content_type, Http_parser::boundary, Http_parser::charset from values found in the raw HTTP Content-Type header.

< No boundary or charset to parse.

◆ print_all()

void Http_parser::print_all ( ostream &  o_stream,
http_io io,
bool  hex_dump = false 
)

Dump all the data structures (optionally in hex_dump format) to any stream. Calls Http_io::print_env, Http_parser::print_file, Http_parser::print_post, and Http_parser::print_get.

Parameters
o_streamThe stream to print the output to; stdout or a file typically.
ioAdditional data to print.
hex_dumpwhether to print in hex_dump format.

◆ print_file()

void Http_parser::print_file ( ostream &  o_stream,
bool  hex_dump = false 
)

Dump Http_parser::file (optionally in hex_dump format) to any stream.

Parameters
o_streamThe stream to print the output to; stdout or a file typically.
hex_dumpwhether to print in hex_dump format.

◆ print_get()

void Http_parser::print_get ( ostream &  o_stream,
bool  hex_dump = false 
)

Dump Http_parser::get (optionally in hex_dump format) to any stream.

Parameters
o_streamThe stream to print the output to; stdout or a file typically.
hex_dumpwhether to print in hex_dump format.

◆ print_post()

void Http_parser::print_post ( ostream &  o_stream,
bool  hex_dump = false 
)

Dump Http_parser::post (optionally in hex_dump format) to any stream.

Parameters
o_streamThe stream to print the output to; stdout or a file typically.
hex_dumpwhether to print in hex_dump format.

Member Data Documentation

◆ boundary

string Http_parser::boundary

◆ charset

string Http_parser::charset

◆ content_type

string Http_parser::content_type

◆ content_type_regex

regex Http_parser::content_type_regex {http_content_type, regex_constants::optimize}
private

◆ cr_nl

const string Http_parser::cr_nl {"\r\n"}

◆ cr_nl_2

const string Http_parser::cr_nl_2 {"\r\n\r\n"}

◆ cr_nl_2s

const int Http_parser::cr_nl_2s = 4
static

◆ cr_nl_s

const int Http_parser::cr_nl_s = 2
static

◆ curl

void* Http_parser::curl

◆ data_regex

const string Http_parser::data_regex = R"END(Content-Disposition: form-data; name="(.*)")END"
private

◆ env

map<string, string> Http_parser::env

◆ file

map<string, vector<map<string, string> > > Http_parser::file

◆ file_regex_line1

const string Http_parser::file_regex_line1 = R"END(Content-Disposition: form-data; name="(.*?)"; filename="(.*?)")END"
private

◆ file_regex_line2

const string Http_parser::file_regex_line2 = R"END(Content-Type: (.*))END"
private

◆ get

map<string, vector<string> > Http_parser::get

◆ http_content_type

const char Http_parser::http_content_type[24] = R"END(^(.*?);\s(.*)$)END"
private

◆ multipart_form_data

regex Http_parser::multipart_form_data {data_regex, regex_constants::optimize}
private

◆ multipart_form_file_l1

regex Http_parser::multipart_form_file_l1 {file_regex_line1, regex_constants::optimize}
private

◆ multipart_form_file_l2

regex Http_parser::multipart_form_file_l2 {file_regex_line2, regex_constants::optimize}
private

◆ post

map<string, vector<string> > Http_parser::post

◆ su

string_util Http_parser::su

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