#include <network_webserver.h>
Interface to access more high level functions to read/send data with http connections. This functions are used by the web server to read and send data.
Public Member Functions | |
MAXON_METHOD Result< void > | OpenConnection (const String &address, const ThreadRef &thread, TimeValue connectionTimeOut, TimeValue sessiontimeOut) |
MAXON_METHOD String | GetMimeType (const Url &file) const |
MAXON_METHOD Result< CString > | CreateRequestHeader (HTTPMETHOD method, const UrlScheme &proxyScheme, Bool allowGzip, const String &hostName, const String &fileName, const String &queryParameter, const Range< Int64 > &range, const DataDictionary &optionalTags=DataDictionary(), const Block< const Char > &postData=Block< const Char >()) const |
MAXON_METHOD CString | CreateAnswerHeader (const String &mime, Int64 size, HTTPCODE code=HTTPCODE::OK, Int refresh=-1, const UniversalDateTime &expires=UniversalDateTime()) const |
MAXON_METHOD Result< DataDictionary > | ReadRequest () |
MAXON_METHOD Result< DataDictionary > | ReadAnswer () |
MAXON_METHOD Result< void > | SendHtmlFile (const Url &path, Bool usemime, Bool del=false, const UniversalDateTime &expires=UniversalDateTime()) |
MAXON_METHOD Result< void > | SendRedirect (const String &location) |
MAXON_METHOD Result< void > | HandleGet (const Url &basePath, const DataDictionary &request) |
MAXON_METHOD Result< DataDictionary > | HandlePost (const DataDictionary &request, const Url &upload) |
MAXON_METHOD Result< void > | LoadHtmlFile (const Url &file, String &html) |
MAXON_METHOD Result< void > | SubstInHtml (String &html, const DataDictionary &data) |
MAXON_METHOD Result< void > | LssHtmlFile (const Url &file, const DataDictionary &data, HTTPCODE code=HTTPCODE::OK, Int refresh=-1) |
MAXON_METHOD String | KillPercentChar (const String &name) |
MAXON_METHOD Result< void > | DoIt () |
Private Member Functions | |
MAXON_INTERFACE (NetworkHttpHandlerInterface, MAXON_REFERENCE_NORMAL, "net.maxon.interface.networkhttphandler") | |
|
private |
MAXON_METHOD Result<void> OpenConnection | ( | const String & | address, |
const ThreadRef & | thread, | ||
TimeValue | connectionTimeOut, | ||
TimeValue | sessiontimeOut | ||
) |
Opens an outgoing http connection.
[in] | address | Connection address e.g. "127.0.0.1:80" or "www.maxon.de:8080". |
[in] | thread | Reference to the handling thread. this thread is checked for the is cancelled state. |
[in] | connectionTimeOut | Timeout during the first connect. |
[in] | sessiontimeOut | Timeout for the session in seconds. if SOCKETTIMEOUT_INDEFINITELY is used a thread is needed. |
MAXON_METHOD String GetMimeType | ( | const Url & | file | ) | const |
Determines the mine type depending of the file.
[in] | file | File name of the file which type should be determined. |
MAXON_METHOD Result<CString> CreateRequestHeader | ( | HTTPMETHOD | method, |
const UrlScheme & | proxyScheme, | ||
Bool | allowGzip, | ||
const String & | hostName, | ||
const String & | fileName, | ||
const String & | queryParameter, | ||
const Range< Int64 > & | range, | ||
const DataDictionary & | optionalTags = DataDictionary() , |
||
const Block< const Char > & | postData = Block< const Char >() |
||
) | const |
Creates an http request header for a server. The default values for the header are: -"Host: <<hostName without port>>". -"Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*‍/*;q=0.8". -"User-Agent: Maxon Computer GmbH". -"Accept-Encoding: gzip" if range is empty. -"Content-Type: application/x-www-form-urlencoded" if isPost is true. -"Content-Length: <<postData.GetCount()>>" if isPost is true.
[in] | method | HTTP method. |
[in] | proxyScheme | An empty Id if this is not a proxy request. Otherwise the scheme (e.g. "http") of the request. In that case the "<<scheme>>://<<hostName>>" and "Proxy-Connection: keep-alive" will be added to the request. |
[in] | allowGzip | True if the request allows gzip compression. |
[in] | hostName | Host name with the port. In case of a proxy this name will be added to the request (e.g. "www.maxon.de:80"). This name without the port will be added to the "Host:" field. |
[in] | fileName | The path of the request. E.g. "/file/index.html". This name must start with a '/'. |
[in] | queryParameter | Query parameter for the request. Usually they will be concatenated with a '?' to the fileName. |
[in] | range | If range is not empty the request will add a "Range: bytes=@-" if maxRange is LIMIT<Int64>::MAX or "Range: bytes=@-@" otherwise. |
[in] | optionalTags | Optional parameter, if given each entry in the dictionary will be added to the request in the form: "key: value\r\n". |
[in] | postData | Optional parameter, if given this contains the block of data for the post request added to the post. |
MAXON_METHOD CString CreateAnswerHeader | ( | const String & | mime, |
Int64 | size, | ||
HTTPCODE | code = HTTPCODE::OK , |
||
Int | refresh = -1 , |
||
const UniversalDateTime & | expires = UniversalDateTime() |
||
) | const |
Creates an http answer header for a given mime type.
[in] | mime | Mime type of the data to be send. If not IsEmpty() the "content-type" field will be created. |
[in] | size | Size of the data to be send. If not 0 the "content-length" field will be created. |
[in] | code | Code the is used for the http header code. "HTTP/1.0 <<_code_>>" is generated. |
[in] | refresh | If > 0 the "refresh" field will be created. This forces the browser to reload the site every refresh seconds. |
[in] | expires | Defines the date when this object has to be reloaded. Use DateTime() to disable caching. |
MAXON_METHOD Result<DataDictionary> ReadRequest | ( | ) |
MAXON_METHOD Result<DataDictionary> ReadAnswer | ( | ) |
MAXON_METHOD Result<void> SendHtmlFile | ( | const Url & | path, |
Bool | usemime, | ||
Bool | del = false , |
||
const UniversalDateTime & | expires = UniversalDateTime() |
||
) |
MAXON_METHOD Result<void> SendRedirect | ( | const String & | location | ) |
MAXON_METHOD Result<void> HandleGet | ( | const Url & | basePath, |
const DataDictionary & | request | ||
) |
MAXON_METHOD Result<DataDictionary> HandlePost | ( | const DataDictionary & | request, |
const Url & | upload | ||
) |
MAXON_METHOD Result<void> LoadHtmlFile | ( | const Url & | file, |
String & | html | ||
) |
MAXON_METHOD Result<void> SubstInHtml | ( | String & | html, |
const DataDictionary & | data | ||
) |
MAXON_METHOD Result<void> LssHtmlFile | ( | const Url & | file, |
const DataDictionary & | data, | ||
HTTPCODE | code = HTTPCODE::OK , |
||
Int | refresh = -1 |
||
) |
MAXON_METHOD String KillPercentChar | ( | const String & | name | ) |
MAXON_METHOD Result<void> DoIt | ( | ) |