7#ifndef MI_NEURAYLIB_HTTP_H
8#define MI_NEURAYLIB_HTTP_H
19namespace neuraylib {
class IBuffer; }
94 virtual void set_url(
const char* url) = 0;
103 virtual void set_header(
const char* key,
const char* value) = 0;
128 Size index,
const char** key_pointer,
const char** value_pointer)
const = 0;
176 Size index,
const char** key_pointer,
const char** value_pointer)
const = 0;
212 virtual void set_header(
const char* key,
const char* value) = 0;
237 Size index,
const char** key_pointer,
const char** value_pointer)
const = 0;
250 mi::base::Interface_declare<0x723054d8,0xdfa7,0x4475,0xbc,0xb4,0x44,0x23,0x25,0xea,0x52,0x50>
293 virtual bool print(
const char*
string) = 0;
305#ifdef MI_COMPILER_GCC
306 __attribute__((format(
printf, 2, 3)))
310 va_start( args,
string);
312#ifdef MI_COMPILER_MSC
313 vsnprintf_s( &buffer[0],
sizeof( buffer),
sizeof( buffer)-1,
string, args);
315 vsnprintf( &buffer[0],
sizeof( buffer),
string, args);
317 bool result = this->
print( &buffer[0]);
331 virtual bool enqueue( neuraylib::IBuffer* buffer) = 0;
398 T* ptr_T =
static_cast<T*
>( ptr->
get_interface(
typename T::IID()));
452 mi::base::Interface_declare<0x70ad6206,0x38f0,0x4f2a,0xb7,0x5d,0x8f,0x90,0x64,0x3e,0xd0,0x06>
467 mi::base::Interface_declare<0xbe989e2c,0xf1e6,0x492a,0xb6,0x42,0x1f,0xd7,0x30,0x1f,0xa2,0x9f>
476 bool binary_frame) = 0;
493 mi::base::Interface_declare<0x52fd1beb,0x4c6f,0x4456,0x86,0x9c,0xfd,0xf4,0x12,0x52,0x0a,0xae>
527 WS_STATE_FORCE_32_BIT = 0xffffffffU
582 virtual bool print(
const char*
string,
bool binary_frame =
false) = 0;
591#ifdef MI_COMPILER_GCC
592 __attribute__((format(
printf, 2, 3)))
596 va_start( args,
string);
598#ifdef MI_COMPILER_MSC
599 vsnprintf_s( &buffer[0],
sizeof( buffer),
sizeof( buffer)-1,
string, args);
601 vsnprintf( &buffer[0],
sizeof( buffer),
string, args);
603 bool result = this->
print( &buffer[0]);
636 mi::base::Interface_declare<0xb784d27c,0x3b80,0x432e,0x89,0xa0,0x13,0xe7,0x33,0x04,0x82,0x5c>
659 mi::base::Interface_declare<0x8747d0dd,0x1e27,0x4413,0xa0,0xd4,0x07,0x60,0x8f,0xed,0xfc,0xf9>
688 mi::base::Interface_declare<0xa7fe482e,0x65f8,0x4a4c,0x87,0x21,0xff,0x19,0x21,0x36,0xda,0xe0>
713 mi::base::Interface_declare<0xa9386278,0x6938,0x45a7,0xa2,0x3b,0xbb,0x35,0xf7,0xe9,0x28,0x20>
724 mi::base::Interface_declare<0x9923b273,0x082f,0x403a,0x83,0x57,0xcd,0x23,0x9b,0xcf,0x68,0x4c>
771 const char* listen_address,
const char* cert_file,
772 const char* private_key_file,
const char* password) = 0;
796 virtual void add_mime_type(
const char* extension,
const char* mime_type) = 0;
921 mi::base::Interface_declare<0xddded154,0x4be8,0x42b6,0x81,0x68,0x21,0x16,0xc7,0xbd,0x63,0x40>
942 const char* root_url,
const char* root_path,
bool is_recursive =
true) = 0;
952 const char* source_url,
const char* target_url) = 0;
This interface is the base interface of all types.
Definition: idata.h:297
Mixin class template for deriving new interface declarations.
Definition: interface_declare.h:43
CGI request handlers are responsible for handling HTTP requests.
Definition: http.h:689
virtual bool handle(IConnection *connection)=0
Handles a request coming in on a connection.
The connection class represents a connection from a client to the server.
Definition: http.h:277
virtual IResponse * get_response()=0
Returns the response associated with the connection.
virtual void set_attachment(const char *key, const char *value)=0
Attaches a string attachment to the connection.
virtual bool print(const char *string)=0
Prints a string to the connection.
virtual void add_data_handler(IData_handler *handler)=0
Adds a data handler to the connection.
virtual IRequest * get_request()=0
Returns the request of the connection.
virtual const char * get_local_address()=0
Returns the address of the local side of the connection.
virtual bool enqueue(neuraylib::IBuffer *buffer)=0
Enqueues a buffer to be sent on the connection.
bool printf(const char *string,...) __attribute__((format(printf
Prints a string to the connection.
virtual Sint32 flush()=0
Waits until all enqueued data has been written.
T * get_data_attachment(const char *key)
Returns an attachment from the connection.
Definition: http.h:393
virtual const char * get_attachment(const char *key)=0
Returns a string attachment from the connection.
virtual bool check_error()=0
Indicates whether an error occurred on the connection.
virtual void set_data_attachment(const char *key, IData *value)=0
Attaches an attachment to the connection.
virtual bool is_secure_connection()=0
Query whether this is a secure (i.e.
virtual void remove_attachment(const char *key)=0
Removes an attachment from the connection.
virtual Sint32 read_data(Size size, char *buffer)=0
Reads incoming CGI data into a supplied buffer.
virtual IData * get_data_attachment(const char *key)=0
Returns an attachment from the connection.
virtual const char * get_peer_address()=0
Returns the address of the peer of the connection.
A data handler may be added to a connection.
Definition: http.h:251
virtual neuraylib::IBuffer * handle(IConnection *connection, neuraylib::IBuffer *buffer)=0
Handles data.
The factory can be used to instantiate the built-in HTTP classes.
Definition: http.h:922
virtual IRequest_handler * create_file_handler(const char *root_url, const char *root_path, bool is_recursive=true)=0
Creates a new file handler for the server.
virtual IResponse_handler * create_log_handler(const char *path)=0
Creates a new log handler.
virtual IResponse_handler * create_chunked_encoding_handler()=0
Creates a new chunked encoding handler.
virtual IServer * create_server()=0
Creates a new HTTP server.
virtual IRequest_handler * create_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.
virtual IWeb_socket * create_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 specifi...
Request handlers are responsible for handling HTTP requests.
Definition: http.h:660
virtual bool handle(IConnection *connection)=0
Handles a request coming in on a connection.
This interface holds all the parameters of a request.
Definition: http.h:80
virtual const char * get_url() const =0
Returns the URL of the request.
virtual const char * get_body() const =0
Returns the body string.
virtual void add_argument(const char *key, const char *value)=0
Adds an argument to the request.
virtual const char * get_protocol() const =0
Returns the protocol of the request.
virtual const char * get_header(const char *key) const =0
Returns a header from the request.
virtual const char * get_command() const =0
Returns the command of the request.
virtual void remove_header(const char *key)=0
Removes a header from the request.
virtual void set_header(const char *key, const char *value)=0
Changes an existing header of the request or adds a new header to the request.
virtual bool get_header(Size index, const char **key_pointer, const char **value_pointer) const =0
Returns the header with the given index.
virtual void set_argument(const char *key, const char *value)=0
Changes an argument of the request or adds an argument to the request.
virtual const char * get_request_line() const =0
Returns the request line of the request.
virtual const char * get_argument(const char *key) const =0
Returns an argument from the request.
virtual bool get_argument(Size index, const char **key_pointer, const char **value_pointer) const =0
Returns the argument with the given index.
virtual void remove_argument(const char *key)=0
Removes an argument from the request.
virtual void set_url(const char *url)=0
Sets the URL of the request.
Response handlers can be used to modify responses generated by request handlers.
Definition: http.h:714
virtual void handle(IConnection *connection)=0
Handles a response on a connection.
This interface holds all the parameters of a response.
Definition: http.h:197
virtual void set_header(const char *key, const char *value)=0
Changes a header of the response or adds a header to the response.
virtual bool was_sent() const =0
Indicates whether the response was already sent.
virtual Sint32 get_result_code() const =0
Returns the result code of the response.
virtual const char * get_header(const char *key) const =0
Returns a header from the response.
virtual void remove_header(const char *key)=0
Removes a header from the response.
virtual bool get_header(Size index, const char **key_pointer, const char **value_pointer) const =0
Returns the header with the given index.
virtual void set_result_code(Sint32 code, const char *message)=0
Sets the result code of the response.
The server builds a framework for the handlers.
Definition: http.h:725
virtual void remove(ICGIRequest_handler *handler)=0
Removes a previously installed CGI request handler from the server.
virtual const char * get_listen_address()=0
Returns the listen address of the server.
virtual Uint32 get_concurrent_connection_limit()=0
Returns the current concurrent connection limit.
virtual const char * get_ssl_listen_address()=0
Returns the SSL listen address of the server.
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.
virtual void shutdown()=0
Shuts down a server that has been previously started.
virtual void install(IResponse_handler *handler)=0
Adds a new response handler to the server.
virtual void remove(IRequest_handler *handler)=0
Removes a previously installed request handler from the server.
virtual void remove(IResponse_handler *handler)=0
Removes a previously installed response handler from the server.
virtual void remove(IWeb_socket_handler *handler)=0
Removes a previously installed WebSocket request handler from the server.
virtual void install(IWeb_socket_handler *handler)=0
Adds a new WebSocket request handler to the server.
virtual Uint32 get_http_post_body_limit() const =0
Returns the size limit for the body of HTTP POST requests.
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.
virtual void install(IRequest_handler *handler)=0
Adds a new request handler to the server.
virtual Uint32 get_keep_alive_timeout() const =0
Returns the idle timeout for keep-alive connections.
virtual Sint32 start(const char *listen_address)=0
Starts the server listening on the given address.
virtual void add_mime_type(const char *extension, const char *mime_type)=0
Adds a new MIME type to the server.
virtual Size get_nr_of_connections()=0
Returns the number of existing HTTP connections in this server.
virtual void set_send_buffer_size(Uint32 send_buffer_size)=0
Sets the send buffer size of the socket.
virtual Size get_nr_of_active_connections()=0
Returns the number of HTTP connections in this server which actually handle requests.
virtual void install(ICGIRequest_handler *handler)=0
Adds a new CGI request handler to the server.
virtual void set_concurrent_connection_limit(Uint32 limit)=0
Sets the maximum number of concurrent connections this server will accept.
virtual void set_keep_alive_timeout(Uint32 nr_of_seconds)=0
Sets the idle timeout for keep-alive connections.
virtual void set_http_post_body_limit(Uint32 http_post_body_limit)=0
Sets the size limit for the body of HTTP POST requests.
virtual Uint32 get_send_buffer_size() const =0
Returns the send buffer size of the socket.
virtual void set_identification(const char *id_string)=0
Sets the identification string of the server.
virtual const char * lookup_mime_type(const char *extension)=0
Returns the MIME type registered for a certain extension.
A WebSocket data handler that can be installed to a WebSocket connection to handle data arriving at t...
Definition: http.h:468
virtual void handle(IWeb_socket *web_socket, neuraylib::IBuffer *buffer, bool binary_frame)=0
The handle() function is called when new data is received.
WebSocket handlers are responsible for handling WebSocket requests.
Definition: http.h:637
virtual bool handle(IWeb_socket *web_socket)=0
Handles an incoming WebSocket request.
A WebSocket state handler that can be installed to a WebSocket connection to handle events of the Web...
Definition: http.h:453
virtual void handle(IWeb_socket *web_socket)=0
The handle() function is called when the WebSocket changes its state.
The WebSocket connection class represents a connection that is built on top of an HTTP connection.
Definition: http.h:494
virtual void set_max_payload(Uint64 bytes)=0
Set the maximum payload that web socket messages can have.
virtual bool print(const char *string, bool binary_frame=false)=0
Prints a string to the connection.
virtual void set_state_handler(IWeb_socket_state_handler *handler)=0
Sets a state handler to the WebSocket connection.
virtual State get_state() const =0
Returns the state of the connection.
virtual void close()=0
Closes the connection.
virtual Difference write(neuraylib::IBuffer *buffer, bool binary_frame=false)=0
Writes data from a buffer to the connection.
virtual IConnection * get_http_connection()=0
Returns the HTTP connection associated with this WebSocket connection.
virtual void set_data_handler(IWeb_socket_data_handler *handler)=0
Sets a data handler to the WebSocket connection.
State
This class represents different states that a WebSocket can be in.
Definition: http.h:513
@ WS_STATE_CLOSED
The closing handshake has been completed or the or the underlying TCP connection has been closed.
Definition: http.h:524
@ WS_STATE_ERROR
An error has occurred.
Definition: http.h:526
@ WS_STATE_CLOSING
The closing handshake has been started.
Definition: http.h:521
@ WS_STATE_CONNECTED
A connection has been established.
Definition: http.h:519
@ WS_STATE_INIT
The initial state.
Definition: http.h:515
@ WS_STATE_CONNECTING
The client has sent a request and awaits a response.
Definition: http.h:517
virtual const char * get_peer_address() const =0
Returns the peer's address of the connection.
virtual Uint64 get_max_payload()=0
Get the maximum payoad.
bool printf(const char *string,...) __attribute__((format(printf
Prints a string to the connection.
virtual const char * get_url_path() const =0
Returns the URL path that the WebSocket request is sent to.
virtual const char * get_local_address() const =0
Returns the local address of the connection.
#define mi_static_assert(expr)
Compile time assertion that raises a compilation error if the constant expression expr evaluates to f...
Definition: assert.h:65
virtual const IInterface * get_interface(const Uuid &interface_id) const =0
Acquires a const interface from another.
virtual Uint32 release() const =0
Decrements the reference count.
unsigned long long Uint64
64-bit unsigned integer.
Definition: types.h:62
unsigned int Uint32
32-bit unsigned integer.
Definition: types.h:49
Sint64 Difference
Signed integral type that is large enough to hold the difference of two pointers.
Definition: types.h:122
Uint64 Size
Unsigned integral type that is large enough to hold the size of all types.
Definition: types.h:112
float Float32
32-bit float.
Definition: types.h:51
signed int Sint32
32-bit signed integer.
Definition: types.h:46
Mixin class template for deriving new interface declarations.
Common namespace for APIs of NVIDIA Advanced Rendering Center GmbH.
Definition: dice.h:89