29 #ifndef FASTCGIPP_PROTOCOL_HPP 30 #define FASTCGIPP_PROTOCOL_HPP 126 return id.m_socket < socket;
131 return socket <
id.m_socket;
138 using Requests = std::map<RequestId, T, RequestId::Less>;
208 static const size_t size =
sizeof(T);
209 static_assert(
size==2 ||
size==4 ||
size==8,
"Fastcgipp::Protocol::" 210 "BigEndian can only work with types of size 2, 4 or 8.");
227 for(
unsigned int i=0; i<
size; ++i)
228 m_data[i] = static_cast<unsigned char>(
229 0xff & base>>8*(
size-1-i));
260 static T
read(
const unsigned char* source)
269 for(
unsigned int i=0; i<
size; ++i)
270 base |= static_cast<BaseType>(*(source+i))
277 static T
read(
const char* source)
279 return read(reinterpret_cast<const unsigned char*>(source));
420 const char*
const dataEnd,
490 std::copy(name_, name_+NAMELENGTH,
name);
491 std::copy(value_, value_+VALUELENGTH,
value);
uint8_t nameLength
Length in bytes of name.
The body for FastCGI records of type RecordType::END_REQUEST.
uint8_t padding[paddingLength]
Padding data.
Topmost namespace for the fastcgi++ library.
bool operator()(const Socket &socket, const RequestId &id) const
RecordType type
Unknown record type.
const char version[]
Defines the fastcgi++ version.
const ManagementReply< 13, 2 > maxReqsReply
The maximum allowed requests at a time.
RequestId(FcgiId id, const Socket &socket)
Construct from an FcgiId and a Socket.
bool kill() const
Get keep alive value from the record body.
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.
RequestId(const RequestId &x)
uint8_t value[VALUELENGTH]
Value data.
bool operator()(const RequestId &x, const RequestId &y) const
Unsigned< size >::Type BaseType
Underlying unsigned integral type.
const ManagementReply< 15, 1 > mpxsConnsReply
Where or not requests can be multiplexed over a single connections.
ProtocolStatus
Possible statuses a request may declare when complete.
BigEndian< Role > role
Role.
static const int keepConnBit
Flag bit representing the keep alive value.
Header header
Management records header.
const uint16_t badFcgiId
Constant that defines a bad/special FcgiId.
The body for FastCGI records with a RecordType of UNKNOWN_TYPE.
std::true_type is_transparent
unsigned char m_data[size]
The raw data of the big endian integer.
Allows raw storage of types in big endian format.
Get unsigned integral type from size.
BigEndian & operator=(T x)
uint16_t FcgiId
The internal ID of a FastCGI request.
uint8_t valueLength
Length in bytes of value.
Class for representing an OS level I/O socket.
uint8_t reserved[5]
Reserved for future use and body padding.
A unique identifier for each FastCGI request.
BigEndian< int32_t > appStatus
Return value.
const int chunkSize
All FastCGI records will be a multiple of this many bytes.
uint8_t reserved[3]
Reseved for future use and body padding.
uint8_t reserved[7]
Reseved for future use and body padding.
Defines the Message data structure.
We need this uglyness to find ranges based purely on the socket.
static const int paddingLength
For the reply of FastCGI management records.
static T read(const char *source)
Simply casts char to unsigned char.
The body for FastCGI records with a RecordType of BEGIN_REQUEST.
RecordType
Defines the types of records within the FastCGI protocol.
uint8_t name[NAMELENGTH]
Name data.
Socket m_socket
Associated socket.
static T read(const unsigned char *source)
Static function for reading the value out of a data array.
bool operator()(const RequestId &id, const Socket &socket) const
ManagementReply(const char *name_, const char *value_)
Construct the record based on the name data and value data.
FcgiId m_id
Internal FastCGI request ID.
Declares everything for interfaces with OS level sockets.
const ManagementReply< 14, 2 > maxConnsReply
The maximum allowed file descriptors open at a time.
RequestId & operator=(const RequestId &x)
const int version
The version of the FastCGI protocol that this adheres to.
std::map< RequestId, T, RequestId::Less > Requests
A simple associative container that indexes with RequestId.
Role
Defines the possible roles a FastCGI application may play.
ProtocolStatus protocolStatus
Requests Status.