fastcgi++
Classes | Enumerations | Functions | Variables
Fastcgipp::Http Namespace Reference

Defines classes and function relating to the http protocol. More...

Classes

struct  Post
 Holds a piece of HTTP post data. More...
class  Address
 Efficiently stores IPv6 addresses. More...
struct  Environment
 Data structure of HTTP environment data. More...
class  SessionId
 Defines ID values for HTTP sessions. More...
class  Sessions
 Container for HTTP sessions. More...

Enumerations

enum  RequestMethod {
  HTTP_METHOD_ERROR, HTTP_METHOD_HEAD, HTTP_METHOD_GET, HTTP_METHOD_POST,
  HTTP_METHOD_PUT, HTTP_METHOD_DELETE, HTTP_METHOD_TRACE, HTTP_METHOD_OPTIONS,
  HTTP_METHOD_CONNECT
}
 The HTTP request method as an enumeration. More...

Functions

template<class charT , class Traits >
std::basic_ostream< charT,
Traits > & 
operator<< (std::basic_ostream< charT, Traits > &os, const RequestMethod requestMethod)
template<class charT , class Traits >
std::basic_ostream< charT,
Traits > & 
operator<< (std::basic_ostream< charT, Traits > &os, const Address &address)
 Address stream insertion operation.
template<class charT , class Traits >
std::basic_istream< charT,
Traits > & 
operator>> (std::basic_istream< charT, Traits > &is, Address &address)
 Address stream extractor operation.
void charToString (const char *data, size_t size, std::wstring &string)
 Convert a char string to a std::wstring.
void charToString (const char *data, size_t size, std::string &string)
 Convert a char string to a std::string.
int atoi (const char *start, const char *end)
 Convert a char string to an integer.
template<class charT >
void decodeUrlEncoded (const char *data, size_t size, std::map< std::basic_string< charT >, std::basic_string< charT > > &output, const char fieldSeperator='&')
 Decodes a url-encoded string into a container.
size_t percentEscapedToRealBytes (const char *source, char *destination, size_t size)
 Convert a string with percent escaped byte values to their actual values.
template<class In , class Out >
void base64Encode (In start, In end, Out destination)
 Convert a binary container of data to a Base64 encoded container.
template<class In , class Out >
Out base64Decode (In start, In end, Out destination)
 Convert a Base64 encoded container to a binary container.
template<class charT , class Traits >
std::basic_ostream< charT,
Traits > & 
operator<< (std::basic_ostream< charT, Traits > &os, const SessionId &x)
 Output the ID data in base64 encoding.

Variables

const char * requestMethodLabels []
const char base64Characters [] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
 List of characters in order for Base64 encoding.

Detailed Description

Defines classes and function relating to the http protocol.


Enumeration Type Documentation

The HTTP request method as an enumeration.

Enumerator:
HTTP_METHOD_ERROR 
HTTP_METHOD_HEAD 
HTTP_METHOD_GET 
HTTP_METHOD_POST 
HTTP_METHOD_PUT 
HTTP_METHOD_DELETE 
HTTP_METHOD_TRACE 
HTTP_METHOD_OPTIONS 
HTTP_METHOD_CONNECT 

Definition at line 95 of file http.hpp.


Function Documentation

int Fastcgipp::Http::atoi ( const char *  start,
const char *  end 
)

Convert a char string to an integer.

This function is very similar to std::atoi() except that it takes start/end values of a non null terminated char string instead of a null terminated string. The first character must be either a number or a minus sign (-). As soon as the end is reached or a non numerical character is reached, the result is tallied and returned.

Parameters:
[in]startPointer to the first byte in the string
[in]endPointer to the last byte in the string + 1
Returns:
Integer value represented by the string

Definition at line 52 of file http.cpp.

Referenced by Fastcgipp::Http::Address::assign(), Fastcgipp::Http::Environment< charT >::fill(), and ASql::MySQL::Statement::init().

template<class In , class Out >
Out Fastcgipp::Http::base64Decode ( In  start,
In  end,
Out  destination 
)

Convert a Base64 encoded container to a binary container.

If destination is a fixed size container, it should have a size of at least (end-start)*3/4 not including null terminators if used.

Parameters:
[in]startIterator to start of Base64 data.
[in]endIterator to end of Base64 data.
[out]destinationIterator to start of binary destination.
Template Parameters:
InInput iterator type. Should be dereferenced to type char.
OutOutput iterator type. Should be dereferenced to type char.
Returns:
Iterator to last position written+1 (The normal end() iterator). If the return value equals destination, an error occurred.

Definition at line 574 of file http.hpp.

Referenced by Fastcgipp::Http::SessionId::operator=().

template<class In , class Out >
void Fastcgipp::Http::base64Encode ( In  start,
In  end,
Out  destination 
)

Convert a binary container of data to a Base64 encoded container.

If destination is a fixed size container, it should have a size of at least ((end-start-1)/3 + 1)*4 not including null terminators if used and assuming integer arithmetic.

Parameters:
[in]startIterator to start of binary data.
[in]endIterator to end of binary data.
[out]destinationIterator to start of Base64 destination.
Template Parameters:
InInput iterator type. Should be dereferenced to type char.
OutOutput iterator type. Should be dereferenced to type char.

Definition at line 617 of file http.hpp.

References base64Characters.

Referenced by operator<<().

void Fastcgipp::Http::charToString ( const char *  data,
size_t  size,
std::wstring &  string 
)

Convert a char string to a std::wstring.

Parameters:
[in]dataFirst byte in char string
[in]sizeSize in bytes of the string (no null terminator)
[out]stringReference to the wstring that should be modified
Returns:
Returns true on success, false on failure

Definition at line 29 of file http.cpp.

Referenced by decodeUrlEncoded(), Fastcgipp::Http::Environment< charT >::fill(), Fastcgipp::Http::Environment< charT >::parsePostsMultipart(), and Fastcgipp::Http::Environment< charT >::parsePostsUrlEncoded().

void Fastcgipp::Http::charToString ( const char *  data,
size_t  size,
std::string &  string 
)
inline

Convert a char string to a std::string.

Parameters:
[in]dataFirst byte in char string
[in]sizeSize in bytes of the string (no null terminator)
[out]stringReference to the string that should be modified
Returns:
Returns true on success, false on failure

Definition at line 352 of file http.hpp.

template<class charT >
void Fastcgipp::Http::decodeUrlEncoded ( const char *  data,
size_t  size,
std::map< std::basic_string< charT >, std::basic_string< charT > > &  output,
const char  fieldSeperator = '&' 
)

Decodes a url-encoded string into a container.

Parameters:
[in]dataData to decode
[in]sizeSize of data to decode
[out]outputContainer to output data into
Returns:
Returns false if the name isn't found. True otherwise.

Definition at line 484 of file http.cpp.

References charToString(), and percentEscapedToRealBytes().

Referenced by Fastcgipp::Http::Environment< charT >::fill().

template<class charT , class Traits >
std::basic_ostream<charT, Traits>& Fastcgipp::Http::operator<< ( std::basic_ostream< charT, Traits > &  os,
const RequestMethod  requestMethod 
)
inline

Definition at line 108 of file http.hpp.

References requestMethodLabels.

template<class charT , class Traits >
std::basic_ostream< charT, Traits > & Fastcgipp::Http::operator<< ( std::basic_ostream< charT, Traits > &  os,
const Address &  address 
)

Address stream insertion operation.

This stream inserter obeys all stream manipulators regarding alignment, field width and numerical base.

Definition at line 717 of file http.cpp.

References Fastcgipp::Protocol::readBigEndian().

template<class charT , class Traits >
std::basic_ostream<charT, Traits>& Fastcgipp::Http::operator<< ( std::basic_ostream< charT, Traits > &  os,
const SessionId &  x 
)

Output the ID data in base64 encoding.

Definition at line 497 of file http.hpp.

References base64Encode(), and Fastcgipp::Http::SessionId::size.

template<class charT , class Traits >
std::basic_istream< charT, Traits > & Fastcgipp::Http::operator>> ( std::basic_istream< charT, Traits > &  is,
Address &  address 
)

Address stream extractor operation.

In order for this to work the string must represent either an IPv4 address in standard textual decimal form (127.0.0.1) or an IPv6 in standard form.

Definition at line 854 of file http.cpp.

size_t Fastcgipp::Http::percentEscapedToRealBytes ( const char *  source,
char *  destination,
size_t  size 
)

Convert a string with percent escaped byte values to their actual values.

Since converting a percent escaped string to actual values can only make it shorter, it is safe to assume that the return value will always be smaller than size. It is thereby a safe move to make the destination block of memory the same size as the source.

Parameters:
[in]sourcePointer to the first character in the percent escaped string
[in]sizeSize in bytes of the data pointed to by source (no null termination)
[out]destinationPointer to the section of memory to write the converted string to
Returns:
Actual size of the new string

Definition at line 67 of file http.cpp.

Referenced by decodeUrlEncoded(), Fastcgipp::Http::Environment< charT >::fill(), and Fastcgipp::Http::Environment< charT >::parsePostsUrlEncoded().


Variable Documentation

const char Fastcgipp::Http::base64Characters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"

List of characters in order for Base64 encoding.

Definition at line 523 of file http.cpp.

Referenced by base64Encode().

const char * Fastcgipp::Http::requestMethodLabels
Initial value:
{
"ERROR",
"HEAD",
"GET",
"POST",
"PUT",
"DELETE",
"TRACE",
"OPTIONS",
"CONNECT"
}

Definition at line 524 of file http.cpp.

Referenced by Fastcgipp::Http::Environment< charT >::fill(), and operator<<().