fastcgi++
A C++ FastCGI/Web API
protocol.cpp
Go to the documentation of this file.
1 
10 /*******************************************************************************
11 * Copyright (C) 2017 Eddie Carle [eddie@isatec.ca] *
12 * *
13 * This file is part of fastcgi++. *
14 * *
15 * fastcgi++ is free software: you can redistribute it and/or modify it under *
16 * the terms of the GNU Lesser General Public License as published by the Free *
17 * Software Foundation, either version 3 of the License, or (at your option) *
18 * any later version. *
19 * *
20 * fastcgi++ is distributed in the hope that it will be useful, but WITHOUT ANY *
21 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS *
22 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for *
23 * more details. *
24 * *
25 * You should have received a copy of the GNU Lesser General Public License *
26 * along with fastcgi++. If not, see <http://www.gnu.org/licenses/>. *
27 *******************************************************************************/
28 
29 #include "fastcgi++/protocol.hpp"
30 #include "fastcgi++/config.hpp"
31 
33  const char* data,
34  const char* const dataEnd,
35  const char*& name,
36  const char*& value,
37  const char*& end)
38 {
39  size_t nameSize;
40  size_t valueSize;
41 
42  if(data>=dataEnd)
43  return false;
44  if(*data & 0x80)
45  {
46  const auto size=data;
47  data += sizeof(uint32_t);
48 
49  if(data>dataEnd)
50  return false;
51 
52  nameSize=BigEndian<uint32_t>::read(&*size) & 0x7fffffff;
53  }
54  else
55  nameSize=*data++;
56 
57  if(data>=dataEnd)
58  return false;
59  if(*data & 0x80)
60  {
61  const auto size=data;
62  data += sizeof(uint32_t);
63 
64  if(data>dataEnd)
65  return false;
66 
67  valueSize=BigEndian<uint32_t>::read(&*size) & 0x7fffffff;
68  }
69  else
70  valueSize=*data++;
71 
72  name = data;
73  value = name+nameSize;
74  end = value+valueSize;
75 
76  if(end>dataEnd)
77  return false;
78  else
79  return true;
80 }
81 
83 Fastcgipp::Protocol::maxConnsReply("FCGI_MAX_CONNS", "10");
84 
86 Fastcgipp::Protocol::maxReqsReply("FCGI_MAX_REQS", "50");
87 
89 Fastcgipp::Protocol::mpxsConnsReply("FCGI_MPXS_CONNS", "1");
90 
const char version[]
Defines the fastcgi++ version.
Definition: protocol.cpp:91
const ManagementReply< 13, 2 > maxReqsReply
The maximum allowed requests at a time.
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.
Definition: protocol.cpp:32
const ManagementReply< 15, 1 > mpxsConnsReply
Where or not requests can be multiplexed over a single connections.
#define FASTCGIPP_VERSION
Definition: config.hpp:4
Declares everything for relating to the FastCGI protocol itself.
Allows raw storage of types in big endian format.
Definition: protocol.hpp:205
For the reply of FastCGI management records.
Definition: protocol.hpp:444
const ManagementReply< 14, 2 > maxConnsReply
The maximum allowed file descriptors open at a time.