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/HTTPCookie.h"
00045
00046 CGICC_BEGIN_NAMESPACE
00047
00049 typedef size_t (* reader_function_t)(void *, size_t);
00050
00051 #ifdef WIN32
00052 template class CGICC_API STDNS vector<HTTPCookie>;
00053 #endif
00054
00055
00056
00057
00058
00060 typedef STDNS vector<HTTPCookie>::iterator cookie_iterator;
00062 typedef STDNS vector<HTTPCookie>::const_iterator const_cookie_iterator;
00063
00064
00065
00066
00067
00076 class CGICC_API CgiEnvironment
00077 {
00078 public:
00079
00080 friend class Cgicc;
00081
00082
00083
00086
00097 CgiEnvironment(reader_function_t stream_reader);
00098
00104 ~CgiEnvironment();
00106
00107
00108
00113
00120 inline STDNS string
00121 getServerSoftware() const
00122 { return fServerSoftware; }
00123
00130 inline STDNS string
00131 getServerName() const
00132 { return fServerName; }
00133
00140 inline STDNS string
00141 getGatewayInterface() const
00142 { return fGatewayInterface;}
00143
00150 inline STDNS string
00151 getServerProtocol() const
00152 { return fServerProtocol; }
00153
00160 inline unsigned long
00161 getServerPort() const
00162 { return fServerPort; }
00163
00170 inline bool
00171 usingHTTPS() const
00172 { return fUsingHTTPS; }
00174
00175
00176
00181
00191 inline STDNS string
00192 getCookies() const
00193 { return fCookie; }
00194
00204 inline const STDNS vector<HTTPCookie>&
00205 getCookieList() const
00206 { return fCookies; }
00207
00214 inline STDNS string
00215 getRequestMethod() const
00216 { return fRequestMethod; }
00217
00226 inline STDNS string
00227 getPathInfo() const
00228 { return fPathInfo; }
00229
00236 inline STDNS string
00237 getPathTranslated() const
00238 { return fPathTranslated; }
00239
00246 inline STDNS string
00247 getScriptName() const
00248 { return fScriptName; }
00249
00259 inline STDNS string
00260 getQueryString() const
00261 { return fQueryString; }
00262
00269 inline unsigned long
00270 getContentLength() const
00271 { return fContentLength; }
00272
00284 inline STDNS string
00285 getContentType() const
00286 { return fContentType; }
00287
00294 inline STDNS string
00295 getPostData() const
00296 { return fPostData; }
00298
00299
00300
00305
00312 inline STDNS string
00313 getReferrer() const
00314 { return fReferrer; }
00316
00317
00318
00323
00330 inline STDNS string
00331 getRemoteHost() const
00332 { return fRemoteHost; }
00333
00340 inline STDNS string
00341 getRemoteAddr() const
00342 { return fRemoteAddr; }
00343
00351 inline STDNS string
00352 getAuthType() const
00353 { return fAuthType; }
00354
00362 inline STDNS string
00363 getRemoteUser() const
00364 { return fRemoteUser; }
00365
00376 inline STDNS string
00377 getRemoteIdent() const
00378 { return fRemoteIdent; }
00379
00386 inline STDNS string
00387 getAccept() const
00388 { return fAccept; }
00389
00397 inline STDNS string
00398 getUserAgent() const
00399 { return fUserAgent; }
00401
00402
00403
00409
00417 inline STDNS string
00418 getRedirectRequest() const
00419 { return fRedirectRequest; }
00420
00429 inline STDNS string
00430 getRedirectURL() const
00431 { return fRedirectURL; }
00432
00440 inline STDNS string
00441 getRedirectStatus() const
00442 { return fRedirectStatus; }
00444
00445 protected:
00446
00447
00448
00453
00460 void
00461 save(const STDNS string& filename) const;
00462
00469
00470 void
00471 restore(const STDNS string& filename);
00473
00474
00475
00476 private:
00477
00478
00479 void
00480 parseCookies();
00481
00482
00483 void
00484 parseCookie(const STDNS string& data);
00485
00486
00487 void
00488 readEnvironmentVariables();
00489
00490 unsigned long fServerPort;
00491 unsigned long fContentLength;
00492 bool fUsingHTTPS;
00493 STDNS string fServerSoftware;
00494 STDNS string fServerName;
00495 STDNS string fGatewayInterface;
00496 STDNS string fServerProtocol;
00497 STDNS string fRequestMethod;
00498 STDNS string fPathInfo;
00499 STDNS string fPathTranslated;
00500 STDNS string fScriptName;
00501 STDNS string fQueryString;
00502 STDNS string fRemoteHost;
00503 STDNS string fRemoteAddr;
00504 STDNS string fAuthType;
00505 STDNS string fRemoteUser;
00506 STDNS string fRemoteIdent;
00507 STDNS string fContentType;
00508 STDNS string fAccept;
00509 STDNS string fUserAgent;
00510 STDNS string fPostData;
00511 STDNS string fRedirectRequest;
00512 STDNS string fRedirectURL;
00513 STDNS string fRedirectStatus;
00514 STDNS string fReferrer;
00515 STDNS string fCookie;
00516 STDNS vector<HTTPCookie> fCookies;
00517 };
00518
00519 CGICC_END_NAMESPACE
00520
00521 #endif