fastcgi++
A C++ FastCGI/Web API
Classes | Typedefs | Enumerations | Functions | Variables
Fastcgipp::Protocol Namespace Reference

Defines aspects of the FastCGI Protocol. More...

Classes

struct  BeginRequest
 The body for FastCGI records with a RecordType of BEGIN_REQUEST. More...
 
class  BigEndian
 Allows raw storage of types in big endian format. More...
 
struct  EndRequest
 The body for FastCGI records of type RecordType::END_REQUEST. More...
 
struct  Header
 Data structure used as the header for FastCGI records. More...
 
struct  ManagementReply
 For the reply of FastCGI management records. More...
 
struct  RequestId
 A unique identifier for each FastCGI request. More...
 
struct  UnknownType
 The body for FastCGI records with a RecordType of UNKNOWN_TYPE. More...
 
struct  Unsigned
 Get unsigned integral type from size. More...
 
struct  Unsigned< 2 >
 
struct  Unsigned< 4 >
 
struct  Unsigned< 8 >
 

Typedefs

typedef uint16_t FcgiId
 The internal ID of a FastCGI request. More...
 
template<class T >
using Requests = std::map< RequestId, T, RequestId::Less >
 A simple associative container that indexes with RequestId. More...
 

Enumerations

enum  RecordType : uint8_t {
  RecordType::BEGIN_REQUEST =1, RecordType::ABORT_REQUEST =2, RecordType::END_REQUEST =3, RecordType::PARAMS =4,
  RecordType::IN =5, RecordType::OUT =6, RecordType::ERR =7, RecordType::DATA =8,
  RecordType::GET_VALUES =9, RecordType::GET_VALUES_RESULT =10, RecordType::UNKNOWN_TYPE =11
}
 Defines the types of records within the FastCGI protocol. More...
 
enum  Role : uint16_t { Role::RESPONDER =1, Role::AUTHORIZER =2, Role::FILTER =3 }
 Defines the possible roles a FastCGI application may play. More...
 
enum  ProtocolStatus : uint8_t { ProtocolStatus::REQUEST_COMPLETE =0, ProtocolStatus::CANT_MPX_CONN =1, ProtocolStatus::OVERLOADED =2, ProtocolStatus::UNKNOWN_ROLE =3 }
 Possible statuses a request may declare when complete. More...
 

Functions

bool processParamHeader (const char *data, const char *const dataEnd, const char *&name, const char *&value, const char *&end)
 Process the body of a FastCGI record of type RecordType::PARAMS. More...
 

Variables

const uint16_t badFcgiId = 0xffffUL
 Constant that defines a bad/special FcgiId. More...
 
const int version =1
 The version of the FastCGI protocol that this adheres to. More...
 
const int chunkSize =8
 All FastCGI records will be a multiple of this many bytes. More...
 
const ManagementReply< 14, 2 > maxConnsReply
 The maximum allowed file descriptors open at a time. More...
 
const ManagementReply< 13, 2 > maxReqsReply
 The maximum allowed requests at a time. More...
 
const ManagementReply< 15, 1 > mpxsConnsReply
 Where or not requests can be multiplexed over a single connections. More...
 

Detailed Description

Defines aspects of the FastCGI Protocol.

The Protocol namespace defines the data structures and constants used by the FastCGI protocol version 1. All data has been modelled after the official FastCGI protocol specification located at http://www.fastcgi.com/devkit/doc/fcgi-spec.html

Typedef Documentation

typedef uint16_t Fastcgipp::Protocol::FcgiId

The internal ID of a FastCGI request.

Definition at line 57 of file protocol.hpp.

template<class T >
using Fastcgipp::Protocol::Requests = typedef std::map<RequestId, T, RequestId::Less>

A simple associative container that indexes with RequestId.

Definition at line 138 of file protocol.hpp.

Enumeration Type Documentation

enum Fastcgipp::Protocol::ProtocolStatus : uint8_t
strong

Possible statuses a request may declare when complete.

Enumerator
REQUEST_COMPLETE 
CANT_MPX_CONN 
OVERLOADED 
UNKNOWN_ROLE 

Definition at line 171 of file protocol.hpp.

enum Fastcgipp::Protocol::RecordType : uint8_t
strong

Defines the types of records within the FastCGI protocol.

Enumerator
BEGIN_REQUEST 
ABORT_REQUEST 
END_REQUEST 
PARAMS 
IN 
OUT 
ERR 
DATA 
GET_VALUES 
GET_VALUES_RESULT 
UNKNOWN_TYPE 

Definition at line 141 of file protocol.hpp.

enum Fastcgipp::Protocol::Role : uint16_t
strong

Defines the possible roles a FastCGI application may play.

Enumerator
RESPONDER 
AUTHORIZER 
FILTER 

Definition at line 163 of file protocol.hpp.

Function Documentation

bool Fastcgipp::Protocol::processParamHeader ( const char *  data,
const char *const  dataEnd,
const char *&  name,
const char *&  value,
const char *&  end 
)

Process the body of a FastCGI record of type RecordType::PARAMS.

Takes the body of a FastCGI record of type RecordType::PARAMS and parses it. You end up with iterators giving you both the name and value of the parameter.

The return value indicates whether or not there is actually sufficient data in the array to to read both the sizes and the values themselves.

Parameters
[in]dataIterator to the first byte of the record body
[in]dataEndIterator to 1+ the last byte of the record body
[out]nameReference to an iterator that will be pointed to the first byte of the parameter name. If false is returned this value is undefined.
[out]valueReference to an iterator that will be pointed to the first byte of the parameter value. If false is returned this value is undefined.
[out]endReference to an iterator that will be pointed to 1+ the last byte of the parameter value. If false is returned this value is undefined.
Returns
False if out of bounds. True otherwise.

Definition at line 32 of file protocol.cpp.

References maxConnsReply, maxReqsReply, and mpxsConnsReply.

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

Variable Documentation

const uint16_t Fastcgipp::Protocol::badFcgiId = 0xffffUL

Constant that defines a bad/special FcgiId.

Definition at line 60 of file protocol.hpp.

Referenced by Fastcgipp::Transceiver::cleanupSocket(), and Fastcgipp::Manager_base::push().

const int Fastcgipp::Protocol::chunkSize =8

All FastCGI records will be a multiple of this many bytes.

Definition at line 160 of file protocol.hpp.

Referenced by Fastcgipp::FcgiStreambuf< charT, traits >::dump(), and Fastcgipp::FcgiStreambuf< charT, traits >::emptyBuffer().

const Fastcgipp::Protocol::ManagementReply< 14, 2 > Fastcgipp::Protocol::maxConnsReply
const Fastcgipp::Protocol::ManagementReply< 13, 2 > Fastcgipp::Protocol::maxReqsReply
const Fastcgipp::Protocol::ManagementReply< 15, 1 > Fastcgipp::Protocol::mpxsConnsReply
const int Fastcgipp::Protocol::version =1