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.");
216 unsigned char m_data[size];
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));
326 static const int keepConnBit = 1;
340 return !(flags & keepConnBit);
420 const char*
const dataEnd,
447 static const int paddingLength = (chunkSize-1)-(
464 uint8_t name[NAMELENGTH];
467 uint8_t value[VALUELENGTH];
470 uint8_t padding[paddingLength];
487 nameLength(NAMELENGTH),
488 valueLength(VALUELENGTH)
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.
bool operator()(const RequestId &id, const Socket &socket) const
Topmost namespace for the fastcgi++ library.
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 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)
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.
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
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.
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.
Defines the Message data structure.
We need this uglyness to find ranges based purely on the socket.
bool operator()(const Socket &socket, const RequestId &id) const
For the reply of FastCGI management records.
static T read(const char *source)
Simply casts char to unsigned char.
bool kill() const
Get keep alive value from the record body.
The body for FastCGI records with a RecordType of BEGIN_REQUEST.
RecordType
Defines the types of records within the FastCGI protocol.
Socket m_socket
Associated socket.
static T read(const unsigned char *source)
Static function for reading the value out of a data array.
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.
bool operator()(const RequestId &x, const RequestId &y) const
Role
Defines the possible roles a FastCGI application may play.
ProtocolStatus protocolStatus
Requests Status.