Drizzled Public API Documentation

connection_handler_ms.h

00001 /* Copyright (C) 2008 PrimeBase Technologies GmbH, Germany
00002  *
00003  * PrimeBase Media Stream for MySQL
00004  *
00005  * This program is free software; you can redistribute it and/or modify
00006  * it under the terms of the GNU General Public License as published by
00007  * the Free Software Foundation; either version 2 of the License, or
00008  * (at your option) any later version.
00009  *
00010  * This program is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  * GNU General Public License for more details.
00014  *
00015  * You should have received a copy of the GNU General Public License
00016  * along with this program; if not, write to the Free Software
00017  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
00018  *
00019  * Original author: Paul McCullagh
00020  * Continued development: Barry Leslie
00021  *
00022  * 2007-05-25
00023  *
00024  * H&G2JCtL
00025  *
00026  * Connection Handler.
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(){} // Do nothing here because 'self' will no longer be valid, use completeWork().
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