NetworkHttpHandlerInterface Class Reference

#include <network_webserver.h>

Inheritance diagram for NetworkHttpHandlerInterface:

Detailed Description

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< CStringCreateRequestHeader (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")

Member Function Documentation


MAXON_INTERFACE ( NetworkHttpHandlerInterface  ,

◆ OpenConnection()

MAXON_METHOD Result<void> OpenConnection ( const String address,
const ThreadRef thread,
TimeValue  connectionTimeOut,
TimeValue  sessiontimeOut 

Opens an outgoing http connection.

[in]addressConnection address e.g. "" or "".
[in]threadReference to the handling thread. this thread is checked for the is cancelled state.
[in]connectionTimeOutTimeout during the first connect.
[in]sessiontimeOutTimeout for the session in seconds. if SOCKETTIMEOUT_INDEFINITELY is used a thread is needed.
True if the connection could be opened.

◆ GetMimeType()

MAXON_METHOD String GetMimeType ( const Url file) const

Determines the mine type depending of the file.

[in]fileFile name of the file which type should be determined.
Mime type. E.g. "image/jpg".

◆ CreateRequestHeader()

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,*&zwj;/*;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]methodHTTP method.
[in]proxySchemeAn 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]allowGzipTrue if the request allows gzip compression.
[in]hostNameHost name with the port. In case of a proxy this name will be added to the request (e.g. ""). This name without the port will be added to the "Host:" field.
[in]fileNameThe path of the request. E.g. "/file/index.html". This name must start with a '/'.
[in]queryParameterQuery parameter for the request. Usually they will be concatenated with a '?' to the fileName.
[in]rangeIf range is not empty the request will add a "Range: bytes=@-" if maxRange is LIMIT<Int64>::MAX or "Range: bytes=@-@" otherwise.
[in]optionalTagsOptional parameter, if given each entry in the dictionary will be added to the request in the form: "key: value\r\n".
[in]postDataOptional parameter, if given this contains the block of data for the post request added to the post.
The string with a valid http request header.

◆ CreateAnswerHeader()

MAXON_METHOD CString CreateAnswerHeader ( const String mime,
Int64  size,
Int  refresh = -1,
const UniversalDateTime expires = UniversalDateTime() 
) const

Creates an http answer header for a given mime type.

[in]mimeMime type of the data to be send. If not IsEmpty() the "content-type" field will be created.
[in]sizeSize of the data to be send. If not 0 the "content-length" field will be created.
[in]codeCode the is used for the http header code. "HTTP/1.0 <<_code_>>" is generated.
[in]refreshIf > 0 the "refresh" field will be created. This forces the browser to reload the site every refresh seconds.
[in]expiresDefines the date when this object has to be reloaded. Use DateTime() to disable caching.
The string with a valid http header.

◆ ReadRequest()

MAXON_METHOD Result<DataDictionary> ReadRequest ( )

◆ ReadAnswer()

MAXON_METHOD Result<DataDictionary> ReadAnswer ( )

◆ SendHtmlFile()

MAXON_METHOD Result<void> SendHtmlFile ( const Url path,
Bool  usemime,
Bool  del = false,
const UniversalDateTime expires = UniversalDateTime() 

◆ SendRedirect()

MAXON_METHOD Result<void> SendRedirect ( const String location)

◆ HandleGet()

MAXON_METHOD Result<void> HandleGet ( const Url basePath,
const DataDictionary &  request 

◆ HandlePost()

MAXON_METHOD Result<DataDictionary> HandlePost ( const DataDictionary &  request,
const Url upload 

◆ LoadHtmlFile()

MAXON_METHOD Result<void> LoadHtmlFile ( const Url file,
String html 

◆ SubstInHtml()

MAXON_METHOD Result<void> SubstInHtml ( String html,
const DataDictionary &  data 

◆ LssHtmlFile()

MAXON_METHOD Result<void> LssHtmlFile ( const Url file,
const DataDictionary &  data,
Int  refresh = -1 

◆ KillPercentChar()

MAXON_METHOD String KillPercentChar ( const String name)

◆ DoIt()

MAXON_METHOD Result<void> DoIt ( )