fastcgi++
A C++ FastCGI/Web API
Public Member Functions | Public Attributes | Private Member Functions | Private Attributes | List of all members
Fastcgipp::Http::Environment< charT > Struct Template Reference

Data structure of HTTP environment data. More...

#include <fastcgi++/http.hpp>

Public Member Functions

void fill (const char *data, const char *dataEnd)
 Parses FastCGI parameter data into the data structure. More...
 
void fillPostBuffer (const char *start, const char *end)
 Consolidates POST data into a single buffer. More...
 
bool parsePostBuffer ()
 Attempts to parse the POST buffer. More...
 
const std::vector< char > & postBuffer () const
 Get the post buffer. More...
 
void clearPostBuffer ()
 Clear the post buffer. More...
 
 Environment ()
 

Public Attributes

std::basic_string< charT > host
 Hostname of the server. More...
 
std::basic_string< charT > userAgent
 User agent string. More...
 
std::basic_string< charT > acceptContentTypes
 Content types the client accepts. More...
 
std::vector< std::string > acceptLanguages
 Languages the client accepts. More...
 
std::basic_string< charT > acceptCharsets
 Character sets the clients accepts. More...
 
std::basic_string< charT > authorization
 Http authorization string. More...
 
std::basic_string< charT > referer
 Referral URL. More...
 
std::basic_string< charT > contentType
 Content type of data sent from client. More...
 
std::basic_string< charT > root
 HTTP root directory. More...
 
std::basic_string< charT > scriptName
 Filename of script relative to the HTTP root directory. More...
 
RequestMethod requestMethod
 REQUEST_METHOD. More...
 
std::basic_string< charT > requestUri
 REQUEST_URI. More...
 
std::vector< std::basic_string< charT > > pathInfo
 Path information. More...
 
unsigned etag
 The etag the client assumes this document should have. More...
 
unsigned keepAlive
 How many seconds the connection should be kept alive. More...
 
unsigned contentLength
 Length of content to be received from the client (post data) More...
 
Address serverAddress
 IP address of the server. More...
 
Address remoteAddress
 IP address of the client. More...
 
uint16_t serverPort
 TCP port used by the server. More...
 
uint16_t remotePort
 TCP port used by the client. More...
 
std::time_t ifModifiedSince
 Timestamp the client has for this document. More...
 
std::multimap< std::basic_string< charT >, std::basic_string< charT > > cookies
 Container with all url-encoded cookie data. More...
 
std::multimap< std::basic_string< charT >, std::basic_string< charT > > gets
 Container with all url-encoded GET data. More...
 
std::multimap< std::basic_string< charT >, std::basic_string< charT > > posts
 Container of none-file POST data. More...
 
std::multimap< std::basic_string< charT >, File< charT > > files
 Container of file POST data. More...
 

Private Member Functions

void parsePostsMultipart ()
 Parses "multipart/form-data" http post data. More...
 
void parsePostsUrlEncoded ()
 Parses "application/x-www-form-urlencoded" post data. More...
 

Private Attributes

std::vector< char > boundary
 Raw string of characters representing the post boundary. More...
 
std::vector< char > m_postBuffer
 Buffer for processing post data. More...
 

Detailed Description

template<class charT>
struct Fastcgipp::Http::Environment< charT >

Data structure of HTTP environment data.

This structure contains all HTTP environment data for each individual request. The data is processed from FastCGI parameter records.

Template Parameters
charTCharacter type to use for strings
Date
May 3, 2017
Author
Eddie Carle <eddie.nosp@m.@isa.nosp@m.tec.c.nosp@m.a>

Definition at line 251 of file http.hpp.

Constructor & Destructor Documentation

◆ Environment()

template<class charT>
Fastcgipp::Http::Environment< charT >::Environment ( )
inline

Definition at line 385 of file http.hpp.

Member Function Documentation

◆ clearPostBuffer()

template<class charT>
void Fastcgipp::Http::Environment< charT >::clearPostBuffer ( )
inline

