mod_servlet
C++Servlets
|
Defines an object to provide client request information to a servlet. More...
#include <request.h>
Public Member Functions | |
virtual tree_any_map & | get_attributes ()=0 |
Returns the attributes map associated with this request. More... | |
virtual const tree_any_map & | get_attributes () const =0 |
Const version of call get_attributes() const. More... | |
virtual const std::map < std::string, std::vector < std::string >, std::less<> > & | get_parameters ()=0 |
Returns all the parameters of this request. More... | |
virtual const std::map < string_view, string_view, std::less<> > & | get_env ()=0 |
Returns all the environment variables accessible from this request. More... | |
virtual bool | is_secure ()=0 |
Returns a boolean indicating whether this request was made using a secure channel, such as HTTPS. More... | |
virtual std::shared_ptr < SSL_information > | ssl_information ()=0 |
Returns information about SSL connection if it is established. More... | |
template<typename StringType > | |
const optional_ref< const std::string > | get_parameter (const StringType &name) |
Returns the value of a request parameter as a reference to std::string , or null if the parameter does not exist. More... | |
template<typename StringType > | |
const optional_ref< const std::vector< std::string > > | get_parameters (const StringType &name) |
Returns all values of a request parameter as a reference to std::vector , or null if the parameters do not exist. More... | |
virtual string_view | get_auth_type ()=0 |
Returns the name of the authentication scheme used to protect the servlet. More... | |
virtual const std::vector < cookie > & | get_cookies ()=0 |
Returns an array containing all of the cookie objects the client sent with this request. More... | |
virtual string_view | get_context_path () const =0 |
Returns the portion of the request URI that indicates the context of the request. More... | |
virtual string_view | get_servlet_path () const =0 |
Returns the part of this request's URL that calls the servlet. More... | |
virtual const URI & | get_request_uri () const =0 |
Returns the URI> with which this request was called. More... | |
virtual string_view | get_path_info () const =0 |
Returns any extra path information associated with the URL the client sent when it made this request. More... | |
virtual string_view | get_header (const std::string &name) const =0 |
Returns the value of the specified request header as a std::string . More... | |
virtual long | get_date_header (const std::string &name) const =0 |
Returns the value of the specified request header as a long value that represents a Date object. More... | |
virtual string_view | get_content_type () const =0 |
Returns the MIME type of the body of the request, or empty string if the type is not known. More... | |
virtual long | get_content_length () const =0 |
Returns the length, in bytes, of the request body and made available by the input stream, or -1 if the length is not known. More... | |
virtual void | get_headers (const std::string &name, std::vector< std::string > &headers) const =0 |
Fills the std::vector with all the header values associated with the specified header name. More... | |
virtual void | get_headers (std::vector< std::pair< std::string, std::string >> &headers) const =0 |
Fills the std::vector with all the request header values. More... | |
virtual string_view | get_method () const =0 |
Returns the name of the HTTP method with which this request was made, for example, GET, POST, or PUT. More... | |
virtual string_view | get_path_translated () const =0 |
Returns any extra path information after the servlet name but before the query string, and translates it to a real path. More... | |
virtual string_view | get_scheme () const =0 |
Returns the name of the scheme used to make this request, for example, http or https . More... | |
virtual string_view | get_protocol () const =0 |
Returns the name and version of the protocol the request uses in the form protocol/majorVersion.minorVersion, for example, HTTP/1.1. More... | |
virtual string_view | get_client_addr () const =0 |
Returns the Internet Protocol (IP) address of the client or last proxy that sent the request. More... | |
virtual string_view | get_client_host () const =0 |
Returns the fully qualified name of the client or the last proxy that sent the request if available. More... | |
virtual uint16_t | get_client_port () const =0 |
Returns the Internet Protocol (IP) source port of the client or last proxy that sent the request. More... | |
virtual string_view | get_remote_user () const =0 |
Returns the login of the user making this request, if the user has been authenticated, or empty view if the user has not been authenticated. More... | |
virtual string_view | get_local_addr () const =0 |
Returns the Internet Protocol (IP) address of the interface on which the request was received. More... | |
virtual string_view | get_local_host () const =0 |
Returns the host name of the Internet Protocol (IP) interface on which the request was received. More... | |
virtual uint16_t | get_local_port () const =0 |
Returns the Internet Protocol (IP) port number of the interface on which the request was received. More... | |
virtual string_view | get_server_name () const =0 |
Returns the host name of the server to which the request was sent. More... | |
virtual uint16_t | get_server_port () const =0 |
Returns the port number to which the request was sent. More... | |
virtual void | forward (const std::string &redirectURI, bool from_context_path=true)=0 |
Redirects the request to a specified local URI within the server. More... | |
virtual int | include (const std::string &includeURI, bool from_context_path=true)=0 |
Includes the response of the specified local URI into the current response. More... | |
virtual http_session & | get_session ()=0 |
Returns the current http_session associated with this request or, if there is no current session returns a new session. More... | |
virtual bool | has_session ()=0 |
Returns true if the http_session associated with this request exists. More... | |
virtual void | invalidate_session ()=0 |
Invalidates the session assosiated with this request if it exists. | |
virtual std::istream & | get_input_stream ()=0 |
Retrieves the body of the request as binary data using a std::istream . More... | |
virtual multipart_input & | get_multipart_input ()=0 |
Retrieves the body of the request as binary data if the input is a multipart stream. More... | |
virtual bool | is_multipart () const =0 |
Returns true if current request is multipart. More... | |
Defines an object to provide client request information to a servlet.
The servlet container creates a http_equest
object and passes it as an argument to the servlet's http_servlet::service
method.
A http_request
object provides data including parameter name and values, attributes,
|
pure virtual |
Redirects the request to a specified local URI within the server.
Redirect processed internally without returning to the client, which is the difference of this method from http_response::send_redirect. This method expects only local path, not the full URI.
If the provided URI is an absolute path it will be used as is if from_context_path
argument is false
. Otherwise current context path will be prepended to the URI.
If the provided URI is a relative path it will be resolved against current request URI (see get_request_uri).
redirectURI | URI to redirect the request to |
from_context_path | true if the redirectURI should be resolved against the current context path |
Implemented in servlet::http_request_wrapper.
|
pure virtual |
Returns the attributes map associated with this request.
Attributes can be set two ways. The servlet container may set attributes to make available custom information about a request. For example, for requests made using HTTPS, the attribute javax.servlet.request.X509Certificate
can be used to retrieve information on the certificate of the client. Attributes can also be set programatically using the returned map.
tree_any_map
containing the attributes of this request. Implemented in servlet::http_request_wrapper.
|
pure virtual |
Const version of call get_attributes() const.
tree_any_map
containing the attributes of this request. Implemented in servlet::http_request_wrapper.
|
pure virtual |
Returns the name of the authentication scheme used to protect the servlet.
All servlet containers support basic, form and client certificate authentication, and may additionally support digest authentication. If the servlet is not authenticated empty string is returned.
Same as the value of the CGI variable AUTH_TYPE.
Implemented in servlet::http_request_wrapper.
|
pure virtual |
Returns the Internet Protocol (IP) address of the client or last proxy that sent the request.
For HTTP servlets, same as the value of the CGI variable REMOTE_ADDR
.
string_view
containing the IP address of the client that sent the request Implemented in servlet::http_request_wrapper.
|
pure virtual |
Returns the fully qualified name of the client or the last proxy that sent the request if available.
If the engine cannot or chooses not to resolve the hostname, this method returns the dotted-string form of the IP address. For HTTP servlets, same as the value of the CGI variable REMOTE_HOST
.
string_view
containing the fully qualified name of the client Implemented in servlet::http_request_wrapper.
|
pure virtual |
Returns the Internet Protocol (IP) source port of the client or last proxy that sent the request.
Implemented in servlet::http_request_wrapper.
|
pure virtual |
Returns the length, in bytes, of the request body and made available by the input stream, or -1 if the length is not known.
For HTTP servlets, same as the value of the CGI variable CONTENT_LENGTH.
Implemented in servlet::http_request_wrapper.
|
pure virtual |
Returns the MIME type of the body of the request, or empty string if the type is not known.
For HTTP servlets, same as the value of the CGI variable CONTENT_TYPE.
string_view
containing the name of the MIME type of the request, or empty view if the type is not known Implemented in servlet::http_request_wrapper.
|
pure virtual |
Returns the portion of the request URI that indicates the context of the request.
The context path always comes first in a request URI. The path starts with a "/" character but does not end with a "/" character. For servlets in the default (root) context, this method returns "". The container does not decode this string.
string_view
specifying the portion of the request URI that indicates the context of the request Implemented in servlet::http_request_wrapper.
|
pure virtual |
Returns an array containing all of the cookie
objects the client sent with this request.
This method returns empty vector if no cookies were sent.
cookies
included with this request, or empty vector if the request has no cookies Implemented in servlet::http_request_wrapper.
|
pure virtual |
Returns the value of the specified request header as a long
value that represents a Date
object.
Use this method with headers that contain dates, such as If-Modified-Since
.
The date is returned as the number of milliseconds since January 1, 1970 GMT. The header name is case insensitive.
If the request did not have a header of the specified name, this method returns -1. If the header can't be converted to a date, the method throws an stack_bad_cast
.
name | a std::string specifying the name of the header |
long
value representing the date specified in the header expressed as the number of milliseconds since January 1, 1970 GMT, or -1 if the named header was not included with the request stack_bad_cast | If the header value can't be converted to a date |
Implemented in servlet::http_request_wrapper.
|
pure virtual |
Returns all the environment variables accessible from this request.
Environment variables can be set by other servler modules in order to provide information to other modules (like PHP or CGI). This method allows to access these variables
tree_map
representing this request's environment variables Implemented in servlet::http_request_wrapper.
|
pure virtual |
Returns the value of the specified request header as a std::string
.
If the request did not include a header of the specified name, this method returns empty string. If there are multiple headers with the same name, this method returns the first head in the request. The header name is case insensitive. You can use this method with any request header.
name | a std::string specifying the header name |
string_view
containing the value of the requested header, or empty view if the request does not have a header of that name Implemented in servlet::http_request_wrapper.
|
pure virtual |
Fills the std::vector
with all the header values associated with the specified header name.
name | Header name to look up |
headers | The values for the specified header. These are the raw values so if multiple values are specified in a single header that will be returned as a single header value. |
Implemented in servlet::http_request_wrapper.
|
pure virtual |
Fills the std::vector
with all the request header values.
headers | The values for all the header values. |
Implemented in servlet::http_request_wrapper.
|
pure virtual |
Retrieves the body of the request as binary data using a std::istream
.
If this request has content type of "multipart/form-data" method get_multipart_input also can be called. If get_multipart_input has already been called than get_input_stream
will return the input stream for the current part of the multipart stream.
std::istream
object containing the body of the request Implemented in servlet::http_request_wrapper.
|
pure virtual |
Returns the Internet Protocol (IP) address of the interface on which the request was received.
string_view
containing the IP address on which the request was received. Implemented in servlet::http_request_wrapper.
|
pure virtual |
Returns the host name of the Internet Protocol (IP) interface on which the request was received.
string_view
containing the host name of the IP on which the request was received. Implemented in servlet::http_request_wrapper.
|
pure virtual |
Returns the Internet Protocol (IP) port number of the interface on which the request was received.
Implemented in servlet::http_request_wrapper.
|
pure virtual |
Returns the name of the HTTP method with which this request was made, for example, GET, POST, or PUT.
Same as the value of the CGI variable REQUEST_METHOD.
string_view
specifying the name of the method with which this request was made Implemented in servlet::http_request_wrapper.
|
pure virtual |
Retrieves the body of the request as binary data if the input is a multipart stream.
This method can only retrieve input only if the current request has content type of "multipart/form-data". It it not so use method get_input_stream to read the request's input, while this method will throw stack_io_exception
.
If this method is called after calling get_input_stream stack_io_exception
will be thrown.
std::istream
object containing the body of the request stack_io_exception | if this request is not a multipart or if the stream is already retrieved with get_input_stream |
Implemented in servlet::http_request_wrapper.
|
inline |
Returns the value of a request parameter as a reference to std::string
, or null
if the parameter does not exist.
You should only use this method when you are sure the parameter has only one value. If the parameter might have more than one value, use get_parameters(const StringType&).
If you use this method with a multivalued parameter, the value returned is equal to the first value in the array returned by get_parameters
.
StringType | a type comparable to std::string |
name | a StringType (might be std::string , string_view or const char* ) specifying the name of the parameter |
std::string
representing the single value of the parameter
|
pure virtual |
Returns all the parameters of this request.
Request parameters are extra information sent with the request. For HTTP servlets, parameters are contained in the query string or posted form data.
If the parameter data was sent in the request body, such as occurs with an HTTP POST request, then reading the body directly via get_input_stream or get_multipart_input can interfere with the execution of this method.
tree_map
representing this request's parameters Implemented in servlet::http_request_wrapper.
|
inline |
Returns all values of a request parameter as a reference to std::vector
, or null
if the parameters do not exist.
StringType | a type comparable to std::string |
name | a StringType (might be std::string , string_view or const char* ) specifying the name of the parameter |
std::vector
representing all the values of the parameter
|
pure virtual |
Returns any extra path information associated with the URL the client sent when it made this request.
The extra path information follows the servlet path but precedes the query string and will start with a "/" character.
This method returns empty view if there was no extra path information.
Same as the value of the CGI variable PATH_INFO.
string_view
, decoded by the web container, specifying extra path information that comes after the servlet path but before the query string in the request URL; or empty view if the URL does not have any extra path information Implemented in servlet::http_request_wrapper.
|
pure virtual |
Returns any extra path information after the servlet name but before the query string, and translates it to a real path.
Same as the value of the CGI variable PATH_TRANSLATED.
If the URL does not have any extra path information, this method returns empty view or the servlet container cannot translate the virtual path to a real path for any reason (such as when the web application is executed from an archive). The web container does not decode this string.
string_view
specifying the real path, or empty view if the URL does not have any extra path information Implemented in servlet::http_request_wrapper.
|
pure virtual |
Returns the name and version of the protocol the request uses in the form protocol/majorVersion.minorVersion, for example, HTTP/1.1.
For HTTP servlets, the value returned is the same as the value of the CGI variable SERVER_PROTOCOL
.
string_view
containing the protocol name and version number Implemented in servlet::http_request_wrapper.
|
pure virtual |
Returns the login of the user making this request, if the user has been authenticated, or empty view if the user has not been authenticated.
Whether the user name is sent with each subsequent request depends on the browser and type of authentication. Same as the value of the CGI variable REMOTE_USER.
string_view
specifying the login of the user making this request, or empty view if the user login is not known Implemented in servlet::http_request_wrapper.
|
pure virtual |
Returns the URI>
with which this request was called.
URI
Implemented in servlet::http_request_wrapper.
|
pure virtual |
Returns the name of the scheme used to make this request, for example, http
or https
.
Different schemes have different rules for constructing URLs, as noted in RFC 1738.
string_view
containing the name of the scheme used to make this request Implemented in servlet::http_request_wrapper.
|
pure virtual |
Returns the host name of the server to which the request was sent.
It is the value of the part before ":" in the Host
header value, if any, or the resolved server name, or the server IP address.
string_view
containing the name of the server Implemented in servlet::http_request_wrapper.
|
pure virtual |
Returns the port number to which the request was sent.
It is the value of the part after ":" in the Host
header value, if any, or the server port where the client connection was accepted on.
Implemented in servlet::http_request_wrapper.
|
pure virtual |
Returns the part of this request's URL that calls the servlet.
This path starts with a "/" character and includes either the servlet name or a path to the servlet, but does not include any extra path information or a query string. Same as the value of the CGI variable SCRIPT_NAME.
This method will return an empty string ("") if the servlet used to process this request was matched using the wildcard pattern.
string_view
containing the name or path of the servlet being called, as specified in the request URL, decoded, or an empty string if the servlet used to process the request is matched using the wildcard pattern. Implemented in servlet::http_request_wrapper.
|
pure virtual |
Returns the current http_session
associated with this request or, if there is no current session returns a new session.
To make sure the session is properly maintained, you must call this method before the response is committed. If the container is using cookies to maintain session integrity.
If the intent is to get only the session which already exists use method has_session() to ensure the session exists before calling this method.
http_session
associated with this request. Implemented in servlet::http_request_wrapper.
|
pure virtual |
Returns true
if the http_session
associated with this request exists.
true
if session associated with this request exists. Implemented in servlet::http_request_wrapper.
|
pure virtual |
Includes the response of the specified local URI into the current response.
Include processed internally and locally. The provided URI follows the same rules as redirectURI
in forward call.
includeURI | URI to include into current response |
from_context_path | true if the includeURI should be resolved against the current context path |
Implemented in servlet::http_request_wrapper.
|
pure virtual |
Returns true
if current request is multipart.
This method should be called before calling get_multipart_input to avoid exceptions. If this method returns false
get_input_stream should be called instead.
true
if current request is multipart. Implemented in servlet::http_request_wrapper.
|
pure virtual |
Returns a boolean indicating whether this request was made using a secure channel, such as HTTPS.
Implemented in servlet::http_request_wrapper.
|
pure virtual |
Returns information about SSL connection if it is established.
SSL information will be provided only if this request was made using secure channel (method is_secure() returns true
. If Otherwise nullptr
will be returned.
nullptr
Implemented in servlet::http_request_wrapper.