diff --git a/V8Client/V8ClientConnection.cpp b/V8Client/V8ClientConnection.cpp index 3a941914da..058103baae 100644 --- a/V8Client/V8ClientConnection.cpp +++ b/V8Client/V8ClientConnection.cpp @@ -53,181 +53,317 @@ using namespace triagens::basics; using namespace triagens::httpclient; +using namespace triagens::v8client; using namespace std; -namespace triagens { - namespace v8client { +// ----------------------------------------------------------------------------- +// --SECTION-- constructors and destructors +// ----------------------------------------------------------------------------- - //////////////////////////////////////////////////////////////////////////////// - /// constructor and destructor - //////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// +/// @addtogroup V8ClientConnection +/// @{ +//////////////////////////////////////////////////////////////////////////////// - V8ClientConnection::V8ClientConnection (const std::string& hostname, - int port, - double requestTimeout, - size_t retries, - double connectionTimeout, - bool warn) : _client(0), _httpResult(0) { +//////////////////////////////////////////////////////////////////////////////// +/// @brief constructor +//////////////////////////////////////////////////////////////////////////////// + +V8ClientConnection::V8ClientConnection (const std::string& hostname, + int port, + double requestTimeout, + size_t retries, + double connectionTimeout, + bool warn) + : _connected(false), + _lastHttpReturnCode(0), + _lastErrorMessage(""), + _client(0), + _httpResult(0) { - _connected = false; - _lastHttpReturnCode = 0; - _lastErrorMessage = ""; - _client = new SimpleHttpClient(hostname, port, requestTimeout, retries, connectionTimeout, warn); + _client = new SimpleHttpClient(hostname, port, requestTimeout, retries, connectionTimeout, warn); - // connect to server and get version number - map headerFields; - SimpleHttpResult* result = _client->request(SimpleHttpClient::GET, "/_api/version", 0, 0, headerFields); + // connect to server and get version number + map headerFields; + SimpleHttpResult* result = _client->request(SimpleHttpClient::GET, "/_api/version", 0, 0, headerFields); - if (!result->isComplete()) { - // save error message - _lastErrorMessage = _client->getErrorMessage(); - _lastHttpReturnCode = 500; - } - else { - _lastHttpReturnCode = result->getHttpReturnCode(); - if (result->getHttpReturnCode() == SimpleHttpResult::HTTP_STATUS_OK) { + if (!result->isComplete()) { + // save error message + _lastErrorMessage = _client->getErrorMessage(); + _lastHttpReturnCode = 500; + } + else { + _lastHttpReturnCode = result->getHttpReturnCode(); - triagens::basics::VariantArray* json = result->getBodyAsVariantArray(); - if (json) { - triagens::basics::VariantString* vs = json->lookupString("server"); - if (vs && vs->getValue() == "arango") { - // connected to arango server - _connected = true; - vs = json->lookupString("version"); - if (vs) { - _version = vs->getValue(); - } - } - delete json; + if (result->getHttpReturnCode() == SimpleHttpResult::HTTP_STATUS_OK) { + triagens::basics::VariantArray* json = result->getBodyAsVariantArray(); + + if (json) { + triagens::basics::VariantString* vs = json->lookupString("server"); + + if (vs && vs->getValue() == "arango") { + // connected to arango server + _connected = true; + vs = json->lookupString("version"); + + if (vs) { + _version = vs->getValue(); } - } - } - - delete result; - } - - V8ClientConnection::~V8ClientConnection () { - if (_httpResult) { - delete _httpResult; - } - - if (_client) { - delete _client; - } - } - - v8::Handle V8ClientConnection::getData (std::string const& location, map const& headerFields) { - return requestData(SimpleHttpClient::GET, location, "", headerFields); - } - - v8::Handle V8ClientConnection::deleteData (std::string const& location, map const& headerFields) { - return requestData(SimpleHttpClient::DELETE, location, "", headerFields); - } - - v8::Handle V8ClientConnection::headData (std::string const& location, map const& headerFields) { - return requestData(SimpleHttpClient::HEAD, location, "", headerFields); - } - - v8::Handle V8ClientConnection::postData (std::string const& location, std::string const& body, map const& headerFields) { - return requestData(SimpleHttpClient::POST, location, body, headerFields); - } - - v8::Handle V8ClientConnection::putData (std::string const& location, std::string const& body, map const& headerFields) { - return requestData(SimpleHttpClient::PUT, location, body, headerFields); - } - - const std::string& V8ClientConnection::getHostname () { - return _client->getHostname(); - } - - int V8ClientConnection::getPort () { - return _client->getPort(); - } - - v8::Handle V8ClientConnection::requestData (int method, string const& location, string const& body, map const& headerFields) { - _lastErrorMessage = ""; - _lastHttpReturnCode = 0; - - if (_httpResult) { - delete _httpResult; - } - - if (body.empty()) { - _httpResult = _client->request(method, location, 0, 0, headerFields); - } - else { - _httpResult = _client->request(method, location, body.c_str(), body.length(), headerFields); - } - - if (!_httpResult->isComplete()) { - // not complete - _lastErrorMessage = _client->getErrorMessage(); - - if (_lastErrorMessage == "") { - _lastErrorMessage = "Unknown error"; } - - _lastHttpReturnCode = SimpleHttpResult::HTTP_STATUS_SERVER_ERROR; - - v8::Handle result = v8::Object::New(); - result->Set(v8::String::New("error"), v8::Boolean::New(true)); - result->Set(v8::String::New("code"), v8::Integer::New(SimpleHttpResult::HTTP_STATUS_SERVER_ERROR)); - - int errorNumber = 0; - switch (_httpResult->getResultType()) { - case (SimpleHttpResult::COULD_NOT_CONNECT) : - errorNumber = TRI_SIMPLE_CLIENT_COULD_NOT_CONNECT; - break; - - case (SimpleHttpResult::READ_ERROR) : - errorNumber = TRI_SIMPLE_CLIENT_COULD_NOT_READ; - break; - case (SimpleHttpResult::WRITE_ERROR) : - errorNumber = TRI_SIMPLE_CLIENT_COULD_NOT_WRITE; - break; - - default: - errorNumber = TRI_SIMPLE_CLIENT_UNKNOWN_ERROR; - } - - result->Set(v8::String::New("errorNum"), v8::Integer::New(errorNumber)); - result->Set(v8::String::New("errorMessage"), v8::String::New(_lastErrorMessage.c_str(), _lastErrorMessage.length())); - return result; + delete json; } - else { - // complete - _lastHttpReturnCode = _httpResult->getHttpReturnCode(); - - // got a body - if (_httpResult->getBody().str().length() > 0) { - string contentType = _httpResult->getContentType(true); + } + } + + delete result; +} - if (contentType == "application/json") { - TRI_json_t* js = TRI_JsonString(TRI_UNKNOWN_MEM_ZONE, _httpResult->getBody().str().c_str()); +//////////////////////////////////////////////////////////////////////////////// +/// @brief destructor +//////////////////////////////////////////////////////////////////////////////// - if (js != NULL) { - // return v8 object - v8::Handle result = TRI_ObjectJson(js); - TRI_FreeJson(TRI_UNKNOWN_MEM_ZONE, js); - return result; - } - } +V8ClientConnection::~V8ClientConnection () { + if (_httpResult) { + delete _httpResult; + } - // return body as string - v8::Handle result = v8::String::New(_httpResult->getBody().str().c_str(), _httpResult->getBody().str().length()); - return result; - } - else { - // no body - // this should not happen - v8::Handle result; - result->Set(v8::String::New("error"), v8::Boolean::New(false)); - result->Set(v8::String::New("code"), v8::Integer::New(_httpResult->getHttpReturnCode())); - return result; - } - } - } - + if (_client) { + delete _client; } } + +//////////////////////////////////////////////////////////////////////////////// +/// @} +//////////////////////////////////////////////////////////////////////////////// + +// ----------------------------------------------------------------------------- +// --SECTION-- public functions +// ----------------------------------------------------------------------------- + +//////////////////////////////////////////////////////////////////////////////// +/// @addtogroup V8ClientConnection +/// @{ +//////////////////////////////////////////////////////////////////////////////// + +//////////////////////////////////////////////////////////////////////////////// +/// @brief returns true if it is connected +//////////////////////////////////////////////////////////////////////////////// + + bool isConnected (); + +//////////////////////////////////////////////////////////////////////////////// +/// @brief returns the version and build number of the arango server +//////////////////////////////////////////////////////////////////////////////// + +const string& V8ClientConnection::getVersion () { + return _version; +} + +//////////////////////////////////////////////////////////////////////////////// +/// @brief get the last http return code +//////////////////////////////////////////////////////////////////////////////// + +int V8ClientConnection::getLastHttpReturnCode () { + return _lastHttpReturnCode; +} + +//////////////////////////////////////////////////////////////////////////////// +/// @brief get the last error message +//////////////////////////////////////////////////////////////////////////////// + +const std::string& V8ClientConnection::getErrorMessage () { + return _lastErrorMessage; +} + +//////////////////////////////////////////////////////////////////////////////// +/// @brief get the hostname +//////////////////////////////////////////////////////////////////////////////// + +const std::string& V8ClientConnection::getHostname () { + return _client->getHostname(); +} + +//////////////////////////////////////////////////////////////////////////////// +/// @brief get the port +//////////////////////////////////////////////////////////////////////////////// + +int V8ClientConnection::getPort () { + return _client->getPort(); +} + +//////////////////////////////////////////////////////////////////////////////// +/// @brief get the simple http client +//////////////////////////////////////////////////////////////////////////////// + +triagens::httpclient::SimpleHttpClient* V8ClientConnection::getHttpClient() { + return _client; +} + +//////////////////////////////////////////////////////////////////////////////// +/// @brief do a "GET" request +//////////////////////////////////////////////////////////////////////////////// + +v8::Handle V8ClientConnection::getData (std::string const& location, + map const& headerFields) { + return requestData(SimpleHttpClient::GET, location, "", headerFields); +} + +//////////////////////////////////////////////////////////////////////////////// +/// @brief do a "DELETE" request +//////////////////////////////////////////////////////////////////////////////// + +v8::Handle V8ClientConnection::deleteData (std::string const& location, + map const& headerFields) { + return requestData(SimpleHttpClient::DELETE, location, "", headerFields); +} + +//////////////////////////////////////////////////////////////////////////////// +/// @brief do a "HEAD" request +//////////////////////////////////////////////////////////////////////////////// + +v8::Handle V8ClientConnection::headData (std::string const& location, + map const& headerFields) { + return requestData(SimpleHttpClient::HEAD, location, "", headerFields); +} + +//////////////////////////////////////////////////////////////////////////////// +/// @brief do a "POST" request +//////////////////////////////////////////////////////////////////////////////// + +v8::Handle V8ClientConnection::postData (std::string const& location, + std::string const& body, + map const& headerFields) { + return requestData(SimpleHttpClient::POST, location, body, headerFields); +} + +//////////////////////////////////////////////////////////////////////////////// +/// @brief do a "PUT" request +//////////////////////////////////////////////////////////////////////////////// + +v8::Handle V8ClientConnection::putData (std::string const& location, + std::string const& body, + map const& headerFields) { + return requestData(SimpleHttpClient::PUT, location, body, headerFields); +} + +//////////////////////////////////////////////////////////////////////////////// +/// @} +//////////////////////////////////////////////////////////////////////////////// + +// ----------------------------------------------------------------------------- +// --SECTION-- private functions +// ----------------------------------------------------------------------------- + +//////////////////////////////////////////////////////////////////////////////// +/// @addtogroup V8ClientConnection +/// @{ +//////////////////////////////////////////////////////////////////////////////// + +//////////////////////////////////////////////////////////////////////////////// +/// @brief executs a request +//////////////////////////////////////////////////////////////////////////////// + +v8::Handle V8ClientConnection::requestData (int method, + string const& location, + string const& body, + map const& headerFields) { + _lastErrorMessage = ""; + _lastHttpReturnCode = 0; + + if (_httpResult) { + delete _httpResult; + } + + if (body.empty()) { + _httpResult = _client->request(method, location, 0, 0, headerFields); + } + else { + _httpResult = _client->request(method, location, body.c_str(), body.length(), headerFields); + } + + if (!_httpResult->isComplete()) { + // not complete + _lastErrorMessage = _client->getErrorMessage(); + + if (_lastErrorMessage.empty()) { + _lastErrorMessage = "Unknown error"; + } + + _lastHttpReturnCode = SimpleHttpResult::HTTP_STATUS_SERVER_ERROR; + + v8::Handle result = v8::Object::New(); + result->Set(v8::String::New("error"), v8::Boolean::New(true)); + result->Set(v8::String::New("code"), v8::Integer::New(SimpleHttpResult::HTTP_STATUS_SERVER_ERROR)); + + int errorNumber = 0; + + switch (_httpResult->getResultType()) { + case (SimpleHttpResult::COULD_NOT_CONNECT) : + errorNumber = TRI_SIMPLE_CLIENT_COULD_NOT_CONNECT; + break; + + case (SimpleHttpResult::READ_ERROR) : + errorNumber = TRI_SIMPLE_CLIENT_COULD_NOT_READ; + break; + + case (SimpleHttpResult::WRITE_ERROR) : + errorNumber = TRI_SIMPLE_CLIENT_COULD_NOT_WRITE; + break; + + default: + errorNumber = TRI_SIMPLE_CLIENT_UNKNOWN_ERROR; + break; + } + + result->Set(v8::String::New("errorNum"), v8::Integer::New(errorNumber)); + result->Set(v8::String::New("errorMessage"), v8::String::New(_lastErrorMessage.c_str(), _lastErrorMessage.length())); + + return result; + } + else { + // complete + _lastHttpReturnCode = _httpResult->getHttpReturnCode(); + + // got a body + if (_httpResult->getBody().str().length() > 0) { + string contentType = _httpResult->getContentType(true); + + if (contentType == "application/json") { + TRI_json_t* js = TRI_JsonString(TRI_UNKNOWN_MEM_ZONE, _httpResult->getBody().str().c_str()); + + if (js != NULL) { + // return v8 object + v8::Handle result = TRI_ObjectJson(js); + TRI_FreeJson(TRI_UNKNOWN_MEM_ZONE, js); + + return result; + } + } + + // return body as string + v8::Handle result = v8::String::New(_httpResult->getBody().str().c_str(), _httpResult->getBody().str().length()); + + return result; + } + else { + // no body + // this should not happen + v8::Handle result; + + result->Set(v8::String::New("error"), v8::Boolean::New(false)); + result->Set(v8::String::New("code"), v8::Integer::New(_httpResult->getHttpReturnCode())); + + return result; + } + } +} + +//////////////////////////////////////////////////////////////////////////////// +/// @} +//////////////////////////////////////////////////////////////////////////////// + +// Local Variables: +// mode: outline-minor +// outline-regexp: "^\\(/// @brief\\|/// {@inheritDoc}\\|/// @addtogroup\\|// --SECTION--\\|/// @\\}\\)" +// End: diff --git a/V8Client/V8ClientConnection.h b/V8Client/V8ClientConnection.h index 31e54bcaef..6e85bf99e9 100644 --- a/V8Client/V8ClientConnection.h +++ b/V8Client/V8ClientConnection.h @@ -40,11 +40,12 @@ #define TRIAGENS_V8_CLIENT_CONNECTION_H 1 #include + #include -#include -#include -#include +// ----------------------------------------------------------------------------- +// --SECTION-- forward declarations +// ----------------------------------------------------------------------------- namespace triagens { namespace httpclient { @@ -53,6 +54,15 @@ namespace triagens { } } +// ----------------------------------------------------------------------------- +// --SECTION-- class V8ClientConnection +// ----------------------------------------------------------------------------- + +//////////////////////////////////////////////////////////////////////////////// +/// @addtogroup ArangoDB +/// @{ +//////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// /// @brief class for http requests //////////////////////////////////////////////////////////////////////////////// @@ -61,170 +71,264 @@ namespace triagens { namespace v8client { class V8ClientConnection { - private: - V8ClientConnection (V8ClientConnection const&); - V8ClientConnection& operator= (V8ClientConnection const&); + private: + V8ClientConnection (V8ClientConnection const&); + V8ClientConnection& operator= (V8ClientConnection const&); - public: - //////////////////////////////////////////////////////////////////////////////// - /// @brief constructor - /// - /// @param string hostname server hostname - /// @param int port server port - /// @param double requestTimeout timeout in seconds for one request - /// @param size_t retries maximum number of request retries - /// @param double connTimeout timeout in seconds for the tcp connect - /// - //////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// +/// @} +//////////////////////////////////////////////////////////////////////////////// - V8ClientConnection (const string& hostname, - int port, - double requestTimeout, - size_t retries, - double connectionTimeout, - bool warn); +// ----------------------------------------------------------------------------- +// --SECTION-- constructors and destructors +// ----------------------------------------------------------------------------- - //////////////////////////////////////////////////////////////////////////////// - /// @brief destructor - //////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// +/// @addtogroup ArangoDB +/// @{ +//////////////////////////////////////////////////////////////////////////////// - ~V8ClientConnection (); + public: - //////////////////////////////////////////////////////////////////////////////// - /// @brief returns true if it is connected - //////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// +/// @brief constructor +/// +/// @param string hostname server hostname +/// @param int port server port +/// @param double requestTimeout timeout in seconds for one request +/// @param size_t retries maximum number of request retries +/// @param double connTimeout timeout in seconds for the tcp connect +//////////////////////////////////////////////////////////////////////////////// - bool isConnected () { - return _connected; - } + V8ClientConnection (const string& hostname, + int port, + double requestTimeout, + size_t retries, + double connectionTimeout, + bool warn); - //////////////////////////////////////////////////////////////////////////////// - /// @brief returns the version and build number of the arango server - //////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// +/// @brief destructor +//////////////////////////////////////////////////////////////////////////////// - const string& getVersion () { - return _version; - } + ~V8ClientConnection (); - //////////////////////////////////////////////////////////////////////////////// - /// @brief do a "GET" request - /// - /// @param string location the request location - /// @param map headerFields additional header fields - /// - /// @return v8::Value a V8 JavaScript object - //////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// +/// @} +//////////////////////////////////////////////////////////////////////////////// - v8::Handle getData (std::string const& location, map const& headerFields); +// ----------------------------------------------------------------------------- +// --SECTION-- public methods +// ----------------------------------------------------------------------------- - //////////////////////////////////////////////////////////////////////////////// - /// @brief do a "DELETE" request - /// - /// @param string location the request location - /// @param map headerFields additional header fields - /// - /// @return v8::Value a V8 JavaScript object - //////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// +/// @addtogroup ArangoDB +/// @{ +//////////////////////////////////////////////////////////////////////////////// - v8::Handle deleteData (std::string const& location, map const& headerFields); + public: - //////////////////////////////////////////////////////////////////////////////// - /// @brief do a "HEAD" request - /// - /// @param string location the request location - /// @param map headerFields additional header fields - /// - /// @return v8::Value a V8 JavaScript object - //////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// +/// @brief returns true if it is connected +//////////////////////////////////////////////////////////////////////////////// - v8::Handle headData (std::string const& location, map const& headerFields); + bool isConnected (); + +//////////////////////////////////////////////////////////////////////////////// +/// @brief returns the version and build number of the arango server +//////////////////////////////////////////////////////////////////////////////// + + const string& getVersion (); + +//////////////////////////////////////////////////////////////////////////////// +/// @brief get the last http return code +/// +/// @return int the code +//////////////////////////////////////////////////////////////////////////////// + + int getLastHttpReturnCode (); + +//////////////////////////////////////////////////////////////////////////////// +/// @brief get the last error message +/// +/// @return string the error message +//////////////////////////////////////////////////////////////////////////////// + + const std::string& getErrorMessage (); + +//////////////////////////////////////////////////////////////////////////////// +/// @brief get the hostname +/// +/// @return string the server name +//////////////////////////////////////////////////////////////////////////////// + + const std::string& getHostname (); - //////////////////////////////////////////////////////////////////////////////// - /// @brief do a "POST" request - /// - /// @param string location the request location - /// @param string body the request body - /// @param map headerFields additional header fields - /// - /// @return v8::Value a V8 JavaScript object - //////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// +/// @brief get the port +/// +/// @return string the server port +//////////////////////////////////////////////////////////////////////////////// - v8::Handle postData (std::string const& location, std::string const& body, map const& headerFields); - - //////////////////////////////////////////////////////////////////////////////// - /// @brief do a "PUT" request - /// - /// @param string location the request location - /// @param string body the request body - /// @param map headerFields additional header fields - /// - /// @return v8::Value a V8 JavaScript object - //////////////////////////////////////////////////////////////////////////////// - - v8::Handle putData (std::string const& location, std::string const& body, map const& headerFields); - - //////////////////////////////////////////////////////////////////////////////// - /// @brief get the last http return code - /// - /// @return int the code - //////////////////////////////////////////////////////////////////////////////// - - int getLastHttpReturnCode () { - return _lastHttpReturnCode; - } - - //////////////////////////////////////////////////////////////////////////////// - /// @brief get the last error message - /// - /// @return string the error message - //////////////////////////////////////////////////////////////////////////////// - - const std::string& getErrorMessage () { - return _lastErrorMessage; - } - - //////////////////////////////////////////////////////////////////////////////// - /// @brief get the hostname - /// - /// @return string the server name - //////////////////////////////////////////////////////////////////////////////// - - const std::string& getHostname (); + int getPort (); - //////////////////////////////////////////////////////////////////////////////// - /// @brief get the port - /// - /// @return string the server port - //////////////////////////////////////////////////////////////////////////////// - - int getPort (); - - //////////////////////////////////////////////////////////////////////////////// - /// @brief get the simple http client - /// - /// @return triagens::httpclient::SimpleHttpClient* then client connection - //////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// +/// @brief get the simple http client +/// +/// @return triagens::httpclient::SimpleHttpClient* then client connection +//////////////////////////////////////////////////////////////////////////////// - triagens::httpclient::SimpleHttpClient* getHttpClient() { - return _client; - } + triagens::httpclient::SimpleHttpClient* getHttpClient(); + +//////////////////////////////////////////////////////////////////////////////// +/// @brief do a "GET" request +/// +/// @param string location the request location +/// @param map headerFields additional header fields +/// +/// @return v8::Value a V8 JavaScript object +//////////////////////////////////////////////////////////////////////////////// + + v8::Handle getData (std::string const& location, + map const& headerFields); + +//////////////////////////////////////////////////////////////////////////////// +/// @brief do a "DELETE" request +/// +/// @param string location the request location +/// @param map headerFields additional header fields +/// +/// @return v8::Value a V8 JavaScript object +//////////////////////////////////////////////////////////////////////////////// + + v8::Handle deleteData (std::string const& location, + map const& headerFields); + +//////////////////////////////////////////////////////////////////////////////// +/// @brief do a "HEAD" request +/// +/// @param string location the request location +/// @param map headerFields additional header fields +/// +/// @return v8::Value a V8 JavaScript object +//////////////////////////////////////////////////////////////////////////////// + + v8::Handle headData (std::string const& location, + map const& headerFields); + +//////////////////////////////////////////////////////////////////////////////// +/// @brief do a "POST" request +/// +/// @param string location the request location +/// @param string body the request body +/// @param map headerFields additional header fields +/// +/// @return v8::Value a V8 JavaScript object +//////////////////////////////////////////////////////////////////////////////// + + v8::Handle postData (std::string const& location, + std::string const& body, + map const& headerFields); + +//////////////////////////////////////////////////////////////////////////////// +/// @brief do a "PUT" request +/// +/// @param string location the request location +/// @param string body the request body +/// @param map headerFields additional header fields +/// +/// @return v8::Value a V8 JavaScript object +//////////////////////////////////////////////////////////////////////////////// + + v8::Handle putData (std::string const& location, + std::string const& body, + map const& headerFields); + +//////////////////////////////////////////////////////////////////////////////// +/// @} +//////////////////////////////////////////////////////////////////////////////// + +// ----------------------------------------------------------------------------- +// --SECTION-- private functions +// ----------------------------------------------------------------------------- + +//////////////////////////////////////////////////////////////////////////////// +/// @addtogroup V8ClientConnection +/// @{ +//////////////////////////////////////////////////////////////////////////////// private: - v8::Handle requestData (int method, std::string const& location, std::string const& body, map const& headerFields); +//////////////////////////////////////////////////////////////////////////////// +/// @brief executs a request +//////////////////////////////////////////////////////////////////////////////// + + v8::Handle requestData (int method, + std::string const& location, + std::string const& body, + map const& headerFields); +//////////////////////////////////////////////////////////////////////////////// +/// @} +//////////////////////////////////////////////////////////////////////////////// + +// ----------------------------------------------------------------------------- +// --SECTION-- private variables +// ----------------------------------------------------------------------------- + +//////////////////////////////////////////////////////////////////////////////// +/// @addtogroup V8ClientConnection +/// @{ +//////////////////////////////////////////////////////////////////////////////// + private: + +//////////////////////////////////////////////////////////////////////////////// +/// @brief server version +//////////////////////////////////////////////////////////////////////////////// + std::string _version; + +//////////////////////////////////////////////////////////////////////////////// +/// @brief connection status +//////////////////////////////////////////////////////////////////////////////// + bool _connected; +//////////////////////////////////////////////////////////////////////////////// +/// @brief last http return code +//////////////////////////////////////////////////////////////////////////////// + int _lastHttpReturnCode; + +//////////////////////////////////////////////////////////////////////////////// +/// @brief last error message +//////////////////////////////////////////////////////////////////////////////// + std::string _lastErrorMessage; +//////////////////////////////////////////////////////////////////////////////// +/// @brief underlying client +//////////////////////////////////////////////////////////////////////////////// + triagens::httpclient::SimpleHttpClient* _client; +//////////////////////////////////////////////////////////////////////////////// +/// @brief last result +//////////////////////////////////////////////////////////////////////////////// + triagens::httpclient::SimpleHttpResult* _httpResult; }; } } -#endif /* HTTPCLIENT_H */ +//////////////////////////////////////////////////////////////////////////////// +/// @} +//////////////////////////////////////////////////////////////////////////////// + +#endif + +// Local Variables: +// mode: outline-minor +// outline-regexp: "^\\(/// @brief\\|/// {@inheritDoc}\\|/// @addtogroup\\|// --SECTION--\\|/// @\\}\\)" +// End: