neuray API Programmer's Manual

mi::http::IServer Class Reference

[HTTP server]

Description

The server builds a framework for the handlers.

Public Member Functions

virtual void add_mime_type( const char* extension, const char* mime_type) =0
Adds a new MIME type to the server. More...
virtual Uint32 get_http_post_body_limit() const =0
Returns the size limit for the body of HTTP POST requests.
virtual Uint32 get_keep_alive_timeout() const =0
Returns the idle timeout for keep-alive connections.
virtual const char* get_listen_address() =0
Returns the listen address of the server.
virtual Size get_nr_of_active_connections() =0
Returns the number of HTTP connections in this server which actually handle requests. More...
virtual Size get_nr_of_connections() =0
Returns the number of existing HTTP connections in this server. More...
virtual Uint32 get_send_buffer_size() const =0
Returns the send buffer size of the socket.
virtual const char* get_ssl_listen_address() =0
Returns the SSL listen address of the server.
virtual void install( IRequest_handler* handler) =0
Adds a new request handler to the server. More...
virtual void install( IWeb_socket_handler* handler) =0
Adds a new WebSocket request handler to the server. More...
virtual void install( ICGIRequest_handler* handler) =0
Adds a new CGI request handler to the server. More...
virtual void install( IResponse_handler* handler) =0
Adds a new response handler 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 remove( IRequest_handler* handler) =0
Removes a previously installed request handler from the server. More...
virtual void remove( IWeb_socket_handler* handler) =0
Removes a previously installed WebSocket request handler from the server. More...
virtual void remove( ICGIRequest_handler* handler) =0
Removes a previously installed CGI request handler from the server. More...
virtual void remove( IResponse_handler* handler) =0
Removes a previously installed response handler from the server. 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 set_http_post_body_limit( Uint32 http_post_body_limit) =0
Sets the size limit for the body of HTTP POST requests. More...
virtual void set_identification( const char* id_string) =0
Sets the identification string of the server. More...
virtual void set_keep_alive_timeout( Uint32 nr_of_seconds) =0
Sets 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 void shutdown() =0
Shuts down a server that has been previously started. More...
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...

Member Functions

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

extension
The extension identifying the MIME type.
mime_type
The MIME type to be set when the extension was found.
virtual Uint32 mi::​http::​IServer::get_http_post_body_limit() const [pure virtual]

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

virtual Uint32 mi::​http::​IServer::get_keep_alive_timeout() const [pure virtual]

Returns the idle timeout for keep-alive connections.

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

Returns the listen address of the server.

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.

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.

virtual Uint32 mi::​http::​IServer::get_send_buffer_size() const [pure virtual]

Returns the send buffer size of the socket.

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

Returns the SSL listen address of the server.

virtual void mi::​http::​IServer::install( IRequest_handler* handler) [pure virtual]

Adds a new request handler to the server.

Parameters

handler
The handler to be installed.
virtual void mi::​http::​IServer::install( IWeb_socket_handler* handler) [pure virtual]

Adds a new WebSocket request handler to the server.

Parameters

handler
The handler to be installed.
virtual void mi::​http::​IServer::install( ICGIRequest_handler* handler) [pure virtual]

Adds a new CGI request handler to the server.

Parameters

handler
The handler to be installed.
virtual void mi::​http::​IServer::install( IResponse_handler* handler) [pure virtual]

Adds a new response handler to the server.

Parameters

handler
The handler to be installed.
virtual const char* mi::​http::​IServer::lookup_mime_type( const char* extension) [pure virtual]

Returns the MIME type registered for a certain extension.

Parameters

extension
The file extension to lookup.

Returns

The registered MIME type or NULL .

virtual void mi::​http::​IServer::remove( IRequest_handler* handler) [pure virtual]

Removes a previously installed request handler from the server.

Parameters

handler
The handler to be removed.
virtual void mi::​http::​IServer::remove( IWeb_socket_handler* handler) [pure virtual]

Removes a previously installed WebSocket request handler from the server.

Parameters

handler
The handler to be removed.
virtual void mi::​http::​IServer::remove( ICGIRequest_handler* handler) [pure virtual]

Removes a previously installed CGI request handler from the server.

Parameters

handler
The handler to be removed.
virtual void mi::​http::​IServer::remove( IResponse_handler* handler) [pure virtual]

Removes a previously installed response handler from the server.

Parameters

handler
The handler to be removed.
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_type
The default MIME type.

Returns

0, in case of success, or -1 in case of an error.

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_limit
The new size limit.
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_string
The identification string.
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_seconds
Seconds of idleness allowed before the server closes the connection.
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_size
Size of socket send buffer.
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()

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_address
The address to listen on.

Returns

0, if the server could be started, or -1 in case of errors.

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 unsecure 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_address
The address to listen on.
cert_file
The file containing the server's certificate.
private_key_file
The file containing the server's private key.
password
The password for decrypting the private key.

Returns

  • 0: Success.
  • -1: 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