Clear the post buffer.

Definition at line 379 of file http.hpp.

References Fastcgipp::Http::Environment< charT >::m_postBuffer.

◆ fill()

template<class charT >
void Fastcgipp::Http::Environment< charT >::fill ( const char *  data,
const char *  dataEnd 
)

Parses FastCGI parameter data into the data structure.

This function will take the body of a FastCGI parameter record and parse the data into the data structure. data should equal the first character of the records body with size being it's content length.

Parameters
[in]dataStart of parameter data
[in]dataEnd1+ the last byte of parameter data

Definition at line 166 of file http.cpp.

References Fastcgipp::Http::atoi(), Fastcgipp::Http::decodeUrlEncoded(), Fastcgipp::Logging::ERROR, Fastcgipp::Http::percentEscapedToRealBytes(), Fastcgipp::Protocol::processParamHeader(), Fastcgipp::Http::requestMethodLabels, and Fastcgipp::Http::vecToString().

◆ fillPostBuffer()

template<class charT >
void Fastcgipp::Http::Environment< charT >::fillPostBuffer ( const char *  start,
const char *  end 
)

Consolidates POST data into a single buffer.

This function will take arbitrarily divided chunks of raw http post data and consolidate them into m_postBuffer.

Parameters
[in]startStart of post data.
[in]end1+ the last byte of post data

Definition at line 398 of file http.cpp.

◆ parsePostBuffer()

template<class charT >
bool Fastcgipp::Http::Environment< charT >::parsePostBuffer ( )

Attempts to parse the POST buffer.

If the content type is recognized, this function will parse the post buffer and return true. If it isn't recognized, it will return false.

Returns
True if successfully parsed. False otherwise.

Definition at line 408 of file http.cpp.

◆ parsePostsMultipart()

template<class charT >
void Fastcgipp::Http::Environment< charT >::parsePostsMultipart ( )
inlineprivate

◆ parsePostsUrlEncoded()

template<class charT >
void Fastcgipp::Http::Environment< charT >::parsePostsUrlEncoded ( )
inlineprivate

Parses "application/x-www-form-urlencoded" post data.

Definition at line 618 of file http.cpp.

References Fastcgipp::Http::decodeUrlEncoded().

◆ postBuffer()

template<class charT>
const std::vector<char>& Fastcgipp::Http::Environment< charT >::postBuffer ( ) const
inline

Get the post buffer.

Definition at line 373 of file http.hpp.

References Fastcgipp::Http::Environment< charT >::m_postBuffer.

Member Data Documentation

◆ acceptCharsets

template<class charT>
std::basic_string<charT> Fastcgipp::Http::Environment< charT >::acceptCharsets

Character sets the clients accepts.

Definition at line 266 of file http.hpp.

◆ acceptContentTypes

template<class charT>
std::basic_string<charT> Fastcgipp::Http::Environment< charT >::acceptContentTypes

Content types the client accepts.

Definition at line 260 of file http.hpp.

◆ acceptLanguages

template<class charT>
std::vector<std::string> Fastcgipp::Http::Environment< charT >::acceptLanguages

Languages the client accepts.

Definition at line 263 of file http.hpp.

◆ authorization

template<class charT>
std::basic_string<charT> Fastcgipp::Http::Environment< charT >::authorization

Http authorization string.

Definition at line 269 of file http.hpp.

◆ boundary

template<class charT>
std::vector<char> Fastcgipp::Http::Environment< charT >::boundary
private

Raw string of characters representing the post boundary.

Definition at line 402 of file http.hpp.

◆ contentLength

template<class charT>
unsigned Fastcgipp::Http::Environment< charT >::contentLength

Length of content to be received from the client (post data)

Definition at line 299 of file http.hpp.

◆ contentType

template<class charT>
std::basic_string<charT> Fastcgipp::Http::Environment< charT >::contentType

Content type of data sent from client.

Definition at line 275 of file http.hpp.

◆ cookies

template<class charT>
std::multimap< std::basic_string<charT>, std::basic_string<charT> > Fastcgipp::Http::Environment< charT >::cookies

Container with all url-encoded cookie data.

Definition at line 319 of file http.hpp.

◆ etag

template<class charT>
unsigned Fastcgipp::Http::Environment< charT >::etag

The etag the client assumes this document should have.

Definition at line 293 of file http.hpp.

◆ files

template<class charT>
std::multimap< std::basic_string<charT>, File<charT> > Fastcgipp::Http::Environment< charT >::files

Container of file POST data.

Definition at line 334 of file http.hpp.

◆ gets

template<class charT>
std::multimap< std::basic_string<charT>, std::basic_string<charT> > Fastcgipp::Http::Environment< charT >::gets

Container with all url-encoded GET data.

Definition at line 324 of file http.hpp.

◆ host

template<class charT>
std::basic_string<charT> Fastcgipp::Http::Environment< charT >::host

Hostname of the server.

Definition at line 254 of file http.hpp.

◆ ifModifiedSince

template<class charT>
std::time_t Fastcgipp::Http::Environment< charT >::ifModifiedSince

Timestamp the client has for this document.

Definition at line 314 of file http.hpp.

◆ keepAlive

template<class charT>
unsigned Fastcgipp::Http::Environment< charT >::keepAlive

How many seconds the connection should be kept alive.

Definition at line 296 of file http.hpp.

◆ m_postBuffer

template<class charT>
std::vector<char> Fastcgipp::Http::Environment< charT >::m_postBuffer
private

Buffer for processing post data.

Definition at line 405 of file http.hpp.

Referenced by Fastcgipp::Http::Environment< charT >::clearPostBuffer(), and Fastcgipp::Http::Environment< charT >::postBuffer().

◆ pathInfo

template<class charT>
std::vector<std::basic_string<charT> > Fastcgipp::Http::Environment< charT >::pathInfo

Path information.

Definition at line 290 of file http.hpp.

◆ posts

template<class charT>
std::multimap< std::basic_string<charT>, std::basic_string<charT> > Fastcgipp::Http::Environment< charT >::posts

Container of none-file POST data.

Definition at line 329 of file http.hpp.

◆ referer

template<class charT>
std::basic_string<charT> Fastcgipp::Http::Environment< charT >::referer

Referral URL.

Definition at line 272 of file http.hpp.

◆ remoteAddress

template<class charT>
Address Fastcgipp::Http::Environment< charT >::remoteAddress

IP address of the client.

Definition at line 305 of file http.hpp.

◆ remotePort

template<class charT>
uint16_t Fastcgipp::Http::Environment< charT >::remotePort

TCP port used by the client.

Definition at line 311 of file http.hpp.

◆ requestMethod

template<class charT>
RequestMethod Fastcgipp::Http::Environment< charT >::requestMethod

REQUEST_METHOD.

Definition at line 284 of file http.hpp.

◆ requestUri

template<class charT>
std::basic_string<charT> Fastcgipp::Http::Environment< charT >::requestUri

REQUEST_URI.

Definition at line 287 of file http.hpp.

◆ root

template<class charT>
std::basic_string<charT> Fastcgipp::Http::Environment< charT >::root

HTTP root directory.

Definition at line 278 of file http.hpp.

◆ scriptName

template<class charT>
std::basic_string<charT> Fastcgipp::Http::Environment< charT >::scriptName

Filename of script relative to the HTTP root directory.

Definition at line 281 of file http.hpp.

◆ serverAddress

template<class charT>
Address Fastcgipp::Http::Environment< charT >::serverAddress

IP address of the server.

Definition at line 302 of file http.hpp.

◆ serverPort

template<class charT>
uint16_t Fastcgipp::Http::Environment< charT >::serverPort

TCP port used by the server.

Definition at line 308 of file http.hpp.

◆ userAgent

template<class charT>
std::basic_string<charT> Fastcgipp::Http::Environment< charT >::userAgent

User agent string.

Definition at line 257 of file http.hpp.


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