libUTL++
FastCGIserver.h
1 #pragma once
2 
4 
5 #include <libutl/BufferedStream.h>
6 #include <libutl/MemStream.h>
7 #include <libutl/NetServer.h>
8 #include <libutl/StringVars.h>
9 
11 
12 UTL_NS_BEGIN;
13 
15 
16 class FCGI_record;
17 class NetServerClient;
18 
20 // FastCGIserver ///////////////////////////////////////////////////////////////////////////////////
22 
30 
32 class FastCGIserver : public NetServer
33 {
36 
37 public:
38  FastCGIserver(size_t maxClients, size_t maxPaused, size_t clientsPerThread = 1)
39  : NetServer(maxClients, maxPaused, clientsPerThread)
40  {
41  }
42 
43 protected:
44  virtual void onClientConnect(NetServerClient* client);
45 
46 private:
47  virtual void clientReadMsg(NetServerClient* client);
48 
49  virtual void vrespond(NetServerClient* client, StringVars& params, MemStream& input) = 0;
50 
51  void respond(NetServerClient* client, uint16_t requestId, bool keepConn);
52 
53  void readParams(StringVars& params, MemStream& paramsData);
54 };
55 
57 // FastCGIserver ///////////////////////////////////////////////////////////////////////////////////
59 
60 class FastCGIstreamWriter : public BufferedStream
61 {
62  UTL_CLASS_DECL(FastCGIstreamWriter, BufferedStream);
63 
64 public:
65  FastCGIstreamWriter(Stream* stream, bool streamOwner = true);
66 
67  void setRequestId(uint16_t requestId);
68 
69 private:
70  void init();
71  void deInit();
72 
73  virtual void underflow();
74 
75  virtual void overflow();
76 
77 private:
78  FCGI_record* _rec;
79 };
80 
82 
83 UTL_NS_END;
#define UTL_CLASS_DEFID
Default init() and deInit() (which are merely place-holders).
Definition: macros.h:532
void deInit()
De-initialize UTL++.
#define UTL_CLASS_DECL(DC, BC)
Declaration of standard UTL++ functionality for a non-template class.
Definition: macros.h:688
Client connection to NetServer.
Memory stream.
Definition: MemStream.h:40
#define UTL_CLASS_DECL_ABC(DC, BC)
Declaration of standard UTL++ functionality for an abstract base class (ABC).
Definition: macros.h:650
Stream I/O abstraction.
Definition: Stream.h:68
unsigned short uint16_t
Unsigned 16-bit integer.
Definition: types.h:101
Buffered stream.
Abstract base for multi-threaded network server.
A set of (variable-name, variable-value) tuples.
Definition: StringVars.h:28
void init()
Initialize UTL++.
Abstract base for a FastCGI server (responder).
Definition: FastCGIserver.h:32