MarkLogic Connect
MarkLogic Connect Client API Collection
|
Encapsulates a response from a MarkLogic server REST API. More...
#include <Response.hpp>
Public Member Functions | |
MLCLIENT_API | Response () |
MLCLIENT_API void | setResponseCode (const ResponseCode &code) |
Sets the HTTP response code for the Response. More... | |
MLCLIENT_API ResponseType | getResponseType (void) const |
Returns the ResponseType const for the response. This is XML, JSON, Binary, Text, or Unknown. More... | |
MLCLIENT_API void | setResponseType (const ResponseType &type) |
Sets the type of response received (XML, JSON, Binary, etc.), set my this API internally. More... | |
MLCLIENT_API void | setResponseHeaders (const mlclient::HttpHeaders &headers) |
Sets the headers received as part of the response. More... | |
MLCLIENT_API ResponseCode | getResponseCode (void) const |
Returns the HTTP response code for the response. More... | |
MLCLIENT_API mlclient::HttpHeaders | getResponseHeaders (void) const |
Returns the headers that were returned with the response. More... | |
MLCLIENT_API size_t | read (void *buffer, const size_t &max_size, const size_t off=0) |
Reads the raw response in to a buffer. Used for Binary responses. More... | |
MLCLIENT_API const std::string & | getContent () const |
For text responses (including JSON and XML), returns the response content as a string. More... | |
MLCLIENT_API void | setContent (std::string *content) |
Sets the string content for this Response. More... | |
MLCLIENT_API | Response (const Response &)=delete |
MLCLIENT_API Response & | operator= (const Response &)=delete |
Encapsulates a response from a MarkLogic server REST API.
Note that a response can be XML, JSON, text, or binary content. This holds the raw response
MLCLIENT_API mlclient::Response::Response | ( | ) |
Constructor
MLCLIENT_API const std::string& mlclient::Response::getContent | ( | ) | const |
For text responses (including JSON and XML), returns the response content as a string.
MLCLIENT_API ResponseCode mlclient::Response::getResponseCode | ( | void | ) | const |
Returns the HTTP response code for the response.
MLCLIENT_API mlclient::HttpHeaders mlclient::Response::getResponseHeaders | ( | void | ) | const |
Returns the headers that were returned with the response.
MLCLIENT_API ResponseType mlclient::Response::getResponseType | ( | void | ) | const |
Returns the ResponseType const for the response. This is XML, JSON, Binary, Text, or Unknown.
MLCLIENT_API size_t mlclient::Response::read | ( | void * | buffer, |
const size_t & | max_size, | ||
const size_t | off = 0 |
||
) |
Reads the raw response in to a buffer. Used for Binary responses.
For binary responses, reads up to max_size bytes into buffer, starting at a given offset. For example, if an image is returned, it can be saved to a file, reading 4 k chunks. The actual number of bytes read is returned.
[in,out] | buffer | The untyped buffer to copy data in to |
[in] | max_size | The maximum amount of data in bytes to read in to the buffer |
[in] | off | The offset in the buffer after which this function starts writing data to |
MLCLIENT_API void mlclient::Response::setContent | ( | std::string * | content | ) |
Sets the string content for this Response.
This should only be set by the MarkLogic C++ API itself, never by a developer using the API.
[in] | content | A std::unique_ptr to take ownership of the std::string content of the response. |
MLCLIENT_API void mlclient::Response::setResponseCode | ( | const ResponseCode & | code | ) |
Sets the HTTP response code for the Response.
This is normally set when the response is received. It should not be set otherwise.
[in] | code | The HTTP response code |
MLCLIENT_API void mlclient::Response::setResponseHeaders | ( | const mlclient::HttpHeaders & | headers | ) |
Sets the headers received as part of the response.
This is set when the response is received but should not be set otherwise.
[in] | headers | The HTTP response headers |
MLCLIENT_API void mlclient::Response::setResponseType | ( | const ResponseType & | type | ) |
Sets the type of response received (XML, JSON, Binary, etc.), set my this API internally.
This is normally set when the response is received. It should not be set otherwise.
[in] | type | The type of response |