Rudiments
|
#include <httprequest.h>
Inherits input.
Inherited by urlhttprequest.
Classes | |
struct | parameterrequirement |
The httprequest class provides methods for accessing components of the http request.
Returns a null terminated list of the values corresponding to the variables returned from getAllVariables().
uint64_t httprequest::getAllVariableCount | ( | ) |
Returns the total number of variables - environment, parameters, files, and cookies.
Returns a null terminated list of all variables. The order of the list is the order the variables were received in.
|
virtual |
Matches the CONTENT_TYPE environment variable against "deniedcontenttypes" and "allowedcontenttypes" (in that order) using regular expression syntax. Returns true if the content type of the data posted by the client is allowed and false otherwise.
This method may be overriden to provide customized content-type-based security.
uint64_t httprequest::getCookieCount | ( | ) |
Returns the number of cookies collected.
Returns a null terminated list of values corresponding to the variables returned from getCookieVariables().
Returns a null terminated list of cookie variables. The order of the list is the order the variables were received in.
Returns a null terminated list of environment variable values.
Returns the value of the environment variable "name".
uint64_t httprequest::getEnvironmentVariableCount | ( | ) |
Returns the number of environment variables.
Returns a null terminated list of environment variables.
uint64_t httprequest::getFileCount | ( | ) |
Returns the number of posted files.
Returns a null terminated list of file names. The order of the list is the order in which the file parameters were received.
Returns the filename passed in from file parameter "name".
Returns the mime type of the file parameter "name".
Returns the filename of the local file created when file parameter "name" was passed in.
|
virtual |
Matches the REMOTE_ADDR environment variable against "deniedips" and "allowedips" (in that order) using regular expression syntax. Returns true if the client's IP address is allowed and false otherwise.
This method may be overriden to provide customized ip-based security.
|
virtual |
Matches the REQUEST_METHOD environment variable against "deniedmethods" and "allowedmethods" (in that order) using regular expression syntax. Returns true if the request method used by the client is allowed and false otherwise.
This method may be overriden to provide customized request-method-based security.
uint64_t httprequest::getParameterCount | ( | ) |
Returns the number of parameters.
Returns all parameters formatted as an escaped get string into "container" with the exception of a NULL terminated list of exceptions. If "container" is NULL, the list is written to the browser.
void httprequest::getParametersAsHiddenVariables | ( | output * | container, |
const char *const * | excepcions ) |
Returns all parameters formatted as a list of hidden variables into "container" with the exception of a NULL terminated list of exceptions passed in after "container". If "container" is NULL, the list is written to the browser.
Returns a null terminated list of values corresponding to the variables returned from getParameterVariables().
Returns a null terminated list of parameter variables. The order of the list is the order the variables were received in.
|
virtual |
Matches the HTTP_REFERER environment variable against "deniedreferers" and "allowedreferers" (in that order) using regular expression syntax. Returns true if the referrer is permitted and false otherwise.
This method may be overriden to provide customized referrer-based security.
bool httprequest::getRequiredParametersWereProvided | ( | parameterrequirement ** | pr | ) |
Reads through the NULL terminated list of parameter requirements. Returns true if the parameters meet the requirements and false if they did not.
Each parameterrequirement contains a parameter variable name and a boolean value indicating whether that variable can be empty or not.
For example. The following call requires that "first", "last", "address", "city", "state" and "phone" be present but allows "address", "city" and "state" to be blank.
parameterrequirement *pr[]={{"first",false}, {"last",false}, {"address",true}, {"city",true}, {"state",true}, {"phone",false}, NULL}; success=requiredParameters(pr);
|
virtual |
Reads "size" bytes from the data posted by the client into "buffer". Returns the number of bytes that were successfully read or RESULT_ERROR if an error occurred.
Note that all read() methods return 0 (EOF) when the REQUEST_METHOD environment vairable is "get" or "head", as no data will have been posted, or when the REQUEST_METHOD environment variable is "post" and the CONTENT_TYPE environment variable is either "application/x-www-form-urlencoded" or "multipart-form-data", as in those cases, the posted data will have been processed internally.
Implements input.
|
virtual |
Reads a byte from the data posted by the client into "character". Returns the number of bytes that were successfully read or RESULT_ERROR if an error occurred.
Note that all read() methods return 0 (EOF) when the REQUEST_METHOD environment vairable is "get" or "head", as no data will have been posted, or when the REQUEST_METHOD environment variable is "post" and the CONTENT_TYPE environment variable is either "application/x-www-form-urlencoded" or "multipart-form-data", as in those cases, the posted data will have been processed internally.
Implements input.
Reads "length" characters from the data posted by the client into "buffer". Returns the number of bytes that were successfully read or RESULT_ERROR if an error occurred.
Note that all read() methods return 0 (EOF) when the REQUEST_METHOD environment vairable is "get" or "head", as no data will have been posted, or when the REQUEST_METHOD environment variable is "post" and the CONTENT_TYPE environment variable is either "application/x-www-form-urlencoded" or "multipart-form-data", as in those cases, the posted data will have been processed internally.
Implements input.
|
virtual |
Reads a character from the data posted by the client into "character". Returns the number of bytes that were successfully read or RESULT_ERROR if an error occurred.
Note that all read() methods return 0 (EOF) when the REQUEST_METHOD environment vairable is "get" or "head", as no data will have been posted, or when the REQUEST_METHOD environment variable is "post" and the CONTENT_TYPE environment variable is either "application/x-www-form-urlencoded" or "multipart-form-data", as in those cases, the posted data will have been processed internally.
Implements input.
|
virtual |
Reads a double-precision floating point number from the data posted by the client into "number". Returns the number of bytes that were successfully read or RESULT_ERROR if an error occurred.
Note that all read() methods return 0 (EOF) when the REQUEST_METHOD environment vairable is "get" or "head", as no data will have been posted, or when the REQUEST_METHOD environment variable is "post" and the CONTENT_TYPE environment variable is either "application/x-www-form-urlencoded" or "multipart-form-data", as in those cases, the posted data will have been processed internally.
Implements input.
|
virtual |
Reads a floating point number from the data posted by the client into "number". Returns the number of bytes that were successfully read or RESULT_ERROR if an error occurred.
Note that all read() methods return 0 (EOF) when the REQUEST_METHOD environment vairable is "get" or "head", as no data will have been posted, or when the REQUEST_METHOD environment variable is "post" and the CONTENT_TYPE environment variable is either "application/x-www-form-urlencoded" or "multipart-form-data", as in those cases, the posted data will have been processed internally.
Implements input.
|
virtual |
Reads a 16-bit integer from the data posted by the client into "number". Returns the number of bytes that were successfully read or RESULT_ERROR if an error occurred.
Note that all read() methods return 0 (EOF) when the REQUEST_METHOD environment vairable is "get" or "head", as no data will have been posted, or when the REQUEST_METHOD environment variable is "post" and the CONTENT_TYPE environment variable is either "application/x-www-form-urlencoded" or "multipart-form-data", as in those cases, the posted data will have been processed internally.
Implements input.
|
virtual |
Reads a 32-bit integer from the data posted by the client into "number". Returns the number of bytes that were successfully read or RESULT_ERROR if an error occurred.
Note that all read() methods return 0 (EOF) when the REQUEST_METHOD environment vairable is "get" or "head", as no data will have been posted, or when the REQUEST_METHOD environment variable is "post" and the CONTENT_TYPE environment variable is either "application/x-www-form-urlencoded" or "multipart-form-data", as in those cases, the posted data will have been processed internally.
Implements input.
|
virtual |
Reads a 64-bit integer from the data posted by the client into "number". Returns the number of bytes that were successfully read or RESULT_ERROR if an error occurred.
Note that all read() methods return 0 (EOF) when the REQUEST_METHOD environment vairable is "get" or "head", as no data will have been posted, or when the REQUEST_METHOD environment variable is "post" and the CONTENT_TYPE environment variable is either "application/x-www-form-urlencoded" or "multipart-form-data", as in those cases, the posted data will have been processed internally.
Implements input.
|
virtual |
Reads a 16-bit unsigned integer from the data posted by the client into "number". Returns the number of bytes that were successfully read or RESULT_ERROR if an error occurred.
Note that all read() methods return 0 (EOF) when the REQUEST_METHOD environment vairable is "get" or "head", as no data will have been posted, or when the REQUEST_METHOD environment variable is "post" and the CONTENT_TYPE environment variable is either "application/x-www-form-urlencoded" or "multipart-form-data", as in those cases, the posted data will have been processed internally.
Implements input.
|
virtual |
Reads a 32-bit unsigned integer from the data posted by the client into "number". Returns the number of bytes that were successfully read or RESULT_ERROR if an error occurred.
Note that all read() methods return 0 (EOF) when the REQUEST_METHOD environment vairable is "get" or "head", as no data will have been posted, or when the REQUEST_METHOD environment variable is "post" and the CONTENT_TYPE environment variable is either "application/x-www-form-urlencoded" or "multipart-form-data", as in those cases, the posted data will have been processed internally.
Implements input.
|
virtual |
Reads a 64-bit unsigned integer from the data posted by the client into "number". Returns the number of bytes that were successfully read or RESULT_ERROR if an error occurred.
Note that all read() methods return 0 (EOF) when the REQUEST_METHOD environment vairable is "get" or "head", as no data will have been posted, or when the REQUEST_METHOD environment variable is "post" and the CONTENT_TYPE environment variable is either "application/x-www-form-urlencoded" or "multipart-form-data", as in those cases, the posted data will have been processed internally.
Implements input.
Reads "length" characters from the data posted by the client into "buffer". Returns the number of bytes that were successfully read or RESULT_ERROR if an error occurred.
Note that all read() methods return 0 (EOF) when the REQUEST_METHOD environment vairable is "get" or "head", as no data will have been posted, or when the REQUEST_METHOD environment variable is "post" and the CONTENT_TYPE environment variable is either "application/x-www-form-urlencoded" or "multipart-form-data", as in those cases, the posted data will have been processed internally.
Implements input.
|
virtual |
Reads a character from the data posted by the client into "character". Returns the number of bytes that were successfully read or RESULT_ERROR if an error occurred.
Note that all read() methods return 0 (EOF) when the REQUEST_METHOD environment vairable is "get" or "head", as no data will have been posted, or when the REQUEST_METHOD environment variable is "post" and the CONTENT_TYPE environment variable is either "application/x-www-form-urlencoded" or "multipart-form-data", as in those cases, the posted data will have been processed internally.
Implements input.
|
virtual |
Reads "length" characters from the data posted by the client into "buffer". Returns the number of bytes that were successfully read or RESULT_ERROR if an error occurred.
Note that all read() methods return 0 (EOF) when the REQUEST_METHOD environment vairable is "get" or "head", as no data will have been posted, or when the REQUEST_METHOD environment variable is "post" and the CONTENT_TYPE environment variable is either "application/x-www-form-urlencoded" or "multipart-form-data", as in those cases, the posted data will have been processed internally.
Implements input.
|
virtual |
Reads a character from the data posted by the client into "character". Returns the number of bytes that were successfully read or RESULT_ERROR if an error occurred.
Note that all read() methods return 0 (EOF) when the REQUEST_METHOD environment vairable is "get" or "head", as no data will have been posted, or when the REQUEST_METHOD environment variable is "post" and the CONTENT_TYPE environment variable is either "application/x-www-form-urlencoded" or "multipart-form-data", as in those cases, the posted data will have been processed internally.
Implements input.
void httprequest::removeTempFiles | ( | ) |
Removes all temporary files that were created when parsing the request.
Creates a new cookie with name "name" and value "value" or updates an existing cookie "name" to have value "value".
Creates a new environment variable with name "name" and value "value" or updates an existing environment variable "name" to have value "value".
bool httprequest::setFileParameter | ( | const char * | name, |
const char * | filename, | ||
const char * | tempfilename, | ||
const char * | mimetype ) |
Updates file parameter with name "name", to filename "filename", temporary filename "tempfilename" and mime-type "mimetype". If the file parameter doesn't already exist, then no action is taken.
Creates a new parameter with name "name" and value "value" or updates an existing parameter "name" to have value "value".
void httprequest::writeEnvironment | ( | ) |
Writes all environment variables to the browser. Similar to running "env" on the command line.
Writes all environment variables, parameters, file parameters, and cookies to the browser.
Reimplemented in urlhttprequest.