Internal Web Server and functions to carry out operations of it. More...
Go to the source code of this file.
Classes | |
struct | SendInstruction |
Send instruction. More... | |
Macros | |
#define | X_USER_AGENT "redsonic" |
Can be overwritten by configure CFLAGS argument. | |
Functions | |
void | web_server_init () |
Initilialize root directory for web server and different documents. | |
int | web_server_set_alias (const char *a_alias_name, const char *a_alias_content, size_t a_alias_content_length, time_t a_last_modified) |
Replaces current alias with the given alias. | |
int | web_server_set_root_dir (const char *root_dir) |
Assign the path to the global Document root directory. | |
int | web_server_set_cors (const char *cors_string) |
Assign the Access-Control-Allow-Origin specfied by the input const char* cors_string parameterto the global CORS string. | |
void | web_server_callback (http_parser_t *a_parser, http_message_t *a_req, SOCKINFO *a_info) |
Main entry point into web server. | |
void | SetHTTPGetCallback (MiniServerCallback callback) |
Set HTTP Get Callback. | |
void | web_server_destroy () |
Release memory allocated for the global web server root directory and the global XML document. | |
Variables | |
membuffer | gDocumentRootDir |
membuffer | gWebserverCorsString |
Internal Web Server and functions to carry out operations of it.
Definition in file webserver.hpp.
struct SendInstruction |
Send instruction.
Definition at line 50 of file webserver.hpp.
#define X_USER_AGENT "redsonic" |
Can be overwritten by configure CFLAGS argument.
If not already defined, the {X_USER_AGENT
} constant specifies the value of the X-User-Agent: HTTP header. The value "redsonic" is needed for the DSM-320. See https://sourceforge.net/forum/message.php?msg_id=3166856 for more information.
Definition at line 87 of file webserver.hpp.
void web_server_init | ( | ) |
Initilialize root directory for web server and different documents.
Initilialize the different documents. Initialize the memory for root directory for web server. Sets bWebServerState to WEB_SERVER_ENABLED.
Definition at line 1518 of file webserver.cpp.
int web_server_set_alias | ( | const char * | a_alias_name, |
const char * | a_alias_content, | ||
size_t | a_alias_content_length, | ||
time_t | a_last_modified | ||
) |
Replaces current alias with the given alias.
To remove the current alias, set a_alias_name to nullptr.
UPNP_E_SUCCESS
UPNP_E_INVALID_ARGUMENT
[in] | a_alias_name | Pointer to webserver name of alias for a copy; the ownership of this C string with terminating '\0' remains by the caller. He is still responsible to manage it (e.g. deallocating if allocated etc.). |
[in,out] | a_alias_content | Pointer to the xml doc. This string must be allocated by the caller. Ownership of this argument is then taken over by the web server to manage it, in particular also deallocate it. The caller hasn't to worry about memory management. |
[in,out] | a_alias_content_length | Length of alias body in bytes. Document can also contain '\0' characters within its length. |
[in] | a_last_modified | Time when contents of alias were last changed (local time). |
Definition at line 1538 of file webserver.cpp.
int web_server_set_root_dir | ( | const char * | root_dir | ) |
Assign the path to the global Document root directory.
Also check for path names ending in '/'.
[in] | root_dir | String having the root directory for the document. |
Definition at line 1546 of file webserver.cpp.
int web_server_set_cors | ( | const char * | cors_string | ) |
Assign the Access-Control-Allow-Origin specfied by the input const char* cors_string parameterto the global CORS string.
[in] | cors_string | String having the Access-Control-Allow-Origin string. |
Definition at line 1564 of file webserver.cpp.
void web_server_callback | ( | http_parser_t * | a_parser, |
http_message_t * | a_req, | ||
SOCKINFO * | a_info | ||
) |
Main entry point into web server.
Handles HTTP GET and HEAD requests.
[in] | a_parser | . |
[in] | a_req | . |
[in,out] | a_info | . |
Definition at line 1574 of file webserver.cpp.
void SetHTTPGetCallback | ( | MiniServerCallback | callback | ) |
Set HTTP Get Callback.
[in] | callback | HTTP Callback to be invoked. |
Definition at line 1645 of file webserver.cpp.
void web_server_destroy | ( | ) |
Release memory allocated for the global web server root directory and the global XML document.
Resets the flag bWebServerState to WEB_SERVER_DISABLED.
Definition at line 1650 of file webserver.cpp.
|
inline |
Global variable. A local dir which serves as webserver root.
Definition at line 45 of file webserver.hpp.
|
inline |
Global variable. A string which is set in the header field.
Definition at line 47 of file webserver.hpp.