aboutsummaryrefslogtreecommitdiff
path: root/src/experimental/fastcgi.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/experimental/fastcgi.h')
-rw-r--r--src/experimental/fastcgi.h224
1 files changed, 112 insertions, 112 deletions
diff --git a/src/experimental/fastcgi.h b/src/experimental/fastcgi.h
index 63d975f..50b10f5 100644
--- a/src/experimental/fastcgi.h
+++ b/src/experimental/fastcgi.h
@@ -16,118 +16,118 @@
16 16
17namespace Bu 17namespace Bu
18{ 18{
19 class Stream; 19 class Stream;
20 20
21 class FastCgi 21 class FastCgi
22 { 22 {
23 public: 23 public:
24 FastCgi( int iPort ); 24 FastCgi( int iPort );
25 FastCgi(); 25 FastCgi();
26 virtual ~FastCgi(); 26 virtual ~FastCgi();
27 27
28 static bool isEmbedded(); 28 static bool isEmbedded();
29 29
30 typedef Bu::Hash<Bu::String, Bu::String> StrHash; 30 typedef Bu::Hash<Bu::String, Bu::String> StrHash;
31 enum RequestType 31 enum RequestType
32 { 32 {
33 typeBeginRequest = 1, 33 typeBeginRequest = 1,
34 typeAbortRequest = 2, 34 typeAbortRequest = 2,
35 typeEndRequest = 3, 35 typeEndRequest = 3,
36 typeParams = 4, 36 typeParams = 4,
37 typeStdIn = 5, 37 typeStdIn = 5,
38 typeStdOut = 6, 38 typeStdOut = 6,
39 typeStdErr = 7, 39 typeStdErr = 7,
40 typeData = 8, 40 typeData = 8,
41 typeGetValues = 9, 41 typeGetValues = 9,
42 typeGetValuesResult = 10 42 typeGetValuesResult = 10
43 }; 43 };
44 44
45 enum Role 45 enum Role
46 { 46 {
47 roleResponder = 1, 47 roleResponder = 1,
48 roleAuthorizer = 2, 48 roleAuthorizer = 2,
49 roleFilter = 3 49 roleFilter = 3
50 }; 50 };
51 51
52 enum Flags 52 enum Flags
53 { 53 {
54 flagsKeepConn = 1 54 flagsKeepConn = 1
55 }; 55 };
56 56
57 enum Status 57 enum Status
58 { 58 {
59 statusRequestComplete = 0, 59 statusRequestComplete = 0,
60 statusCantMpxConn = 1, 60 statusCantMpxConn = 1,
61 statusOverloaded = 2, 61 statusOverloaded = 2,
62 statusUnknownRole = 3 62 statusUnknownRole = 3
63 }; 63 };
64 64
65 typedef struct { 65 typedef struct {
66 uint8_t uVersion; 66 uint8_t uVersion;
67 uint8_t uType; 67 uint8_t uType;
68 uint16_t uRequestId; 68 uint16_t uRequestId;
69 uint16_t uContentLength; 69 uint16_t uContentLength;
70 uint8_t uPaddingLength; 70 uint8_t uPaddingLength;
71 uint8_t uReserved; 71 uint8_t uReserved;
72 } Record; 72 } Record;
73 73
74 typedef struct { 74 typedef struct {
75 uint16_t uRole; 75 uint16_t uRole;
76 uint8_t uFlags; 76 uint8_t uFlags;
77 uint8_t reserved[5]; 77 uint8_t reserved[5];
78 } BeginRequestBody; 78 } BeginRequestBody;
79 79
80 typedef struct { 80 typedef struct {
81 uint32_t uStatus; 81 uint32_t uStatus;
82 uint8_t uProtocolStatus; 82 uint8_t uProtocolStatus;
83 uint8_t reserved[3]; 83 uint8_t reserved[3];
84 } EndRequestBody; 84 } EndRequestBody;
85 85
86 typedef struct Channel { 86 typedef struct Channel {
87 Channel() : uFlags( 0 ) { } 87 Channel() : uFlags( 0 ) { }
88 StrHash hParams; 88 StrHash hParams;
89 Bu::String sStdIn; 89 Bu::String sStdIn;
90 Bu::String sData; 90 Bu::String sData;
91 uint8_t uFlags; 91 uint8_t uFlags;
92 } Channel; 92 } Channel;
93 93
94 enum ChannelFlags 94 enum ChannelFlags
95 { 95 {
96 chflgParamsDone = 0x01, 96 chflgParamsDone = 0x01,
97 chflgStdInDone = 0x02, 97 chflgStdInDone = 0x02,
98 chflgDataDone = 0x04, 98 chflgDataDone = 0x04,
99 99
100 chflgAllDone = 0x03 100 chflgAllDone = 0x03
101 }; 101 };
102 102
103 virtual void run(); 103 virtual void run();
104 104
105 void stopRunning() { bRunning = false; } 105 void stopRunning() { bRunning = false; }
106 106
107 virtual void onInit() { }; 107 virtual void onInit() { };
108 virtual int onRequest( const StrHash &hParams, 108 virtual int onRequest( const StrHash &hParams,
109 const Bu::String &sStdIn, Bu::Stream &sStdOut, 109 const Bu::String &sStdIn, Bu::Stream &sStdOut,
110 Bu::Stream &sStdErr )=0; 110 Bu::Stream &sStdErr )=0;
111 virtual void onUninit() { }; 111 virtual void onUninit() { };
112 112
113 private: 113 private:
114 void read( Bu::TcpSocket &s, Record &r ); 114 void read( Bu::TcpSocket &s, Record &r );
115 void read( Bu::TcpSocket &s, BeginRequestBody &b ); 115 void read( Bu::TcpSocket &s, BeginRequestBody &b );
116 uint32_t readLen( Bu::TcpSocket &s, uint16_t &uUsed ); 116 uint32_t readLen( Bu::TcpSocket &s, uint16_t &uUsed );
117 void readPair( Bu::TcpSocket &s, StrHash &hParams, uint16_t &uUsed ); 117 void readPair( Bu::TcpSocket &s, StrHash &hParams, uint16_t &uUsed );
118 118
119 void write( Bu::TcpSocket &s, Record r ); 119 void write( Bu::TcpSocket &s, Record r );
120 void write( Bu::TcpSocket &s, EndRequestBody b ); 120 void write( Bu::TcpSocket &s, EndRequestBody b );
121 121
122 bool hasChannel( int iChan ); 122 bool hasChannel( int iChan );
123 123
124 private: 124 private:
125 Bu::TcpServerSocket *pSrv; 125 Bu::TcpServerSocket *pSrv;
126 bool bRunning; 126 bool bRunning;
127 Bu::Array<Channel *> aChannel; 127 Bu::Array<Channel *> aChannel;
128 }; 128 };
129 129
130 Bu::Formatter &operator<<( Bu::Formatter &f, const Bu::FastCgi::Record &r ); 130 Bu::Formatter &operator<<( Bu::Formatter &f, const Bu::FastCgi::Record &r );
131}; 131};
132 132
133#endif 133#endif