CgiEnvironment.h

Go to the documentation of this file.
00001 /* -*-mode:c++; c-file-style: "gnu";-*- */
00002 /*
00003  *  $Id: CgiEnvironment_8h-source.html,v 1.3 2008/01/19 21:53:39 sebdiaz Exp $
00004  *
00005  *  Copyright (C) 1996 - 2004 Stephen F. Booth <sbooth@gnu.org>
00006  *                       2007 Sebastien DIAZ <sebastien.diaz@gmail.com>
00007  *  Part of the GNU cgicc library, http://www.gnu.org/software/cgicc
00008  *
00009  *  This library is free software; you can redistribute it and/or
00010  *  modify it under the terms of the GNU Lesser General Public
00011  *  License as published by the Free Software Foundation; either
00012  *  version 3 of the License, or (at your option) any later version.
00013  *
00014  *  This library is distributed in the hope that it will be useful,
00015  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00016  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00017  *  Lesser General Public License for more details.
00018  *
00019  *  You should have received a copy of the GNU Lesser General Public
00020  *  License along with this library; if not, write to the Free Software
00021  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
00022  */
00023 
00024 #ifndef _CGIENVIRONMENT_H_
00025 #define _CGIENVIRONMENT_H_ 1
00026 
00027 #ifdef __GNUG__
00028 #  pragma interface
00029 #endif
00030 
00040 #include <string>
00041 #include <vector>
00042 #include <cstdlib>
00043 
00044 #include "cgicc/CgiDefs.h"
00045 #include "cgicc/CgiUtils.h"
00046 #include "cgicc/CgiInput.h"
00047 #include "cgicc/HTTPCookie.h"
00048 
00049 namespace cgicc {
00050 
00051 #ifdef WIN32
00052   template class CGICC_API std::vector<HTTPCookie>;
00053 #endif
00054   
00055   // ============================================================
00056   // Iterator typedefs
00057   // ============================================================
00058   
00060   typedef std::vector<HTTPCookie>::iterator     cookie_iterator;
00062   typedef std::vector<HTTPCookie>::const_iterator const_cookie_iterator;
00063   
00064   // ============================================================
00065   // Class CgiEnvironment
00066   // ============================================================
00067   
00076   class CGICC_API CgiEnvironment
00077   {
00078   public:
00079     
00080     friend class Cgicc;
00081     
00082     // ============================================================
00083     
00086     
00101     CgiEnvironment(CgiInput *input);
00102     
00109     inline
00110     CgiEnvironment(const CgiEnvironment& env)
00111     { operator=(env); }
00112 
00118     ~CgiEnvironment();
00120     
00121     // ============================================================
00122     
00125     
00133     bool 
00134     operator== (const CgiEnvironment& env)              const;
00135     
00143     inline bool
00144     operator!= (const CgiEnvironment& env)              const
00145     { return ! operator==(env); }
00146     
00147 #ifdef WIN32
00148     /* Dummy operator for MSVC++ */
00149     inline bool
00150     operator< (const CgiEnvironment& env)               const
00151     { return false; }
00152 #endif
00153     
00161     CgiEnvironment& 
00162     operator= (const CgiEnvironment& env);
00164 
00165     // ============================================================
00166     
00171     
00178     inline std::string 
00179     getServerSoftware()                         const
00180     { return fServerSoftware; }
00181     
00188     inline std::string 
00189     getServerName()                             const
00190     { return fServerName; }
00191     
00198     inline std::string 
00199     getGatewayInterface()                       const
00200     { return fGatewayInterface;}
00201     
00208     inline std::string 
00209     getServerProtocol()                         const
00210     { return fServerProtocol; }
00211     
00218     inline unsigned long
00219     getServerPort()                             const
00220     { return fServerPort; }
00221     
00228     inline bool
00229     usingHTTPS()                                const
00230     { return fUsingHTTPS; }
00232     
00233     // ============================================================
00234     
00239     
00249     inline std::string 
00250     getCookies()                                const
00251     { return fCookie; }
00252     
00262     inline const std::vector<HTTPCookie>& 
00263     getCookieList()                             const
00264     { return fCookies; }
00265     
00272     inline std::string 
00273     getRequestMethod()                          const
00274     { return fRequestMethod; }
00275     
00284     inline std::string
00285     getPathInfo()                               const
00286     { return fPathInfo; }
00287     
00294     inline std::string 
00295     getPathTranslated()                         const
00296     { return fPathTranslated; }
00297     
00304     inline std::string 
00305     getScriptName()                             const
00306     { return fScriptName; }
00307     
00317     inline std::string 
00318     getQueryString()                            const
00319     { return fQueryString; }
00320     
00327     inline unsigned long
00328     getContentLength()                          const
00329     { return fContentLength; }
00330     
00342     inline std::string 
00343     getContentType()                            const
00344     { return fContentType; }
00345     
00352     inline std::string
00353     getPostData()                               const
00354     { return fPostData; }
00356     
00357     // ============================================================
00358     
00363     
00370     inline std::string 
00371     getReferrer()                               const
00372     { return fReferrer; }
00374     
00375     // ============================================================
00376     
00381     
00388     inline std::string 
00389     getRemoteHost()                             const
00390     { return fRemoteHost; }
00391     
00398     inline std::string 
00399     getRemoteAddr()                             const
00400     { return fRemoteAddr; }
00401     
00409     inline std::string 
00410     getAuthType()                               const
00411     { return fAuthType; }
00412     
00420     inline std::string 
00421     getRemoteUser()                             const
00422     { return fRemoteUser; }
00423     
00434     inline std::string 
00435     getRemoteIdent()                            const
00436     { return fRemoteIdent; }
00437     
00444     inline std::string 
00445     getAccept()                                 const
00446     { return fAccept; }
00447     
00455     inline std::string 
00456     getUserAgent()                              const
00457     { return fUserAgent; }
00459     
00460     // ============================================================
00461     
00467     
00475     inline std::string 
00476     getRedirectRequest()                        const
00477     { return fRedirectRequest; }
00478     
00487     inline std::string 
00488     getRedirectURL()                            const
00489     { return fRedirectURL; }
00490     
00498     inline std::string 
00499     getRedirectStatus()                         const
00500     { return fRedirectStatus; }
00502     
00503   protected:
00504     
00505     // ============================================================
00506     
00511     
00518     void 
00519     save(const std::string& filename)           const;
00520     
00527     // Implementation of restore
00528     void 
00529     restore(const std::string& filename);
00531     
00532     // ============================================================
00533     
00534   private:
00535     
00536     // Parse the list of cookies from a string to a vector
00537     void 
00538     parseCookies();
00539     
00540     // Parse a single cookie string (name=value) pair
00541     void
00542     parseCookie(const std::string& data);
00543     
00544     // Read in all the environment variables
00545     void 
00546     readEnvironmentVariables(CgiInput *input);
00547     
00548     unsigned long               fServerPort;
00549     unsigned long               fContentLength;
00550     bool                        fUsingHTTPS;
00551     std::string                 fServerSoftware;
00552     std::string                 fServerName;
00553     std::string                 fGatewayInterface;
00554     std::string                 fServerProtocol;
00555     std::string                 fRequestMethod;
00556     std::string                 fPathInfo;
00557     std::string                 fPathTranslated;
00558     std::string                 fScriptName;
00559     std::string                 fQueryString;
00560     std::string                 fRemoteHost;
00561     std::string                 fRemoteAddr;
00562     std::string                 fAuthType;
00563     std::string                 fRemoteUser;
00564     std::string                 fRemoteIdent;
00565     std::string                 fContentType;
00566     std::string                 fAccept;
00567     std::string                 fUserAgent;
00568     std::string                 fPostData;
00569     std::string                 fRedirectRequest;
00570     std::string                 fRedirectURL;
00571     std::string                 fRedirectStatus;
00572     std::string                 fReferrer;
00573     std::string                 fCookie;
00574     std::vector<HTTPCookie>     fCookies;
00575   };
00576   
00577 } // namespace cgicc
00578 
00579 #endif /* ! _CGIENVIRONMENT_H_ */

GNU cgicc - A C++ class library for writing CGI applications
Copyright © 1996 - 2004 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 Sat Jan 19 21:15:58 2008 for cgicc by doxygen 1.5.1