42 header.
type = Protocol::RecordType::END_REQUEST;
52 m_send(m_id.m_socket, std::move(record), m_kill);
58 std::unique_lock<std::mutex> lock(m_messagesMutex);
59 while(!m_messages.empty())
61 Message message = std::move(m_messages.front());
72 if(header.
type == Protocol::RecordType::ABORT_REQUEST)
78 if(header.
type != m_state)
80 WARNING_LOG(
"Records received out of order from web server")
87 case Protocol::RecordType::PARAMS:
90 role()==Protocol::Role::RESPONDER
91 || role()==Protocol::Role::AUTHORIZER))
93 m_status = Protocol::ProtocolStatus::UNKNOWN_ROLE;
101 if(environment().contentLength > m_maxPostSize)
103 bigPostErrorHandler();
106 m_state = Protocol::RecordType::IN;
110 m_environment.fill(body, bodyEnd);
115 case Protocol::RecordType::IN:
119 if(!inProcessor() && !m_environment.parsePostBuffer())
126 m_environment.clearPostBuffer();
127 m_state = Protocol::RecordType::OUT;
131 if(m_environment.postBuffer().size()+(bodyEnd-body)
132 > environment().contentLength)
134 bigPostErrorHandler();
138 m_environment.fillPostBuffer(body, bodyEnd);
146 ERROR_LOG(
"Our request is in a weird state.")
153 m_message = std::move(message);
168 "Status: 500 Internal Server Error\n"\
169 "Content-Type: text/html; charset=utf-8\r\n\r\n"\
173 "<title>500 Internal Server Error</title>"\
176 "<h1>500 Internal Server Error</h1>"\
186 "Status: 413 Request Entity Too Large\n"\
187 "Content-Type: text/html; charset=utf-8\r\n\r\n"\
191 "<title>413 Request Entity Too Large</title>"\
194 "<h1>413 Request Entity Too Large</h1>"\
205 const std::function<
void(
const Socket&,
Block&&,
bool)> send,
206 const std::function<
void(
Message)> callback)
208 using namespace std::placeholders;
216 m_outStreamBuffer.configure(
218 Protocol::RecordType::OUT,
219 std::bind(send, _1, _2,
false));
220 m_errStreamBuffer.configure(
222 Protocol::RecordType::ERR,
223 std::bind(send, _1, _2,
false));
227 const std::vector<std::string>& locales)
231 for(
const std::string& language: environment().acceptLanguages)
233 if(language.size() <= 5)
235 const auto it = std::find_if(
238 [&language] (
const std::string& locale)
246 if(it != locales.cend())
248 index = it-locales.cbegin();
258 const std::string& locale)
262 out.imbue(std::locale(locale+codepage()));
267 out.imbue(std::locale(
"C"));
The body for FastCGI records of type RecordType::END_REQUEST.
Topmost namespace for the fastcgi++ library.
const char version[]
Defines the fastcgi++ version.
std::unique_lock< std::mutex > handler()
Request Handler.
void header(Level level)
Send a log header to logstream.
Data structure used to pass messages to requests.
virtual void bigPostErrorHandler()
Called when too much post data is recieved.
void configure(const Protocol::RequestId &id, const Protocol::Role &role, bool kill, const std::function< void(const Socket &, Block &&, bool)> send, const std::function< void(Message)> callback)
Configures the request with the data it needs.
Class for representing an OS level I/O socket.
A unique identifier for each FastCGI request.
BigEndian< int32_t > appStatus
Return value.
unsigned pickLocale(const std::vector< std::string > &locales)
Pick a locale.
Block data
The raw data being passed along with the message.
void complete()
Generates an END_REQUEST FastCGI record.
Declares the Request class.
virtual void errorHandler()
Called when a processing error occurs.
void setLocale(const std::string &locale)
Set the output stream's locale.
#define ERROR_LOG(data)
Log any "errors" that can be recovered from.
Declares the Fastcgipp debugging/logging facilities.
const char * codepage() const
Codepage.
Role
Defines the possible roles a FastCGI application may play.
ProtocolStatus protocolStatus
Requests Status.
Data structure to hold a block of raw data.
int type
Type of message. A 0 means FastCGI record. Anything else is open.
#define WARNING_LOG(data)
Log any externally caused "errors".
char * begin()
Pointer to the first element.