HydraExpress™ C++ API Reference Guide

Product Documentation:
   HydraExpress C++
Documentation Home
List of all members | Public Member Functions
rwsf::HttpServletRequest Class Reference

Extends rwsf::ServletRequest to provide request information for HTTP servlets. More...

#include <rwsf/servlet/http/HttpServletRequest.h>

Inheritance diagram for rwsf::HttpServletRequest:
rwsf::ServletRequest

Public Member Functions

virtual ~HttpServletRequest ()
 
std::string getAuthType () const
 
int getContentLength () const
 
std::string getContentType () const
 
std::string getContextPath () const
 
bool getCookie (const std::string &name, rwsf::Cookie &cookie) const
 
std::list< rwsf::CookiegetCookies () const
 
rwsf::DateTime getDateHeader (const std::string &name) const
 
std::string getHeader (const std::string &name) const
 
rwsf::Enumeration< std::string > getHeaderNames () const
 
rwsf::Enumeration< std::string > getHeaders (const std::string &name) const
 
int getIntHeader (const std::string &name) const
 
std::string getMethod () const
 
std::string getPathInfo () const
 
std::string getPathTranslated () const
 
std::string getQueryString () const
 
std::string getRemoteUser () const
 
std::string getRequestedSessionId () const
 
std::string getRequestURI () const
 
std::string getRequestURL () const
 
std::string getServletPath () const
 
rwsf::HttpSession getSession (bool create, rwsf::HttpSession::Lifetime l=rwsf::HttpSession::Transient) const
 
rwsf::HttpSession getSession (rwsf::HttpSession::Lifetime l=rwsf::HttpSession::Transient) const
 
bool isRequestedSessionIdFromCookie () const
 
bool isRequestedSessionIdFromURL () const
 
bool isRequestedSessionIdValid () const
 
bool isUserInRole (const std::string &role) const
 
rwsf::DateTime parseDate (const std::string &value) const
 
- Public Member Functions inherited from rwsf::ServletRequest
virtual ~ServletRequest ()
 
rwsf::Attribute getAttribute (const std::string &name) const
 
rwsf::Enumeration< std::string > getAttributeNames () const
 
std::string getCharacterEncoding () const
 
int getContentLength () const
 
std::string getContentType () const
 
std::string getParameter (const std::string &name) const
 
rwsf::Enumeration< std::string > getParameterNames () const
 
std::list< std::string > getParameterValues (const std::string &name) const
 
std::string getPayload () const
 
std::string getProtocol () const
 
std::string getRemoteAddr () const
 
std::string getRemoteHost () const
 
rwsf::RequestDispatcher getRequestDispatcher (const std::string &path)
 
std::string getScheme () const
 
std::string getServerName () const
 
int getServerPort () const
 
bool isSecure () const
 
rwsf::Attribute removeAttribute (const std::string &name)
 
void setAttribute (const std::string &name, const rwsf::Attribute &value)
 

Detailed Description

An HTTP servlet receives an rwsf::HttpServletRequest object for each request from a client. The request object contains the complete information in the request as well as any rwsf::HttpSession object associated with the request.

The behavior of the following functions are inconsistent with or not defined in the Java Servlet Specification v2.3.

getAuthType() Returns an empty string
getContentLength() Added method, overrides ServletRequest::getContentLength()
getRemoteUser() Returns an empty string
getRequestURI() Returns http://foo.bar/a.html for the request URL http://foo.bar/a.html. It should return /a.html.
getUserPrincipal() Not included in this implementation
isUserInRole() Returns false
parseDate() Added method, but deprecated

Constructor & Destructor Documentation

virtual rwsf::HttpServletRequest::~HttpServletRequest ( )
virtual

Destructor.

Member Function Documentation

std::string rwsf::HttpServletRequest::getAuthType ( ) const

This method currently returns an empty string.

int rwsf::HttpServletRequest::getContentLength ( ) const

Returns the value of the Content-Length header of the request, or -1 if the request contains no such header.

std::string rwsf::HttpServletRequest::getContentType ( ) const

Returns the Content-Type of the request. When the request has no content type, returns the empty string.

std::string rwsf::HttpServletRequest::getContextPath ( ) const

Returns the path for the context from the request URI. For example, in the URL /examples/HelloWorld, the context path is /examples.

bool rwsf::HttpServletRequest::getCookie ( const std::string &  name,
rwsf::Cookie cookie 
) const

Locates the cookie named name in this request. If such a cookie exists, the function copies the located cookie to cookie and returns true. Otherwise, the function returns false and cookie is unchanged. Name comparisons are case-sensitive.

std::list<rwsf::Cookie> rwsf::HttpServletRequest::getCookies ( ) const

Returns a list of the cookies in this request. Returns an empty list if this request has no cookies.

rwsf::DateTime rwsf::HttpServletRequest::getDateHeader ( const std::string &  name) const

Returns the value of the named HTTP header as an rwsf::DateTime. Returns a null date if the header does not exist. Returns an invalid date if the header value is not a valid HTTP/1.1 date string. Header name comparisons are case-insensitive.

std::string rwsf::HttpServletRequest::getHeader ( const std::string &  name) const

