DiCE API nvidia_logo_transpbg.gif Up
mi::http::IFactory Class Referenceabstract

The factory can be used to instantiate the built-in HTTP classes. More...

#include <http.h>

Inheritance diagram for mi::http::IFactory:

Public Member Functions

virtual IServercreate_server ()=0
 Creates a new HTTP server. More...
 
virtual IRequest_handlercreate_file_handler (const char *root_url, const char *root_path, bool is_recursive=true)=0
 Creates a new file handler for the server. More...
 
virtual IRequest_handlercreate_redirect_handler (const char *source_url, const char *target_url)=0
 Creates a new redirect handler which will redirect requests to a certain URL to a new URL. More...
 
virtual IResponse_handlercreate_log_handler (const char *path)=0
 Creates a new log handler. More...
 
virtual IResponse_handlercreate_chunked_encoding_handler ()=0
 Creates a new chunked encoding handler. More...
 
virtual IWeb_socketcreate_client_web_socket (const char *web_socket_address, Float32 connect_timeout)=0
 Creates a client-side WebSocket connection that will attempt to establish a connection to the specified server's address and will send WebSocket requests to the specified URL. More...
 
- Public Member Functions inherited from mi::base::IInterface
virtual Uint32 retain () const =0
 Increments the reference count. More...
 
virtual Uint32 release () const =0
 Decrements the reference count. More...
 
virtual const IInterfaceget_interface (const Uuid &interface_id) const =0
 Acquires a const interface from another. More...
 
template<class T>
const T * get_interface () const
 Acquires a const interface from another. More...
 
virtual IInterfaceget_interface (const Uuid &interface_id)=0
 Acquires a mutable interface from another. More...
 
template<class T>
T * get_interface ()
 Acquires a mutable interface from another. More...
 
virtual Uuid get_iid () const =0
 Returns the interface ID of the most derived interface. More...
 

Additional Inherited Members

- Public Types inherited from mi::base::Interface_declare< 0xddded154, ... >
typedef Interface_declare< id1, ... > Self
 Own type. More...
 
typedef Uuid_t< id1, ... > IID
 Declares the interface ID (IID) of this interface. More...
 
- Public Types inherited from mi::base::IInterface
typedef Uuid_t<0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0> IID
 Declares the interface ID (IID) of this interface. More...
 
- Static Public Member Functions inherited from mi::base::Interface_declare< 0xddded154, ... >
static bool compare_iid (const Uuid &iid)
 Compares the interface ID iid against the interface ID of this interface and of its ancestors. More...
 
- Static Public Member Functions inherited from mi::base::IInterface
static bool compare_iid (const Uuid &iid)
 Compares the interface ID iid against the interface ID of this interface. More...
 

Detailed Description

The factory can be used to instantiate the built-in HTTP classes.

In addition to the HTTP server it can create a number of built-in request and response handlers. Those handlers need to be installed with one or more servers using the server's install() methods. Unless indicated otherwise a handler obtained from the factory function can be installed to multiple HTTP servers.

Member Function Documentation

 create_chunked_encoding_handler()

virtual IResponse_handler * mi::http::IFactory::create_chunked_encoding_handler ( )
pure virtual

Creates a new chunked encoding handler.

If installed on a server it will allow to keep connections alive even if the size of the generated content is not know in advance. This is done by installing a data handler on a connection if the response does not contain the data size when it is sent. The response handler will modify the response and then modify all data passed to the client to be sent in chunks. This handler needs to be installed as the last response handler to work correctly. Exempt from this are response handlers which do not change the data on the way to its clients, e.g., the log handler.

The handler needs to be installed with the desired server using mi::http::IServer::install(IResponse_handler*).

 create_client_web_socket()

virtual IWeb_socket * mi::http::IFactory::create_client_web_socket ( const char *  web_socket_address,
Float32  connect_timeout 
)
pure virtual

Creates a client-side WebSocket connection that will attempt to establish a connection to the specified server's address and will send WebSocket requests to the specified URL.

Parameters
web_socket_addressThe address to be connected to.
connect_timeoutThe timeout interval in seconds when attempting to connect to a server.
Returns
A valid WebSocket if a connection can be established to the server, or NULL in case of failures.
Note
The WebSocket address must have one of the following two formats:
  • "ws://host_address[:host_port]/url" for insecure connections, or
  • "wss://host_address[:host_port]/url" for secure connections.

 create_file_handler()

virtual IRequest_handler * mi::http::IFactory::create_file_handler ( const char *  root_url,
const char *  root_path,
bool  is_recursive = true 
)
pure virtual

Creates a new file handler for the server.

The handler will map a given file or directory into the URL namespace at the root_url.

The handler needs to be installed with the desired server using mi::http::IServer::install(IRequest_handler*).

Parameters
root_urlThe URL needs to start with this prefix to be served by the handler.
root_pathWhen a matching URL is found root_url is replaced by this argument to get the path of a file to be served. If this file can be opened for reading, it will be sent to the client.
is_recursiveIndicates whether handler serves only a single file or a directory tree.
Returns
The new request handler.

 create_log_handler()

virtual IResponse_handler * mi::http::IFactory::create_log_handler ( const char *  path)
pure virtual

Creates a new log handler.

This handler will write a request log to a file with a given path. The file format of the log file is the so called 'Combined log format' used by various HTTP servers.

The handler needs to be installed with the desired server using mi::http::IServer::install(IResponse_handler*).

Parameters
pathPath of the log file to be written.

 create_redirect_handler()

virtual IRequest_handler * mi::http::IFactory::create_redirect_handler ( const char *  source_url,
const char *  target_url 
)
pure virtual

Creates a new redirect handler which will redirect requests to a certain URL to a new URL.

The handler needs to be installed with the desired server using mi::http::IServer::install(IRequest_handler*).

Parameters
source_urlIf this URL is found it is redirected to the target_url.
target_urlTarget of the redirection.

 create_server()

virtual IServer * mi::http::IFactory::create_server ( )
pure virtual

Creates a new HTTP server.