//////////////////////////////////////////////////////////////////////////////// /// @brief http request /// /// @file /// /// DISCLAIMER /// /// Copyright 2004-2012 triAGENS GmbH, Cologne, Germany /// /// Licensed under the Apache License, Version 2.0 (the "License"); /// you may not use this file except in compliance with the License. /// You may obtain a copy of the License at /// /// http://www.apache.org/licenses/LICENSE-2.0 /// /// Unless required by applicable law or agreed to in writing, software /// distributed under the License is distributed on an "AS IS" BASIS, /// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. /// See the License for the specific language governing permissions and /// limitations under the License. /// /// Copyright holder is triAGENS GmbH, Cologne, Germany /// /// @author Dr. Frank Celler /// @author Achim Brandt /// @author Copyright 2008-2012, triAGENS GmbH, Cologne, Germany //////////////////////////////////////////////////////////////////////////////// #include "HttpRequest.h" #include "Logger/Logger.h" #include "Basics/StringBuffer.h" #include "Basics/StringUtils.h" using namespace triagens::basics; using namespace triagens::rest; using namespace std; // ----------------------------------------------------------------------------- // --SECTION-- class HttpRequest // ----------------------------------------------------------------------------- // ----------------------------------------------------------------------------- // --SECTION-- constructors and destructors // ----------------------------------------------------------------------------- //////////////////////////////////////////////////////////////////////////////// /// @addtogroup Rest /// @{ //////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// /// @brief http request constructor //////////////////////////////////////////////////////////////////////////////// HttpRequest::HttpRequest () : _connectionInfo(), _type(HTTP_REQUEST_ILLEGAL), _prefix(), _suffix(), _version(HTTP_1_0), _user() { } //////////////////////////////////////////////////////////////////////////////// /// @brief destructor //////////////////////////////////////////////////////////////////////////////// HttpRequest::~HttpRequest () { } //////////////////////////////////////////////////////////////////////////////// /// @} //////////////////////////////////////////////////////////////////////////////// // ----------------------------------------------------------------------------- // --SECTION-- public methods // ----------------------------------------------------------------------------- //////////////////////////////////////////////////////////////////////////////// /// @addtogroup Rest /// @{ //////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// /// @brief returns the server IP //////////////////////////////////////////////////////////////////////////////// ConnectionInfo const& HttpRequest::connectionInfo () const { return _connectionInfo; } //////////////////////////////////////////////////////////////////////////////// /// @brief sets the server IP //////////////////////////////////////////////////////////////////////////////// void HttpRequest::setConnectionInfo (ConnectionInfo const& info) { _connectionInfo = info; } //////////////////////////////////////////////////////////////////////////////// /// @brief returns the http request type //////////////////////////////////////////////////////////////////////////////// HttpRequest::HttpRequestType HttpRequest::requestType () const { return _type; } //////////////////////////////////////////////////////////////////////////////// /// @brief sets the http request type //////////////////////////////////////////////////////////////////////////////// void HttpRequest::setRequestType (HttpRequestType newType) { _type = newType; } //////////////////////////////////////////////////////////////////////////////// /// @brief returns whether HTTP version is 1.0 //////////////////////////////////////////////////////////////////////////////// bool HttpRequest::isHttp10 () { return _version == HTTP_1_0; } //////////////////////////////////////////////////////////////////////////////// /// @brief returns whether HTTP version is 1.1 //////////////////////////////////////////////////////////////////////////////// bool HttpRequest::isHttp11 () { return _version == HTTP_1_1; } //////////////////////////////////////////////////////////////////////////////// /// @brief returns the authenticated user //////////////////////////////////////////////////////////////////////////////// string const& HttpRequest::user () { return _user; } //////////////////////////////////////////////////////////////////////////////// /// @brief sets the authenticated user //////////////////////////////////////////////////////////////////////////////// void HttpRequest::setUser (string const& user) { _user = user; } //////////////////////////////////////////////////////////////////////////////// /// @} //////////////////////////////////////////////////////////////////////////////// // ----------------------------------------------------------------------------- // --SECTION-- public prefix/suffix methods // ----------------------------------------------------------------------------- //////////////////////////////////////////////////////////////////////////////// /// @addtogroup Rest /// @{ //////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// /// @brief returns the prefix path of the request //////////////////////////////////////////////////////////////////////////////// char const* HttpRequest::prefix () const { return _prefix.c_str(); } //////////////////////////////////////////////////////////////////////////////// /// @brief sets the path of the request //////////////////////////////////////////////////////////////////////////////// void HttpRequest::setPrefix (char const* path) { _prefix = path; } //////////////////////////////////////////////////////////////////////////////// /// @brief returns all suffix parts //////////////////////////////////////////////////////////////////////////////// vector const& HttpRequest::suffix () const { return _suffix; } //////////////////////////////////////////////////////////////////////////////// /// @brief adds a suffix part //////////////////////////////////////////////////////////////////////////////// void HttpRequest::addSuffix (char const* part) { _suffix.push_back(part); } //////////////////////////////////////////////////////////////////////////////// /// @} //////////////////////////////////////////////////////////////////////////////// // ----------------------------------------------------------------------------- // --SECTION-- END-OF-FILE // ----------------------------------------------------------------------------- // Local Variables: // mode: outline-minor // outline-regexp: "^\\(/// @brief\\|/// {@inheritDoc}\\|/// @addtogroup\\|/// @page\\|// --SECTION--\\|/// @\\}\\)" // End: