wibble::net::http::Params Struct Reference

Parse and store HTTP query parameters. More...

`#include <http.h>`

Inheritance diagram for wibble::net::http::Params:
[legend]
Collaboration diagram for wibble::net::http::Params:
[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...
Param * | obtain_field (const std::string &name)
| Get a normal fileld during form parsing. More...
FileParam * | obtain_file_field (const std::string &name)
| Get a normal fileld during form parsing. More...
Param * | field (const std::string &name)
| Get a field by name. More...
FileParam * | file_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

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

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

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

## Member Function Documentation

template<typename TYPE >

TYPE* wibble::net::http::Params::add | ( | const std::string & | name | ) |

inline

Universal, automatic add method.

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().

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().

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

Get a field by name.

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

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

Get a file field by name.

References wibble::iterator().

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().

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().

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.

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

Parse parameters from multipart/form-data.

References wibble::Splitter::begin(), wibble::net::mime::Reader::discard_until_boundary(), wibble::Splitter::end(), wibble::Regexp::match(), wibble::net::http::Param::parse(), wibble::net::http::FileParam::read(), wibble::net::mime::Reader::read_headers(), wibble::net::mime::Reader::read_until_boundary(), and wibble::net::http::Request::sock.

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

Parse parameters from HTTP POST input.

References wibble::net::http::Request::discard_input(), wibble::str::fmtf(), wibble::net::http::Request::headers, and wibble::net::http::Request::read_buf().

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

Parse parameters from urlencoded form data.

References wibble::str::Split::begin(), wibble::str::Split::end(), wibble::net::http::Param::parse(), and wibble::str::urldecode().

## Member Data Documentation

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.

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.

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.

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

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

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

Maximum size of POST input data.

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

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

File parameters.

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

- http.h
- http.cpp