00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
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 namespace cgicc {
00048
00049 #ifdef WIN32
00050 template class CGICC_API std::vector<HTTPCookie>;
00051 #endif
00052
00053
00054
00055
00056
00058 typedef std::vector<HTTPCookie>::iterator cookie_iterator;
00060 typedef std::vector<HTTPCookie>::const_iterator const_cookie_iterator;
00061
00062
00063
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 std::string
00123 getServerSoftware() const
00124 { return fServerSoftware; }
00125
00132 inline std::string
00133 getServerName() const
00134 { return fServerName; }
00135
00142 inline std::string
00143 getGatewayInterface() const
00144 { return fGatewayInterface;}
00145
00152 inline std::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 std::string
00194 getCookies() const
00195 { return fCookie; }
00196
00206 inline const std::vector<HTTPCookie>&
00207 getCookieList() const
00208 { return fCookies; }
00209
00216 inline std::string
00217 getRequestMethod() const
00218 { return fRequestMethod; }
00219
00228 inline std::string
00229 getPathInfo() const
00230 { return fPathInfo; }
00231
00238 inline std::string
00239 getPathTranslated() const
00240 { return fPathTranslated; }
00241
00248 inline std::string
00249 getScriptName() const
00250 { return fScriptName; }
00251
00261 inline std::string
00262 getQueryString() const
00263 { return fQueryString; }
00264
00271 inline unsigned long
00272 getContentLength() const
00273 { return fContentLength; }
00274
00286 inline std::string
00287 getContentType() const
00288 { return fContentType; }
00289
00296 inline std::string
00297 getPostData() const
00298 { return fPostData; }
00300
00301
00302
00307
00314 inline std::string
00315 getReferrer() const
00316 { return fReferrer; }
00318
00319
00320
00325
00332 inline std::string
00333 getRemoteHost() const
00334 { return fRemoteHost; }
00335
00342 inline std::string
00343 getRemoteAddr() const
00344 { return fRemoteAddr; }
00345
00353 inline std::string
00354 getAuthType() const
00355 { return fAuthType; }
00356
00364 inline std::string
00365 getRemoteUser() const
00366 { return fRemoteUser; }
00367
00378 inline std::string
00379 getRemoteIdent() const
00380 { return fRemoteIdent; }
00381
00388 inline std::string
00389 getAccept() const
00390 { return fAccept; }
00391
00399 inline std::string
00400 getUserAgent() const
00401 { return fUserAgent; }
00403
00404
00405
00411
00419 inline std::string
00420 getRedirectRequest() const
00421 { return fRedirectRequest; }
00422
00431 inline std::string
00432 getRedirectURL() const
00433 { return fRedirectURL; }
00434
00442 inline std::string
00443 getRedirectStatus() const
00444 { return fRedirectStatus; }
00446
00447 protected:
00448
00449
00450
00455
00462 void
00463 save(const std::string& filename) const;
00464
00471
00472 void
00473 restore(const std::string& filename);
00475
00476
00477
00478 private:
00479
00480
00481 void
00482 parseCookies();
00483
00484
00485 void
00486 parseCookie(const std::string& data);
00487
00488
00489 void
00490 readEnvironmentVariables(CgiInput *input);
00491
00492 unsigned long fServerPort;
00493 unsigned long fContentLength;
00494 bool fUsingHTTPS;
00495 std::string fServerSoftware;
00496 std::string fServerName;
00497 std::string fGatewayInterface;
00498 std::string fServerProtocol;
00499 std::string fRequestMethod;
00500 std::string fPathInfo;
00501 std::string fPathTranslated;
00502 std::string fScriptName;
00503 std::string fQueryString;
00504 std::string fRemoteHost;
00505 std::string fRemoteAddr;
00506 std::string fAuthType;
00507 std::string fRemoteUser;
00508 std::string fRemoteIdent;
00509 std::string fContentType;
00510 std::string fAccept;
00511 std::string fUserAgent;
00512 std::string fPostData;
00513 std::string fRedirectRequest;
00514 std::string fRedirectURL;
00515 std::string fRedirectStatus;
00516 std::string fReferrer;
00517 std::string fCookie;
00518 std::vector<HTTPCookie> fCookies;
00519 };
00520
00521 }
00522
00523 #endif