Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

CgiEnvironment.h

Go to the documentation of this file.
00001 /* -*-c++-*- */
00002 /*
00003  *  $Id: CgiEnvironment.h,v 1.12 2002/03/06 02:46:21 sbooth Exp $
00004  *
00005  *  Copyright (C) 1996 - 2002 Stephen F. Booth
00006  *
00007  *  This library is free software; you can redistribute it and/or
00008  *  modify it under the terms of the GNU Lesser General Public
00009  *  License as published by the Free Software Foundation; either
00010  *  version 2.1 of the License, or (at your option) any later version.
00011  *
00012  *  This library is distributed in the hope that it will be useful,
00013  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015  *  Lesser General Public License for more details.
00016  *
00017  *  You should have received a copy of the GNU Lesser General Public
00018  *  License along with this library; if not, write to the Free Software
00019  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00020  */
00021 
00022 #ifndef _CGIENVIRONMENT_H_
00023 #define _CGIENVIRONMENT_H_ 1
00024 
00025 #ifdef __GNUG__
00026 #  pragma interface
00027 #endif
00028 
00038 #include <string>
00039 #include <vector>
00040 #include <cstdlib>
00041 
00042 #include "cgicc/CgiDefs.h"
00043 #include "cgicc/CgiUtils.h"
00044 #include "cgicc/CgiInput.h"
00045 #include "cgicc/HTTPCookie.h"
00046 
00047 CGICC_BEGIN_NAMESPACE
00048 
00049 #ifdef WIN32
00050   template class CGICC_API STDNS vector<HTTPCookie>;
00051 #endif
00052 
00053 // ============================================================
00054 // Iterator typedefs
00055 // ============================================================
00056 
00058 typedef STDNS vector<HTTPCookie>::iterator      cookie_iterator;
00060 typedef STDNS vector<HTTPCookie>::const_iterator const_cookie_iterator;
00061 
00062 // ============================================================
00063 // Class CgiEnvironment
00064 // ============================================================
00065 
00074 class CGICC_API CgiEnvironment
00075 {
00076 public:
00077   
00078   friend class Cgicc;
00079     
00080   // ============================================================
00081 
00084 
00099   CgiEnvironment(CgiInput *input);
00100   
00106   ~CgiEnvironment();
00108 
00109   // ============================================================
00110 
00115 
00122   inline STDNS string 
00123   getServerSoftware()                           const
00124     { return fServerSoftware; }
00125   
00132   inline STDNS string 
00133   getServerName()                               const
00134     { return fServerName; }
00135   
00142   inline STDNS string 
00143   getGatewayInterface()                         const
00144     { return fGatewayInterface;}
00145   
00152   inline STDNS string 
00153   getServerProtocol()                           const
00154     { return fServerProtocol; }
00155   
00162   inline unsigned long
00163   getServerPort()                               const
00164     { return fServerPort; }
00165 
00172   inline bool
00173   usingHTTPS()                                  const
00174   { return fUsingHTTPS; }
00176   
00177   // ============================================================
00178 
00183 
00193   inline STDNS string 
00194   getCookies()                                  const
00195     { return fCookie; }
00196   
00206   inline const STDNS vector<HTTPCookie>& 
00207   getCookieList()                               const
00208     { return fCookies; }
00209   
00216   inline STDNS string 
00217   getRequestMethod()                            const
00218     { return fRequestMethod; }
00219   
00228   inline STDNS string
00229   getPathInfo()                                 const
00230     { return fPathInfo; }
00231   
00238   inline STDNS string 
00239   getPathTranslated()                           const
00240     { return fPathTranslated; }
00241   
00248   inline STDNS string 
00249   getScriptName()                               const
00250     { return fScriptName; }
00251   
00261   inline STDNS string 
00262   getQueryString()                              const
00263     { return fQueryString; }
00264   
00271   inline unsigned long
00272   getContentLength()                            const
00273     { return fContentLength; }
00274   
00286   inline STDNS string 
00287   getContentType()                              const
00288     { return fContentType; }
00289   
00296   inline STDNS string
00297   getPostData()                                 const
00298     { return fPostData; }
00300 
00301   // ============================================================
00302   
00307 
00314   inline STDNS string 
00315   getReferrer()                                 const
00316     { return fReferrer; }
00318 
00319   // ============================================================
00320 
00325 
00332   inline STDNS string 
00333   getRemoteHost()                               const
00334     { return fRemoteHost; }
00335   
00342   inline STDNS string 
00343   getRemoteAddr()                               const
00344     { return fRemoteAddr; }
00345   
00353   inline STDNS string 
00354   getAuthType()                                 const
00355     { return fAuthType; }
00356   
00364   inline STDNS string 
00365   getRemoteUser()                               const
00366     { return fRemoteUser; }
00367   
00378   inline STDNS string 
00379   getRemoteIdent()                              const
00380     { return fRemoteIdent; }
00381   
00388   inline STDNS string 
00389   getAccept()                                   const
00390     { return fAccept; }
00391   
00399   inline STDNS string 
00400   getUserAgent()                                const
00401     { return fUserAgent; }
00403   
00404   // ============================================================
00405 
00411 
00419   inline STDNS string 
00420   getRedirectRequest()                          const
00421     { return fRedirectRequest; }
00422   
00431   inline STDNS string 
00432   getRedirectURL()                              const
00433     { return fRedirectURL; }
00434   
00442   inline STDNS string 
00443   getRedirectStatus()                           const
00444     { return fRedirectStatus; }
00446 
00447 protected:
00448   
00449   // ============================================================
00450 
00455 
00462   void 
00463   save(const STDNS string& filename)            const;
00464   
00471   // Implementation of restore
00472   void 
00473   restore(const STDNS string& filename);
00475 
00476   // ============================================================
00477 
00478 private:
00479   
00480   // Parse the list of cookies from a string to a vector
00481   void 
00482   parseCookies();
00483 
00484   // Parse a single cookie string (name=value) pair
00485   void
00486   parseCookie(const STDNS string& data);
00487   
00488   // Read in all the environment variables
00489   void 
00490   readEnvironmentVariables(CgiInput *input);
00491   
00492   unsigned long                 fServerPort;
00493   unsigned long                 fContentLength;
00494   bool                          fUsingHTTPS;
00495   STDNS string                  fServerSoftware;
00496   STDNS string                  fServerName;
00497   STDNS string                  fGatewayInterface;
00498   STDNS string                  fServerProtocol;
00499   STDNS string                  fRequestMethod;
00500   STDNS string                  fPathInfo;
00501   STDNS string                  fPathTranslated;
00502   STDNS string                  fScriptName;
00503   STDNS string                  fQueryString;
00504   STDNS string                  fRemoteHost;
00505   STDNS string                  fRemoteAddr;
00506   STDNS string                  fAuthType;
00507   STDNS string                  fRemoteUser;
00508   STDNS string                  fRemoteIdent;
00509   STDNS string                  fContentType;
00510   STDNS string                  fAccept;
00511   STDNS string                  fUserAgent;
00512   STDNS string                  fPostData;
00513   STDNS string                  fRedirectRequest;
00514   STDNS string                  fRedirectURL;
00515   STDNS string                  fRedirectStatus;
00516   STDNS string                  fReferrer;
00517   STDNS string                  fCookie;
00518   STDNS vector<HTTPCookie>      fCookies;
00519 };
00520 
00521 CGICC_END_NAMESPACE
00522 
00523 #endif /* ! _CGIENVIRONMENT_H_ */

GNU cgicc - A C++ class library for writing CGI applications
Copyright © 1996 - 2002 Stephen F. Booth
Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.1 or any later version published by the Free Software Foundation; with no Invariant Sections, with no Front Cover Texts, and with no Back-Cover Texts.
Documentation generated Sun Mar 17 16:40:57 2002 for cgicc by doxygen 1.2.13.1