Returns the value of the HTTP header in this request with a name matching name. If this request contains no such header, returns the empty string. Header name comparisons are case-insensitive.

rwsf::Enumeration<std::string> rwsf::HttpServletRequest::getHeaderNames ( ) const

Returns an enumeration of the names of the headers contained in the request. Use this method with caution. The contents of the enumeration and the order of the values may vary from request to request.

rwsf::Enumeration<std::string> rwsf::HttpServletRequest::getHeaders ( const std::string &  name) const

Returns an enumeration for all values for the HTTP header named name. This is useful for HTTP headers that can have multiple values. For headers that contain a single value, this function returns an enumeration that contains that value. If the request contains no matching HTTP header, this function returns an empty enumeration. Header name comparisons are case-insensitive.

int rwsf::HttpServletRequest::getIntHeader ( const std::string &  name) const

Returns the value of the HTTP header named name as an int. If the header cannot be found, returns -1. If the value cannot be converted to an int, returns 0.

std::string rwsf::HttpServletRequest::getMethod ( ) const

Returns the HTTP method that was used to invoke this request. The value will be a non-standard HTTP method or one of the following: POST, GET, PUT, DELETE, OPTIONS, or HEAD.

std::string rwsf::HttpServletRequest::getPathInfo ( ) const

This method returns any extra path information from the request. If there is no extra path information, returns the empty string.

Extra path information is information that follows the servlet path but precedes the query string.

For example, if the servlet is located at /examples/hello, this function returns /extra/path for the request URI /examples/hello/extra/path?val=10. For the request URI /examples/hello, this function returns the empty string.

std::string rwsf::HttpServletRequest::getPathTranslated ( ) const

Returns the full path on the underlying operating system that corresponds to the path in the HTTP request. This method returns the empty string if the path info is empty.

std::string rwsf::HttpServletRequest::getQueryString ( ) const

Returns the query string portion of the request URI. This method returns the empty string if there is no query string. The query string for a URI such as /rwsf/Hello?val=10 would be val=10.

std::string rwsf::HttpServletRequest::getRemoteUser ( ) const

Returns the login name of the user who made this request. If the user is not known, returns the empty string. This method is currently unimplemented. All calls to this function return the empty string.

std::string rwsf::HttpServletRequest::getRequestedSessionId ( ) const

Returns the session ID for the current session. If there is no current session, returns the empty string.

std::string rwsf::HttpServletRequest::getRequestURI ( ) const

Returns the URI for this request minus the query string. The web container does not decode this string. The following table shows the return value for some example URIs:

First Line of HTTP Request Returned Value
POST /some/path.html HTTP/1.1 /some/path.html
GET http://foo.bar/a.html HTTP/1.1 http://foo.bar/a.html
HEAD /xyz?a=b HTTP/1.1 /xyz
std::string rwsf::HttpServletRequest::getRequestURL ( ) const

Reconstructs the URL the client used to make the request. The returned URL contains a protocol, server name, port number, and server path, but does not include query string parameters.

This method is useful for creating redirect messages and for reporting errors.

std::string rwsf::HttpServletRequest::getServletPath ( ) const

Returns the path for this servlet from the request URI. The servlet path is the portion of the path between the servlet context and the extra path info or query string. For example, the URI /rwsf/HelloWorld?val=10 has a servlet path of /HelloWorld.

rwsf::HttpSession rwsf::HttpServletRequest::getSession ( bool  create,
rwsf::HttpSession::Lifetime  l = rwsf::HttpSession::Transient 
) const

Returns the current session. If there is no current session, or if the current session is invalid, returns a new session if create is true; returns an invalid session if create is false.

rwsf::HttpSession rwsf::HttpServletRequest::getSession ( rwsf::HttpSession::Lifetime  l = rwsf::HttpSession::Transient) const

Returns the current session. If there is no current session, or if the current session is invalid, returns a new session.

bool rwsf::HttpServletRequest::isRequestedSessionIdFromCookie ( ) const

Returns true if the current session was created from a cookie. The Agent uses JSESSIONID as the cookie to store the session id.

bool rwsf::HttpServletRequest::isRequestedSessionIdFromURL ( ) const

Returns true if the current session was found in the URL. The Agent uses a query string parameter name of JSESSIONID to store the session id.

bool rwsf::HttpServletRequest::isRequestedSessionIdValid ( ) const

Returns true if the current session is valid, false otherwise.

bool rwsf::HttpServletRequest::isUserInRole ( const std::string &  role) const

This method is currently unimplemented. It always returns false.

rwsf::DateTime rwsf::HttpServletRequest::parseDate ( const std::string &  value) const
Deprecated:
As of version 4.6, replaced by getDateHeader().

This method can be used with the getHeader() method to convert an HTTP header representing a date object to an rwsf::DateTime object.

Copyright © 2020 Rogue Wave Software, Inc. All Rights Reserved.
Rogue Wave is registered trademark of Rogue Wave Software, Inc. in the United States and other countries, and HydraExpress is a trademark of Rogue Wave Software. All other trademarks are the property of their respective owners.
Provide feedback to Rogue Wave about its documentation.