Wt::WEnvironment Class Reference

The WEnvironment class captures information on the application environment. More...

#include <WEnvironment>

List of all members.

Public Types

typedef std::vector< std::string > ArgumentValues
 Values associated with an argument.
typedef std::map< std::string,
ArgumentValues
ArgumentMap
 Argument/value map.
typedef std::map< std::string,
std::string > 
CookieMap
 Cookie map.

Public Member Functions

const ArgumentMaparguments () const
 Arguments passed to the application.
const ArgumentValuesgetArgument (const std::string argument_name) const
 Checks for existence and returns specified argument.
const CookieMapcookies () const
 Cookies set in the initial call to the application.
const std::string getCookie (const std::string cookie_name) const
 Checks for existence and returns specified argument.
bool supportsCookies () const
 Returns whether the browser has enabled support for cookies.
bool javaScript () const
 Returns whether the browser has enabled support for JavaScript.
bool ajax () const
 Returns whether the browser has enabled support for AJAX.
std::string locale () const
 Returns the preferred language indicated in the request header.
std::string hostName () const
 Returns the host name which was submitted in the request.
std::string userAgent () const
 Returns the user agent.
std::string referer () const
 Returns the referer.
bool agentIsSpiderBot () const
 Returns if it is a (known) indexing spider bot.
std::string serverSignature () const
 Web server signature.
std::string serverSoftware () const
 Web server software.
std::string serverAdmin () const
 Email address of the server admin.
std::string clientAddress () const
 IP address of the client.
std::string libraryVersion () const
 Version of the Wt library.
void libraryVersion (int &series, int &major, int &minor) const
 Version of the Wt library, broken down.
std::string sessionId () const
 Get the Wt session id.


Detailed Description

The WEnvironment class captures information on the application environment.

The environment provides information on the client, and gives access to startup arguments.


Member Typedef Documentation

typedef std::map<std::string, ArgumentValues> Wt::WEnvironment::ArgumentMap

Argument/value map.

A std::map which associates an argument name with its set of given values.

typedef std::vector<std::string> Wt::WEnvironment::ArgumentValues

Values associated with an argument.

One or more values may be associated with a single argument.

For example a Wt application 'foo.fcg' started as http://.../foo.fcg?hello=Hello&hello=World will result in both values "Hello" and "World" to be associated with the argument "hello".

typedef std::map<std::string, std::string> Wt::WEnvironment::CookieMap

Cookie map.

A std::map which associates a cookie name with a cookie value.


Member Function Documentation

bool Wt::WEnvironment::agentIsSpiderBot (  )  const

Returns if it is a (known) indexing spider bot.

Note: currently the list of know bot is quite small. This method is used internally to skip the default browser capabilities detection step since the spider usually takes too long to follow the link, and then the session has timed out.

bool Wt::WEnvironment::ajax (  )  const [inline]

Returns whether the browser has enabled support for AJAX.

Without support for JavaScript, Wt will still be able to serve the application, but every event will cause the application to retransmit the whole page, rendering many events inpractical.

const ArgumentMap& Wt::WEnvironment::arguments (  )  const [inline]

Arguments passed to the application.

Arguments passed to the application, either in the URL for a http GET, or in both the URL and data submitted in a http POST.

std::string Wt::WEnvironment::clientAddress (  )  const [inline]

IP address of the client.

The IP address of the client that is connected to this session. e.g. 127.0.0.1

const CookieMap& Wt::WEnvironment::cookies (  )  const [inline]

Cookies set in the initial call to the application.

Note that cookies set with WApplication::setCookie() are not made available in the environment.

Not all clients may support cookies or have cookies enabled. See supportsCookies()

const WEnvironment::ArgumentValues & Wt::WEnvironment::getArgument ( const std::string  argument_name  )  const

Checks for existence and returns specified argument.

Throws a std::runtime_error("missing argument: argument_name") when the argument is missing or returns the vector of values otherwise.

const std::string Wt::WEnvironment::getCookie ( const std::string  cookie_name  )  const

Checks for existence and returns specified argument.

Throws a std::runtime_error("missing cookie: cookie_name") when the cookie is missing, or returns cookie value otherwise.

std::string Wt::WEnvironment::hostName (  )  const [inline]

Returns the host name which was submitted in the request.

The hostname is the unresolved host name with optional port number, which the browser used to connect to the application.

e.g. www.mydomain.com e.g. localhost:8080

bool Wt::WEnvironment::javaScript (  )  const [inline]

Returns whether the browser has enabled support for JavaScript.

Without support for JavaScript, Wt will still be able to serve the application, but with a serious limitation: only the WTimer::timeout and WInteractWidget::clicked() signals will be emitted, leaving the other signals dead. Moreover, every click will cause the application to retransmit the whole page.

void Wt::WEnvironment::libraryVersion ( int &  series,
int &  major,
int &  minor 
) const

Version of the Wt library, broken down.

The version of the Wt library, broken down in its three numbers, e.g. series = 1, major = 99, minor = 2.

std::string Wt::WEnvironment::libraryVersion (  )  const

Version of the Wt library.

The version of the Wt library. e.g. 1.99.2

std::string Wt::WEnvironment::locale (  )  const [inline]

Returns the preferred language indicated in the request header.

The language is parsed from the Accept-Language field, if present in the HTTP headers. If not, the locale is empty.

If multiple languages are present, the one with the highest "q"uality is assumed, and if a tie is present, the first one is taken.

std::string Wt::WEnvironment::referer (  )  const [inline]

Returns the referer.

The referer, as reported in the HTTP Referer field.

std::string Wt::WEnvironment::serverAdmin (  )  const [inline]

Email address of the server admin.

The value of the CGI variable SERVER_ADMIN. e.g. root

std::string Wt::WEnvironment::serverSignature (  )  const [inline]

Web server signature.

The value of the CGI variable SERVER_SIGNATURE. e.g. <address>Apache Server at localhost Port 80</address>

std::string Wt::WEnvironment::serverSoftware (  )  const [inline]

Web server software.

The value of the CGI variable SERVER_SOFTWARE. e.g. Apache

std::string Wt::WEnvironment::sessionId (  )  const

Get the Wt session id.

Retrieves the session Id for this session. This is an auto-generated random alpha-numerical id, whose length is determined by settings in the configuration file.

bool Wt::WEnvironment::supportsCookies (  )  const [inline]

Returns whether the browser has enabled support for cookies.

When the user disables cookies during the visit of the page, this value is not updated.

std::string Wt::WEnvironment::userAgent (  )  const [inline]

Returns the user agent.

The user agent, as reported in the HTTP User-Agent field.


The documentation for this class was generated from the following files:
Generated on Sun Jul 1 19:37:18 2007 for Wt by doxygen 1.4.7