wibble  1.1
Public Member Functions | Public Attributes | List of all members
wibble::net::http::Params Struct Reference

Parse and store HTTP query parameters. More...

#include <http.h>

Inheritance diagram for wibble::net::http::Params:
Inheritance graph
[legend]
Collaboration diagram for wibble::net::http::Params:
Collaboration graph
[legend]

Public Member Functions

 Params ()
 
 ~Params ()
 
template<typename TYPE >
TYPE * add (const std::string &name)
 Universal, automatic add method. More...
 
void add (const std::string &name, Param *param)
 Add a normal parameter to be parsed from the request. More...
 
void add (const std::string &name, FileParam *param)
 Add a file upload parameter to be parsed from the request. More...
 
Paramobtain_field (const std::string &name)
 Get a normal fileld during form parsing. More...
 
FileParamobtain_file_field (const std::string &name)
 Get a normal fileld during form parsing. More...
 
Paramfield (const std::string &name)
 Get a field by name. More...
 
FileParamfile_field (const std::string &name)
 Get a file field by name. More...
 
void parse_get_or_post (net::http::Request &req)
 Parse parameters as GET or POST according to request method. More...
 
void parse_urlencoded (const std::string &qstring)
 Parse parameters from urlencoded form data. More...
 
void parse_multipart (net::http::Request &req, size_t inputsize, const std::string &content_type)
 Parse parameters from multipart/form-data. More...
 
void parse_post (net::http::Request &req)
 Parse parameters from HTTP POST input. More...
 

Public Attributes

std::map< std::string, FileParam * > files
 File parameters. More...
 
size_t conf_max_input_size
 Maximum size of POST input data. More...
 
size_t conf_max_field_size
 Maximum size of field data for one non-file field. More...
 
bool conf_accept_unknown_fields
 Whether to accept unknown fields. More...
 
bool conf_accept_unknown_file_fields
 Whether to accept unknown file upload fields. More...
 
std::string conf_outdir
 Directory where we write uploaded files. More...
 
std::string conf_fname_blacklist
 String containing blacklist characters that are replaced with "_" in the file name. More...
 

Detailed Description

Parse and store HTTP query parameters.

It is preconfigured by manipulating the various conf_* fields and using the add() methods, before calling one of the parse_* methods.

Constructor & Destructor Documentation

◆ Params()

wibble::net::http::Params::Params ( )

◆ ~Params()

wibble::net::http::Params::~Params ( )

Member Function Documentation

◆ add() [1/3]

template<typename TYPE >
TYPE* wibble::net::http::Params::add ( const std::string &  name)
inline

Universal, automatic add method.

◆ add() [2/3]

void wibble::net::http::Params::add ( const std::string &  name,
FileParam param 
)

Add a file upload parameter to be parsed from the request.

References wibble::iterator().

◆ add() [3/3]

void wibble::net::http::Params::add ( const std::string &  name,
Param param 
)

Add a normal parameter to be parsed from the request.

References wibble::list::end(), and wibble::iterator().

◆ field()

Param * wibble::net::http::Params::field ( const std::string &  name)

Get a field by name.

References wibble::list::end(), and wibble::iterator().

◆ file_field()

FileParam * wibble::net::http::Params::file_field ( const std::string &  name)

Get a file field by name.

References wibble::iterator().

◆ obtain_field()

Param * wibble::net::http::Params::obtain_field ( const std::string &  name)

Get a normal fileld during form parsing.

Depending on the value of conf_accept_unknown_fields, when handling a field that has not been added before it will either create it if missing, or just return NULL.

References wibble::list::end(), and wibble::iterator().

◆ obtain_file_field()

FileParam * wibble::net::http::Params::obtain_file_field ( const std::string &  name)

Get a normal fileld during form parsing.

Depending on the value of conf_accept_unknown_file_fields, when handling a field that has not been added before it will either create it if missing, or just return NULL.

References wibble::iterator().

◆ parse_get_or_post()

void wibble::net::http::Params::parse_get_or_post ( net::http::Request req)

Parse parameters as GET or POST according to request method.

References wibble::net::http::Request::method, and wibble::net::http::Request::url.

◆ parse_multipart()

void wibble::net::http::Params::parse_multipart ( net::http::Request req,
size_t  inputsize,
const std::string &  content_type 
)

◆ parse_post()

void wibble::net::http::Params::parse_post ( net::http::Request req)

◆ parse_urlencoded()

void wibble::net::http::Params::parse_urlencoded ( const std::string &  qstring)

Member Data Documentation

◆ conf_accept_unknown_fields

bool wibble::net::http::Params::conf_accept_unknown_fields

Whether to accept unknown fields.

If true, unkown fields are stored as ParamMulti

If false, unknown fields are ignored.

◆ conf_accept_unknown_file_fields

bool wibble::net::http::Params::conf_accept_unknown_file_fields

Whether to accept unknown file upload fields.

If true, unkown fields are stored as FileParamMulti

If false, unknown file upload fields are ignored.

◆ conf_fname_blacklist

std::string wibble::net::http::Params::conf_fname_blacklist

String containing blacklist characters that are replaced with "_" in the file name.

If empty, nothing is replaced.

This only applies to the basename: the pathname is ignored when building the local file name.

◆ conf_max_field_size

size_t wibble::net::http::Params::conf_max_field_size

Maximum size of field data for one non-file field.

◆ conf_max_input_size

size_t wibble::net::http::Params::conf_max_input_size

Maximum size of POST input data.

◆ conf_outdir

std::string wibble::net::http::Params::conf_outdir

Directory where we write uploaded files.

Warning
: if it is not set to anything, it ignores all file uploads

◆ files

std::map<std::string, FileParam*> wibble::net::http::Params::files

File parameters.


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