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

The server builds a framework for the handlers. More...

#include <http.h>

Inheritance diagram for mi::http::IServer:

Public Member Functions

virtual Sint32 start (const char *listen_address)=0
 Starts the server listening on the given address. More...
 
virtual Sint32 start_ssl (const char *listen_address, const char *cert_file, const char *private_key_file, const char *password)=0
 Starts the server in SSL mode listening on the given address. More...
 
virtual void shutdown ()=0
 Shuts down a server that has been previously started. More...
 
virtual Sint32 set_default_mime_type (const char *mime_type)=0
 Sets the default MIME type to be used when no MIME type was found. More...
 
virtual void add_mime_type (const char *extension, const char *mime_type)=0
 Adds a new MIME type to the server. More...
 
virtual const char * lookup_mime_type (const char *extension)=0
 Returns the MIME type registered for a certain extension. More...
 
virtual void install (IRequest_handler *handler)=0
 Adds a new request handler to the server. More...
 
virtual void remove (IRequest_handler *handler)=0
 Removes a previously installed request handler from the server. More...
 
virtual void install (IWeb_socket_handler *handler)=0
 Adds a new WebSocket request handler to the server. More...
 
virtual void remove (IWeb_socket_handler *handler)=0
 Removes a previously installed WebSocket request handler from the server. More...
 
virtual void install (ICGIRequest_handler *handler)=0
 Adds a new CGI request handler to the server. More...
 
virtual void remove (ICGIRequest_handler *handler)=0
 Removes a previously installed CGI request handler from the server. More...
 
virtual void install (IResponse_handler *handler)=0
 Adds a new response handler to the server. More...
 
virtual void remove (IResponse_handler *handler)=0
 Removes a previously installed response handler from the server. More...
 
virtual void set_identification (const char *id_string)=0
 Sets the identification string of the server. More...
 
virtual const char * get_listen_address ()=0
 Returns the listen address of the server. More...
 
virtual const char * get_ssl_listen_address ()=0
 Returns the SSL listen address of the server. More...
 
virtual Size get_nr_of_connections ()=0
 Returns the number of existing HTTP connections in this server. More...
 
virtual Size get_nr_of_active_connections ()=0
 Returns the number of HTTP connections in this server which actually handle requests. More...
 
virtual void set_keep_alive_timeout (Uint32 nr_of_seconds)=0
 Sets the idle timeout for keep-alive connections. More...
 
virtual Uint32 get_keep_alive_timeout () const =0
 Returns the idle timeout for keep-alive connections. More...
 
virtual void set_send_buffer_size (Uint32 send_buffer_size)=0
 Sets the send buffer size of the socket. More...
 
virtual Uint32 get_send_buffer_size () const =0
 Returns the send buffer size of the socket. More...
 
virtual void set_http_post_body_limit (Uint32 http_post_body_limit)=0
 Sets the size limit for the body of HTTP POST requests. More...
 
virtual Uint32 get_http_post_body_limit () const =0
 Returns the size limit for the body of HTTP POST requests. More...
 
virtual void set_concurrent_connection_limit (Uint32 limit)=0
 Sets the maximum number of concurrent connections this server will accept. More...
 
virtual Uint32 get_concurrent_connection_limit ()=0
 Returns the current concurrent connection limit. 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< 0x9923b273, ... >
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< 0x9923b273, ... >
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 server builds a framework for the handlers.

Member Function Documentation

 add_mime_type()

virtual void mi::http::IServer::add_mime_type ( const char *  extension,
const char *  mime_type 
)
pure virtual

Adds a new MIME type to the server.

The server will use the given extension / mime_type pairs to set the content-type header in the response based on the extension of the requested URL. Note that a handler may overwrite the MIME type (as any header field), if necessary.

Parameters
extensionThe extension identifying the MIME type.
mime_typeThe MIME type to be set when the extension was found.

 get_concurrent_connection_limit()

virtual Uint32 mi::http::IServer::get_concurrent_connection_limit ( )
pure virtual

Returns the current concurrent connection limit.

 get_http_post_body_limit()

virtual Uint32 mi::http::IServer::get_http_post_body_limit ( ) const
pure virtual

Returns the size limit for the body of HTTP POST requests.

 get_keep_alive_timeout()

virtual Uint32 mi::http::IServer::get_keep_alive_timeout ( ) const
pure virtual

Returns the idle timeout for keep-alive connections.

 get_listen_address()

virtual const char * mi::http::IServer::get_listen_address ( )
pure virtual

Returns the listen address of the server.

 get_nr_of_active_connections()

virtual Size mi::http::IServer::get_nr_of_active_connections ( )
pure virtual

Returns the number of HTTP connections in this server which actually handle requests.

Returns
The current number of active connections.

 get_nr_of_connections()

virtual Size mi::http::IServer::get_nr_of_connections ( )
pure virtual

Returns the number of existing HTTP connections in this server.

Returns
The current number of connections.

 get_send_buffer_size()

virtual Uint32 mi::http::IServer::get_send_buffer_size ( ) const
pure virtual

Returns the send buffer size of the socket.

 get_ssl_listen_address()

virtual const char * mi::http::IServer::get_ssl_listen_address ( )
pure virtual

Returns the SSL listen address of the server.

 install() [1/4]

virtual void mi::http::IServer::install ( ICGIRequest_handler handler)
pure virtual

Adds a new CGI request handler to the server.

