summaryrefslogtreecommitdiff
path: root/src/fastcgi.h
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2012-03-25 20:00:08 +0000
committerMike Buland <eichlan@xagasoft.com>2012-03-25 20:00:08 +0000
commit469bbcf0701e1eb8a6670c23145b0da87357e178 (patch)
treeb5b062a16e46a6c5d3410b4e574cd0cc09057211 /src/fastcgi.h
parentee1b79396076edc4e30aefb285fada03bb45e80d (diff)
downloadlibbu++-469bbcf0701e1eb8a6670c23145b0da87357e178.tar.gz
libbu++-469bbcf0701e1eb8a6670c23145b0da87357e178.tar.bz2
libbu++-469bbcf0701e1eb8a6670c23145b0da87357e178.tar.xz
libbu++-469bbcf0701e1eb8a6670c23145b0da87357e178.zip
Code is all reorganized. We're about ready to release. I should write up a
little explenation of the arrangement.
Diffstat (limited to 'src/fastcgi.h')
-rw-r--r--src/fastcgi.h133
1 files changed, 0 insertions, 133 deletions
diff --git a/src/fastcgi.h b/src/fastcgi.h
deleted file mode 100644
index d290c40..0000000
--- a/src/fastcgi.h
+++ /dev/null
@@ -1,133 +0,0 @@
1/*
2 * Copyright (C) 2007-2011 Xagasoft, All rights reserved.
3 *
4 * This file is part of the libbu++ library and is released under the
5 * terms of the license contained in the file LICENSE.
6 */
7
8#ifndef BU_FAST_CGI_H
9#define BU_FAST_CGI_H
10
11#include "bu/string.h"
12#include "bu/hash.h"
13#include "bu/array.h"
14#include "bu/tcpsocket.h"
15#include "bu/tcpserversocket.h"
16
17namespace Bu
18{
19 class Stream;
20
21 class FastCgi
22 {
23 public:
24 FastCgi( int iPort );
25 FastCgi();
26 virtual ~FastCgi();
27
28 static bool isEmbedded();
29
30 typedef Bu::Hash<Bu::String, Bu::String> StrHash;
31 enum RequestType
32 {
33 typeBeginRequest = 1,
34 typeAbortRequest = 2,
35 typeEndRequest = 3,
36 typeParams = 4,
37 typeStdIn = 5,
38 typeStdOut = 6,
39 typeStdErr = 7,
40 typeData = 8,
41 typeGetValues = 9,
42 typeGetValuesResult = 10
43 };
44
45 enum Role
46 {
47 roleResponder = 1,
48 roleAuthorizer = 2,
49 roleFilter = 3
50 };
51
52 enum Flags
53 {
54 flagsKeepConn = 1
55 };
56
57 enum Status
58 {
59 statusRequestComplete = 0,
60 statusCantMpxConn = 1,
61 statusOverloaded = 2,
62 statusUnknownRole = 3
63 };
64
65 typedef struct {
66 uint8_t uVersion;
67 uint8_t uType;
68 uint16_t uRequestId;
69 uint16_t uContentLength;
70 uint8_t uPaddingLength;
71 uint8_t uReserved;
72 } Record;
73
74 typedef struct {
75 uint16_t uRole;
76 uint8_t uFlags;
77 uint8_t reserved[5];
78 } BeginRequestBody;
79
80 typedef struct {
81 uint32_t uStatus;
82 uint8_t uProtocolStatus;
83 uint8_t reserved[3];
84 } EndRequestBody;
85
86 typedef struct Channel {
87 Channel() : uFlags( 0 ) { }
88 StrHash hParams;
89 Bu::String sStdIn;
90 Bu::String sData;
91 uint8_t uFlags;
92 } Channel;
93
94 enum ChannelFlags
95 {
96 chflgParamsDone = 0x01,
97 chflgStdInDone = 0x02,
98 chflgDataDone = 0x04,
99
100 chflgAllDone = 0x03
101 };
102
103 virtual void run();
104
105 void stopRunning() { bRunning = false; }
106
107 virtual void onInit() { };
108 virtual int onRequest( const StrHash &hParams,
109 const Bu::String &sStdIn, Bu::Stream &sStdOut,
110 Bu::Stream &sStdErr )=0;
111 virtual void onUninit() { };
112
113 private:
114 void read( Bu::TcpSocket &s, Record &r );
115 void read( Bu::TcpSocket &s, BeginRequestBody &b );
116 uint32_t readLen( Bu::TcpSocket &s, uint16_t &uUsed );
117 void readPair( Bu::TcpSocket &s, StrHash &hParams, uint16_t &uUsed );
118
119 void write( Bu::TcpSocket &s, Record r );
120 void write( Bu::TcpSocket &s, EndRequestBody b );
121
122 bool hasChannel( int iChan );
123
124 private:
125 Bu::TcpServerSocket *pSrv;
126 bool bRunning;
127 Bu::Array<Channel *> aChannel;
128 };
129
130 Bu::Formatter &operator<<( Bu::Formatter &f, const Bu::FastCgi::Record &r );
131};
132
133#endif