8 #ifndef SERVLET_REQUEST_H
9 #define SERVLET_REQUEST_H
15 #include <servlet/cookie.h>
16 #include <servlet/session.h>
17 #include <servlet/ssl.h>
25 class multipart_input;
81 virtual const std::map<std::string, std::vector<std::string>, std::less<>>&
get_parameters() = 0;
93 virtual const std::map<string_view, string_view, std::less<>>&
get_env() = 0;
137 template<
typename StringType>
140 const std::map<std::string, std::vector<std::string>, std::less<>>& params =
get_parameters();
141 auto it = params.find(name);
160 template<
typename StringType>
163 const std::map<std::string, std::vector<std::string>, std::less<>>& params =
get_parameters();
164 auto it = params.find(name);
194 virtual const std::vector<cookie>&
get_cookies() = 0;
262 virtual string_view
get_header(
const std::string& name)
const = 0;
315 virtual void get_headers(
const std::string& name, std::vector<std::string>& headers)
const = 0;
322 virtual void get_headers(std::vector<std::pair<std::string, std::string>>& headers)
const = 0;
479 virtual void forward(
const std::string &redirectURI,
bool from_context_path =
true) = 0;
494 virtual int include(
const std::string &includeURI,
bool from_context_path =
true) = 0;
605 virtual const std::map<std::string, std::vector<std::string>, std::less<>>&
get_headers()
const = 0;
617 template<
typename StringType>
620 const std::map<std::string, std::vector<std::string>, std::less<>>& headers =
get_headers();
621 auto it = headers.find(name);
635 template<
typename StringType>
638 const std::map<std::string, std::vector<std::string>, std::less<>>& headers =
get_headers();
639 auto it = headers.find(name);
722 const std::map<std::string, std::vector<std::string>, std::less<>>&
get_parameters()
override
724 const std::map<string_view, string_view, std::less<>>&
get_env()
override {
return _req.
get_env(); };
740 void get_headers(
const std::string& name, std::vector<std::string>& headers)
const override
742 void get_headers(std::vector<std::pair<std::string, std::string>>& headers)
const override
763 void forward(
const std::string &redirectURL,
bool from_context_path =
true)
override
764 { _req.
forward(redirectURL, from_context_path); }
765 int include(
const std::string &includeURL,
bool from_context_path =
true)
override
766 {
return _req.
include(includeURL, from_context_path); }
807 #endif // SERVLET_REQUEST_H
virtual multipart_input & get_multipart_input()=0
Retrieves the body of the request as binary data if the input is a multipart stream.
bool has_session() override
Returns true if the http_session associated with this request exists.
Definition: request.h:769
string_view get_local_host() const override
Returns the host name of the Internet Protocol (IP) interface on which the request was received...
Definition: request.h:757
long get_date_header(const std::string &name) const override
Returns the value of the specified request header as a long value that represents a Date object...
Definition: request.h:735
multipart_input & get_multipart_input() override
Retrieves the body of the request as binary data if the input is a multipart stream.
std::istream & get_input_stream() override
Retrieves the body of the request as binary data using a std::istream.
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...
Definition: request.h:138
virtual string_view get_client_addr() const =0
Returns the Internet Protocol (IP) address of the client or last proxy that sent the request...
Defines an object to provide client request information to a servlet.
Definition: request.h:35
const URI & get_request_uri() const override
Returns the URI> with which this request was called.
Definition: request.h:732
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.
string_view get_path_translated() const override
Returns any extra path information after the servlet name but before the query string, and translates it to a real path.
Definition: request.h:747
string_view get_method() const override
Returns the name of the HTTP method with which this request was made, for example, GET, POST, or PUT.
Definition: request.h:745
virtual const std::vector< cookie > & get_cookies()=0
Returns an array containing all of the cookie objects the client sent with this request.
virtual long get_content_length() const =0
Returns the length, in bytes, of the request body and made available by the input stream...
Optional reference implementation.
Definition: optional.h:221
virtual string_view get_scheme() const =0
Returns the name of the scheme used to make this request, for example, http or https.
string_view get_servlet_path() const override
Returns the part of this request's URL that calls the servlet.
Definition: request.h:731
string_view get_content_type() const override
Returns the MIME type of the body of the request, or empty string if the type is not known...
Definition: request.h:737
Contains definition of URI class and related structures and operations.
string_view get_header(const std::string &name) const override
Returns the value of the specified request header as a std::string.
Definition: request.h:734
virtual string_view get_server_name() const =0
Returns the host name of the server to which the request was sent.
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...
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...
void get_headers(std::vector< std::pair< std::string, std::string >> &headers) const override
Fills the std::vector with all the request header values.
Definition: request.h:742
uint16_t get_server_port() const override
Returns the port number to which the request was sent.
Definition: request.h:760
Definitions for custom implementation of std::istream and std::ostream objects.
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...
Definition: request.h:161
long get_content_length() const override
Returns the length, in bytes, of the request body and made available by the input stream...
Definition: request.h:738
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.
virtual bool has_session()=0
Returns true if the http_session associated with this request exists.
Covenience class on top of associative container to facilitate work with value type std::any...
Definition: any_map.h:84
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...
virtual const URI & get_request_uri() const =0
Returns the URI> with which this request was called.
string_view get_local_addr() const override
Returns the Internet Protocol (IP) address of the interface on which the request was received...
Definition: request.h:756
string_view get_client_addr() const override
Returns the Internet Protocol (IP) address of the client or last proxy that sent the request...
Definition: request.h:751
const tree_any_map & get_attributes() const override
Const version of call get_attributes() const.
Definition: request.h:720
Provides a convenient implementation of the http_request interface that can be subclassed by develope...
Definition: request.h:696
virtual in_filter * filter()
Provides input filter for the http_request::get_input_stream or http_request::get_multipart_input.
Definition: request.h:797
uint16_t get_client_port() const override
Returns the Internet Protocol (IP) source port of the client or last proxy that sent the request...
Definition: request.h:753
std::shared_ptr< SSL_information > ssl_information() override
Returns information about SSL connection if it is established.
Definition: request.h:726
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...
string_view get_client_host() const override
Returns the fully qualified name of the client or the last proxy that sent the request if available...
Definition: request.h:752
tree_any_map & get_attributes() override
Returns the attributes map associated with this request.
Definition: request.h:719
virtual std::istream & get_input_stream()=0
Retrieves the body of the request as binary data using a std::istream.
string_view get_remote_user() const override
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.
Definition: request.h:754
const std::vector< cookie > & get_cookies() override
Returns an array containing all of the cookie objects the client sent with this request.
Definition: request.h:729
bool is_multipart() const override
Returns true if current request is multipart.
Definition: request.h:772
virtual tree_any_map & get_attributes()=0
Returns the attributes map associated with this request.
const http_request & get_wrapped_request() const
Returns wrapped request innstance.
Definition: request.h:717
void get_headers(const std::string &name, std::vector< std::string > &headers) const override
Fills the std::vector with all the header values associated with the specified header name...
Definition: request.h:740
http_request_wrapper(http_request &req)
Constructs a request object wrapping the given request.
Definition: request.h:704
Provides a way to identify a user across more than one page request or visit to a Web site and to sto...
Definition: session.h:56
virtual void invalidate_session()=0
Invalidates the session assosiated with this request if it exists.
virtual bool is_multipart() const =0
Returns true if current request is multipart.
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.
string_view get_path_info() const override
Returns any extra path information associated with the URL the client sent when it made this request...
Definition: request.h:733
virtual void forward(const std::string &redirectURI, bool from_context_path=true)=0
Redirects the request to a specified local URI within the server.
virtual uint16_t get_local_port() const =0
Returns the Internet Protocol (IP) port number of the interface on which the request was received...
int include(const std::string &includeURL, bool from_context_path=true) override
Includes the response of the specified local URI into the current response.
Definition: request.h:765
Represents a Uniform Resource Identifier (URI) reference.
Definition: uri.h:258
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.
void invalidate_session() override
Invalidates the session assosiated with this request if it exists.
Definition: request.h:770
virtual string_view get_header(const std::string &name) const =0
Returns the value of the specified request header as a std::string.
bool is_secure() override
Returns a boolean indicating whether this request was made using a secure channel, such as HTTPS.
Definition: request.h:725
string_view get_scheme() const override
Returns the name of the scheme used to make this request, for example, http or https.
Definition: request.h:748
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.
Contains definitions for the logging framework.
http_request & get_wrapped_request()
Returns wrapped request innstance.
Definition: request.h:712
string_view get_context_path() const override
Returns the portion of the request URI that indicates the context of the request. ...
Definition: request.h:730
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...
virtual const std::map< string_view, string_view, std::less<> > & get_env()=0
Returns all the environment variables accessible from this request.
virtual string_view get_local_addr() const =0
Returns the Internet Protocol (IP) address of the interface on which the request was received...
virtual string_view get_context_path() const =0
Returns the portion of the request URI that indicates the context of the request. ...
string_view get_auth_type() override
Returns the name of the authentication scheme used to protect the servlet.
Definition: request.h:728
string_view get_protocol() const override
Returns the name and version of the protocol the request uses in the form protocol/majorVersion.minorVersion, for example, HTTP/1.1.
Definition: request.h:749
string_view get_server_name() const override
Returns the host name of the server to which the request was sent.
Definition: request.h:761
Definitions for input and output filters and related types.
const std::map< string_view, string_view, std::less<> > & get_env() override
Returns all the environment variables accessible from this request.
Definition: request.h:724
http_session & get_session() override
Returns the current http_session associated with this request or, if there is no current session retu...
Definition: request.h:768
virtual string_view get_local_host() const =0
Returns the host name of the Internet Protocol (IP) interface on which the request was received...
virtual http_session & get_session()=0
Returns the current http_session associated with this request or, if there is no current session retu...
void forward(const std::string &redirectURL, bool from_context_path=true) override
Redirects the request to a specified local URI within the server.
Definition: request.h:763
uint16_t get_local_port() const override
Returns the Internet Protocol (IP) port number of the interface on which the request was received...
Definition: request.h:758
virtual bool is_secure()=0
Returns a boolean indicating whether this request was made using a secure channel, such as HTTPS.
virtual const std::map< std::string, std::vector< std::string >, std::less<> > & get_parameters()=0
Returns all the parameters of this request.
virtual string_view get_servlet_path() const =0
Returns the part of this request's URL that calls the servlet.
virtual std::shared_ptr< SSL_information > ssl_information()=0
Returns information about SSL connection if it is established.
virtual uint16_t get_server_port() const =0
Returns the port number to which the request was sent.
virtual string_view get_auth_type()=0
Returns the name of the authentication scheme used to protect the servlet.
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...
Abstract interface for input filter.
Definition: io_filter.h:93
const std::map< std::string, std::vector< std::string >, std::less<> > & get_parameters() override
Returns all the parameters of this request.
Definition: request.h:722