00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #pragma once
00031 #ifndef __CONNECTIONHANDLER_MS_H__
00032 #define __CONNECTIONHANDLER_MS_H__
00033
00034 #include "cslib/CSDefs.h"
00035 #include "cslib/CSThread.h"
00036 #include "cslib/CSHTTPStream.h"
00037
00038 #include "engine_ms.h"
00039
00040 class MSConnectionHandler : public CSDaemon {
00041 public:
00042 bool amWaitingToListen;
00043 bool shuttingDown;
00044 time_t lastUse;
00045
00046 MSConnectionHandler(CSThreadList *list);
00047 virtual ~MSConnectionHandler(){}
00048
00049 void close();
00050
00051 virtual bool initializeWork();
00052
00053 virtual bool doWork();
00054
00055 virtual void *completeWork();
00056
00057 virtual bool handleException();
00058
00059 static int getHTTPStatus(int err);
00060
00061 void writeException(const char *qualifier);
00062 void writeException();
00063
00064 bool openStream();
00065 void closeStream();
00066
00067 void serviceConnection();
00068 void parseRequestURI();
00069 void freeRequestURI();
00070
00071 void writeFile(CSString *file_path);
00072 void handleGet(bool info_only);
00073 void handlePut();
00074
00075 bool replyPending;
00076
00077 static MSConnectionHandler *newHandler(CSThreadList *list);
00078
00079 private:
00080 CSHTTPInputStream *iInputStream;
00081 CSHTTPOutputStream *iOutputStream;
00082
00083 CSString *iTableURI;
00084
00085 public:
00086 static u_long gMaxKeepAlive;
00087 };
00088
00089 #endif