Parameters
handlerThe handler to be installed.

 install() [2/4]

virtual void mi::http::IServer::install ( IRequest_handler handler)
pure virtual

Adds a new request handler to the server.

Parameters
handlerThe handler to be installed.

 install() [3/4]

virtual void mi::http::IServer::install ( IResponse_handler handler)
pure virtual

Adds a new response handler to the server.

Parameters
handlerThe handler to be installed.

 install() [4/4]

virtual void mi::http::IServer::install ( IWeb_socket_handler handler)
pure virtual

Adds a new WebSocket request handler to the server.

Parameters
handlerThe handler to be installed.

 lookup_mime_type()

virtual const char * mi::http::IServer::lookup_mime_type ( const char *  extension)
pure virtual

Returns the MIME type registered for a certain extension.

Parameters
extensionThe file extension to lookup.
Returns
The registered MIME type or NULL.

 remove() [1/4]

virtual void mi::http::IServer::remove ( ICGIRequest_handler handler)
pure virtual

Removes a previously installed CGI request handler from the server.

Parameters
handlerThe handler to be removed.

 remove() [2/4]

virtual void mi::http::IServer::remove ( IRequest_handler handler)
pure virtual

Removes a previously installed request handler from the server.

Parameters
handlerThe handler to be removed.

 remove() [3/4]

virtual void mi::http::IServer::remove ( IResponse_handler handler)
pure virtual

Removes a previously installed response handler from the server.

Parameters
handlerThe handler to be removed.

 remove() [4/4]

virtual void mi::http::IServer::remove ( IWeb_socket_handler handler)
pure virtual

Removes a previously installed WebSocket request handler from the server.

Parameters
handlerThe handler to be removed.

 set_concurrent_connection_limit()

virtual void mi::http::IServer::set_concurrent_connection_limit ( Uint32  limit)
pure virtual

Sets the maximum number of concurrent connections this server will accept.

Defaults to 256.

Further connections will be put on the OS backlog and serviced only after the number of current connections drops below this value.

Note that when even the OS backlog is full things works a bit differently depending on OS:

Linux: Further connections will be ignored by the server, client will time out and Windows: Further connections will be rejected by the server and fail.

Parameters
limitThe new limit.

 set_default_mime_type()

virtual Sint32 mi::http::IServer::set_default_mime_type ( const char *  mime_type)
pure virtual

Sets the default MIME type to be used when no MIME type was found.

Parameters
mime_typeThe default MIME type.
Returns
0, in case of success, or -1 in case of an error.

 set_http_post_body_limit()

virtual void mi::http::IServer::set_http_post_body_limit ( Uint32  http_post_body_limit)
pure virtual

Sets the size limit for the body of HTTP POST requests.

Parameters
http_post_body_limitThe new size limit.

 set_identification()

virtual void mi::http::IServer::set_identification ( const char *  id_string)
pure virtual

Sets the identification string of the server.

This string is automatically put in the "Server" header of each response. A handler might overwrite it, if necessary on a per URL basis.

Parameters
id_stringThe identification string.

 set_keep_alive_timeout()

virtual void mi::http::IServer::set_keep_alive_timeout ( Uint32  nr_of_seconds)
pure virtual

Sets the idle timeout for keep-alive connections.

The default is not to timeout.

Parameters
nr_of_secondsSeconds of idleness allowed before the server closes the connection.

 set_send_buffer_size()

virtual void mi::http::IServer::set_send_buffer_size ( Uint32  send_buffer_size)
pure virtual

Sets the send buffer size of the socket.

Increasing the buffer size can be useful in the case of high latency connections.

Parameters
send_buffer_sizeSize of socket send buffer.

 shutdown()

virtual void mi::http::IServer::shutdown ( )
pure virtual

Shuts down a server that has been previously started.

The server will stop accepting new requests and shut down as fast as possible. However, requests currently being handled will be served until they are done.

See also
start()

 start()

virtual Sint32 mi::http::IServer::start ( const char *  listen_address)
pure virtual

Starts the server listening on the given address.

This method can be called at most once. Additionally, the method start_ssl() can also be called for secure connections.

The server will run within a separate thread; all requests will be handled in their own threads as well.

See also
shutdown()
Parameters
listen_addressThe address to listen on.
Returns
  • 0: Success.
  • -1: Listen failed, e.g. listen_address already in use.
  • -2: The method has already been called.
  • -7: Invalid listen address

 start_ssl()

virtual Sint32 mi::http::IServer::start_ssl ( const char *  listen_address,
const char *  cert_file,
const char *  private_key_file,
const char *  password 
)
pure virtual

Starts the server in SSL mode listening on the given address.

This method can be called at most once. Additionally, the method start() can also be called for insecure connections.

The server will run within a separate thread; all requests will be handled in their own threads as well.

See also
shutdown()
Parameters
listen_addressThe address to listen on.
cert_fileThe file containing the server's certificate. The certificate needs to be in PEM format. The DER format is not supported.
private_key_fileThe file containing the server's private key.
passwordThe password for decrypting the private key.
Returns
  • 0: Success.
  • -1: Listen failed, e.g. listen_address already in use.
  • -2: The method has already been called.
  • -3: Invalid certificate.
  • -4: Invalid private key.
  • -5: Mismatch of certificate and private key.
  • -6: Cannot load SSL module.
  • -7: Invalid listen address