NAWA 0.9
Web Application Framework for C++
nawa::request::Post Class Reference

#include <nawa/request/GPC/ext/Post.h>

Inherits nawa::request::GPC.

Public Member Functions

 ~Post () override
 
 Post (RequestInitContainer const &requestInit)
 
 operator bool () const override
 
std::shared_ptr< std::string const > getRaw () const
 
std::string getContentType () const
 
bool hasFiles () const
 
std::optional< FilegetFile (std::string const &key) const
 
std::vector< FilegetFileVector (std::string const &key) const
 
size_t countFiles (std::string const &key) const
 
std::unordered_multimap< std::string, File > const & getFileMultimap () const
 
- Public Member Functions inherited from nawa::request::GPC
virtual ~GPC ()
 
 GPC (RequestInitContainer const &requestInit, Source source)
 
std::string operator[] (std::string const &gpcVar) const
 
std::vector< std::string > getVector (std::string const &gpcVar) const
 
size_t count (std::string const &gpcVar) const
 
std::unordered_multimap< std::string, std::string > const & getMultimap () const
 
std::unordered_multimap< std::string, std::string >::const_iterator begin () const
 
std::unordered_multimap< std::string, std::string >::const_iterator end () const
 

Additional Inherited Members

- Public Types inherited from nawa::request::GPC
enum class  Source { GET , POST , COOKIE }
 

Detailed Description

Specialized accessor for POST that also allows accessing files (and in future, maybe, the raw POST data).

Definition at line 36 of file Post.h.

Constructor & Destructor Documentation

◆ ~Post()

nawa::request::Post::~Post ( )
override

◆ Post()

request::Post::Post ( RequestInitContainer const &  requestInit)
explicit

Definition at line 42 of file Post.cpp.

Member Function Documentation

◆ operator bool()

request::Post::operator bool ( ) const
explicitoverridevirtual

Shortcut to check for the existence of POST values (including files).

Returns
True if POST values are available.

Reimplemented from nawa::request::GPC.

Definition at line 46 of file Post.cpp.

◆ getRaw()

shared_ptr< std::string const > request::Post::getRaw ( ) const

Get the raw POST data (availability may depend on the raw_access setting in the config).

Returns
Shared pointer to a string containing the raw POST data if available, otherwise the shared_ptr does not contain an object.

Definition at line 50 of file Post.cpp.

◆ getContentType()

std::string request::Post::getContentType ( ) const

Get the POST content type as submitted by the browser

Returns
String containing the POST content type

Definition at line 54 of file Post.cpp.

◆ hasFiles()

bool request::Post::hasFiles ( ) const

Check whether files have been uploaded via POST.

Returns
True if files have been uploaded via POST.

Definition at line 58 of file Post.cpp.

◆ getFile()

std::optional< File > request::Post::getFile ( std::string const &  key) const

Get a file submitted via POST. If the query contains more than one POST file of the same name, only one of them (usually the first definition) will be returned. For accessing all definitions, please use getFileVector(). Complexity is logarithmic, so if you want to access a value multiple times, saving it in a variable is a good idea.

Parameters
keyKey of the POST file.
Returns
The file if available. Nullopt if no file with the given key has been submitted.

Definition at line 62 of file Post.cpp.

◆ getFileVector()

std::vector< File > request::Post::getFileVector ( std::string const &  key) const

Get all POST files with the given key.

Parameters
keyKey of the files.
Returns
Vector of files. Empty if no file with the given key exists.

Definition at line 69 of file Post.cpp.

◆ countFiles()

size_t request::Post::countFiles ( std::string const &  key) const

Get the number of submitted POST files with the given key.

Parameters
keyKey of the file.
Returns
Number of occurrences.

Definition at line 78 of file Post.cpp.

◆ getFileMultimap()

std::unordered_multimap< std::string, File > const & request::Post::getFileMultimap ( ) const

Get a reference to the POST file multimap.

Returns
Reference to the multimap.

Definition at line 82 of file Post.cpp.


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