mi::nservices::IHttp_request Class Reference
[Http Client]
Description
Represent an individual HTTP request.
Public Member Functions
- virtual mi::Sint32 add_header( const char* name, const char* value) =0
- Adds an HTTP header. If name already exists then a duplicate header will be added.
- virtual const neuraylib::IBuffer* get_body() const =0
- Returns the request body.
- virtual int get_connect_timeout() const =0
- Gets the timeout in seconds for the connection to complete. 0 for the default of 300 seconds.
- virtual const char* get_header( const char* name) const =0
- Returns the first header with given name or NULL if the header doesn't exist. More...
- virtual const mi::IArray* get_headers() const =0
- Returns all headers. More...
- virtual Http_redirect_code get_maintain_request_methods() const =0
- Gets the redirect codes that will maintain http method when followed.
- virtual Http_method get_method() const =0
- The method used by this request.
- virtual int get_timeout() const =0
- Gets the timeout in seconds for the transfer to complete. 0 for the default no timeout.
- virtual const char* get_url() const =0
- The URL used by this request.
- virtual bool get_verify_ssl() const =0
- Gets whether ssl certificates must be verified for the request to succeed. More...
- virtual mi::Sint32 remove_header( const char* name) =0
- Removes a header by name. More...
- virtual void remove_headers() =0
- Removes all headers from the request.
- virtual mi::Sint32 send( IHttp_response_handler* handler, mi::Uint32 transfer_mode = HTTP_TRANSFER_MODE_DEFAULT) const =0
- Sends this HTTP request. More...
- virtual mi::Sint32 set_body( neuraylib::IBuffer* body, const char* content_type = NULL, bool set_content_length = true) =0
- Sets the request body. More...
- virtual void set_connect_timeout( int connect_timeout) =0
- Sets a timeout in seconds for the connection to complete. 0 for the default of 300 seconds.
- virtual void set_follow_redirects( bool follow_redirects, int max_redirects = -1, bool authenticate_redirects = false, Http_redirect_code maintain_request_methods = HTTP_REDIRECT_CODE_NONE) =0
- Set whether the request should automatically follow redirects. More...
- virtual mi::Sint32 set_header( const char* name, const char* value) =0
- Sets an HTTP header. More...
- virtual mi::Sint32 set_headers( const mi::IArray* headers) =0
- Sets all headers from the provided array of mi::IString, all existing headers are removed. More...
- virtual void set_timeout( int timeout) =0
- Sets a timeout in seconds for the transfer to complete. 0 for the default no timeout.
- virtual void set_verify_ssl( bool verify) =0
- Sets whether ssl certificates must be verified for the request to succeed.
Member Functions
- virtual mi::Sint32 mi::nservices::IHttp_request::add_header( const char* name, const char* value) [pure virtual]
-
Adds an HTTP header. If name already exists then a duplicate header will be added.
- virtual const neuraylib::IBuffer* mi::nservices::IHttp_request::get_body() const [pure virtual]
-
Returns the request body.
- virtual int mi::nservices::IHttp_request::get_connect_timeout() const [pure virtual]
-
Gets the timeout in seconds for the connection to complete. 0 for the default of 300 seconds.
- virtual const char* mi::nservices::IHttp_request::get_header( const char* name) const [pure virtual]
-
Returns the first header with given name or NULL if the header doesn't exist.
Parameters
- name
- the name of the header to retrieve.
- virtual const mi::IArray* mi::nservices::IHttp_request::get_headers() const [pure virtual]
-
Returns all headers. The returned array consists of mi::IString elements each of which is the colon separated header name and value.
- virtual Http_redirect_code mi::nservices::IHttp_request::get_maintain_request_methods() const [pure virtual]
-
Gets the redirect codes that will maintain http method when followed.
- virtual Http_method mi::nservices::IHttp_request::get_method() const [pure virtual]
-
The method used by this request.
- virtual int mi::nservices::IHttp_request::get_timeout() const [pure virtual]
-
Gets the timeout in seconds for the transfer to complete. 0 for the default no timeout.
- virtual const char* mi::nservices::IHttp_request::get_url() const [pure virtual]
-
The URL used by this request.
- virtual bool mi::nservices::IHttp_request::get_verify_ssl() const [pure virtual]
-
Gets whether ssl certificates must be verified for the request to succeed. (Default true)
- virtual mi::Sint32 mi::nservices::IHttp_request::remove_header( const char* name) [pure virtual]
-
Removes a header by name. If multiple headers exist with the given name then remove all of them.
- virtual void mi::nservices::IHttp_request::remove_headers() [pure virtual]
-
Removes all headers from the request.
- virtual mi::Sint32 mi::nservices::IHttp_request::send( IHttp_response_handler* handler, mi::Uint32 transfer_mode = HTTP_TRANSFER_MODE_DEFAULT) const [pure virtual]
-
Sends this HTTP request. The provided handler will be called with the response to the request if the request is made. If the request cannot be made an error code will be returned and handler will not be called.
Parameters
- handler
- the response handler, may be NULL.
- transfer_mode
Returns
- 0 success. The response handler is guaranteed to be called.
- -1 unknown error.
- virtual mi::Sint32 mi::nservices::IHttp_request::set_body( neuraylib::IBuffer* body, const char* content_type = NULL, bool set_content_length = true) [pure virtual]
-
Sets the request body. Note that the IBuffer must not be modified after the request has been sent until the response handler has been called.
Parameters
- body
- the body to set. NULL will remove an existing body.
- content_type
- if provided then the content type header is set to this value.
- set_content_length
- if true then content length is automatically set from the body. Otherwise no automatic content length is set
Returns
- 0 success.
- -1 unknown error.
- virtual void mi::nservices::IHttp_request::set_connect_timeout( int connect_timeout) [pure virtual]
-
Sets a timeout in seconds for the connection to complete. 0 for the default of 300 seconds.
- virtual void mi::nservices::IHttp_request::set_follow_redirects( bool follow_redirects, int max_redirects = -1, bool authenticate_redirects = false, Http_redirect_code maintain_request_methods = HTTP_REDIRECT_CODE_NONE) [pure virtual]
-
Set whether the request should automatically follow redirects. Note that by default, redirects are followed indefinitely. Override redirect_limit to change this behaviour. When following certain 3xx response codes, the original request method is changed to GET to maintain consistency with web browsers. Override maintain_request_method to disable this behaviour for each specific response code.
Parameters
- follow_redirects
- whether redirects are automatically followed. (Default is false).
- max_redirects
- the maximum number of redirects followed. -1 for unlimited redirects.
- authenticate_redirects
- whether redirects to other hostnames should have authentication credentials from the original host applied to them. (Default is false)
- maintain_request_methods
- the redirect codes that will maintain http method when followed.
- virtual mi::Sint32 mi::nservices::IHttp_request::set_header( const char* name, const char* value) [pure virtual]
-
Sets an HTTP header. If name already exists then it will be replaced with the given value otherwise it will be created.
- virtual mi::Sint32 mi::nservices::IHttp_request::set_headers( const mi::IArray* headers) [pure virtual]
-
Sets all headers from the provided array of mi::IString, all existing headers are removed. Strings must consists of the header name followed by a colon then the header value.
Parameters
- headers
- the headers to replace.
Returns
- 0 success
- -1 unknown error.
- -2 headers is NULL.
- -3 headers contains non mi::IString elements.
- -4 a header string failed to parse as a header.
- virtual void mi::nservices::IHttp_request::set_timeout( int timeout) [pure virtual]
-
Sets a timeout in seconds for the transfer to complete. 0 for the default no timeout.
- virtual void mi::nservices::IHttp_request::set_verify_ssl( bool verify) [pure virtual]
-
Sets whether ssl certificates must be verified for the request to succeed.