IIPResponse.h

00001 /*
00002     IIP Response Handler Class
00003 
00004     Copyright (C) 2003-2004 Ruven Pillay.
00005 
00006     This program is free software; you can redistribute it and/or modify
00007     it under the terms of the GNU General Public License as published by
00008     the Free Software Foundation; either version 2 of the License, or
00009     (at your option) any later version.
00010 
00011     This program is distributed in the hope that it will be useful,
00012     but WITHOUT ANY WARRANTY; without even the implied warranty of
00013     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014     GNU General Public License for more details.
00015 
00016     You should have received a copy of the GNU General Public License
00017     along with this program; if not, write to the Free Software
00018     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00019 */
00020 
00021 
00022 #ifndef _IIPRESPONSE_H
00023 #define _IIPRESPONSE_H
00024 
00025 #ifndef VERSION
00026 #define VERSION "0.9.9.9"
00027 #endif
00028 
00029 
00030 #include <string>
00031 
00032 
00034 
00035 class IIPResponse{
00036 
00037 
00038  private:
00039 
00040   std::string server;              // Server header
00041   std::string modified;            // Last modified header
00042   std::string cache;               // Cache control header
00043   std::string mimeType;            // Mime type header
00044   std::string eof;                 // End of response delimitter eg "\r\n"
00045   std::string protocol;            // IIP protocol version
00046   std::string responseBody;        // The main response
00047   std::string error;               // Error message
00048   bool sent;                       // Indicate whether a response has been sent
00049 
00050 
00051  public:
00052 
00054   IIPResponse();
00055 
00056 
00058 
00059   void setProtocol( const std::string& p ) { protocol = p; };
00060 
00061 
00063 
00064   void setLastModified( const std::string& m ) { modified = "Last-Modified: " + m; };
00065 
00066 
00068 
00069   void addResponse( const std::string& r ); 
00070 
00071 
00073 
00074   void addResponse( const char* c );
00075 
00076 
00078 
00081   void addResponse( const char* c, int a );
00082 
00083 
00085 
00088   void addResponse( std::string c, const char* a );
00089 
00090 
00092 
00096   void addResponse( const char* c, int a, int b );
00097 
00098 
00100 
00103   void setError( const std::string& code, const std::string& arg );
00104 
00105 
00107   std::string formatResponse();
00108 
00109 
00111   bool isSet(){
00112     if( error.length() || responseBody.length() || protocol.length() ) return true;
00113     else return false;
00114   }
00115 
00116 
00118   bool errorIsSet(){
00119     if( error.length() ) return true;
00120     else return false;
00121   }
00122 
00123 
00125   void setImageSent() { sent = true; };
00126 
00127 
00129   bool imageSent() { return sent; };
00130 
00131 
00133 
00134   std::string getAdvert( const std::string& version );
00135 
00136 
00137 };
00138 
00139 
00140 #endif

Generated on Fri Nov 26 16:55:07 2010 for iipsrv by  doxygen 1.5.8