mirror of https://gitee.com/bigwinds/arangodb
removed unused Url class
This commit is contained in:
parent
9aaeafda10
commit
b922c74ab7
|
@ -116,7 +116,6 @@ add_library(
|
|||
Rest/InitialiseRest.cpp
|
||||
Rest/SslInterface.cpp
|
||||
Rest/Version.cpp
|
||||
Rest/Url.cpp
|
||||
ShapedJson/json-shaper.cpp
|
||||
ShapedJson/shape-accessor.cpp
|
||||
ShapedJson/shaped-json.cpp
|
||||
|
|
|
@ -89,7 +89,6 @@ lib_libarango_a_SOURCES = \
|
|||
lib/Rest/InitialiseRest.cpp \
|
||||
lib/Rest/SslInterface.cpp \
|
||||
lib/Rest/Version.cpp \
|
||||
lib/Rest/Url.cpp \
|
||||
lib/ShapedJson/json-shaper.cpp \
|
||||
lib/ShapedJson/shape-accessor.cpp \
|
||||
lib/ShapedJson/shaped-json.cpp \
|
||||
|
|
|
@ -44,7 +44,6 @@
|
|||
#include "Basics/InitialiseBasics.h"
|
||||
#include "Rest/HttpResponse.h"
|
||||
#include "Rest/Version.h"
|
||||
#include "Rest/Url.h"
|
||||
#include "Statistics/statistics.h"
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
@ -116,7 +115,6 @@ namespace triagens {
|
|||
void InitialiseRest (int argc, char* argv[]) {
|
||||
TRIAGENS_BASICS_INITIALISE(argc, argv);
|
||||
|
||||
TRI_InitialiseUrl();
|
||||
TRI_InitialiseStatistics();
|
||||
|
||||
SSL_library_init();
|
||||
|
@ -138,7 +136,6 @@ namespace triagens {
|
|||
opensslCleanup();
|
||||
#endif
|
||||
|
||||
TRI_ShutdownUrl();
|
||||
TRI_ShutdownStatistics();
|
||||
|
||||
TRIAGENS_BASICS_SHUTDOWN;
|
||||
|
|
214
lib/Rest/Url.cpp
214
lib/Rest/Url.cpp
|
@ -1,214 +0,0 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief url class
|
||||
///
|
||||
/// @file
|
||||
///
|
||||
/// DISCLAIMER
|
||||
///
|
||||
/// Copyright 2004-2013 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 2007-2013, triAGENS GmbH, Cologne, Germany
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "Url.h"
|
||||
|
||||
#include <regex.h>
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include "Basics/Exceptions.h"
|
||||
#include "Basics/StringUtils.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace triagens::basics;
|
||||
using namespace triagens::rest;
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// --SECTION-- private variables
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @addtogroup Url
|
||||
/// @{
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief URL pattern
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static regex_t re;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// --SECTION-- constructors and destructors
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @addtogroup Url
|
||||
/// @{
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief constructor
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
Url::Url (string const& urlName)
|
||||
: _host("localhost"),
|
||||
_port(80),
|
||||
_service("http"),
|
||||
_path("") {
|
||||
int result;
|
||||
regmatch_t matches[5];
|
||||
|
||||
result = regexec(&re, urlName.c_str(), sizeof(matches) / sizeof(matches[0]), matches, 0);
|
||||
|
||||
if (result == 0) {
|
||||
char const* ptr = urlName.c_str();
|
||||
string port = string(ptr + matches[3].rm_so, matches[3].rm_eo - matches[3].rm_so);
|
||||
|
||||
_host = string(ptr + matches[2].rm_so, matches[2].rm_eo - matches[2].rm_so);
|
||||
_port = port.empty() ? 80 : StringUtils::uint32(port.substr(1));
|
||||
_path = string(ptr + matches[4].rm_so, matches[4].rm_eo - matches[4].rm_so);
|
||||
|
||||
if (matches[1].rm_so == matches[1].rm_eo) {
|
||||
_service = "http";
|
||||
}
|
||||
else {
|
||||
_service = string(ptr + matches[1].rm_so, matches[1].rm_eo - matches[1].rm_so - 1);
|
||||
}
|
||||
}
|
||||
else {
|
||||
THROW_PARAMETER_ERROR("url", "url not valid", "constructor");
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// --SECTION-- public methods
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @addtogroup Url
|
||||
/// @{
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief returns the service part
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
string const& Url::service () const {
|
||||
return _service;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief returns the host part
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
string const& Url::host () const {
|
||||
return _host;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief returns the port
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
uint16_t Url::port () const {
|
||||
return _port;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief returns the path part
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
string const& Url::path () const {
|
||||
return _path;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// --SECTION-- MODULE
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// --SECTION-- private variables
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @addtogroup Url
|
||||
/// @{
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief already initialised
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static bool Initialised = false;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// --SECTION-- public functions
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @addtogroup Url
|
||||
/// @{
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief initialises the hashes components
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void TRI_InitialiseUrl () {
|
||||
if (Initialised) {
|
||||
return;
|
||||
}
|
||||
|
||||
regcomp(&re, "([a-z]*:)//([a-z0-9\\._-]*)(:[0-9]+)?(/.*)", REG_ICASE | REG_EXTENDED);
|
||||
|
||||
Initialised = true;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief shut downs the hashes components
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void TRI_ShutdownUrl () {
|
||||
regfree(&re);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Local Variables:
|
||||
// mode: outline-minor
|
||||
// outline-regexp: "/// @brief\\|/// {@inheritDoc}\\|/// @addtogroup\\|/// @page\\|// --SECTION--\\|/// @\\}"
|
||||
// End:
|
194
lib/Rest/Url.h
194
lib/Rest/Url.h
|
@ -1,194 +0,0 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief url class
|
||||
///
|
||||
/// @file
|
||||
/// A class describing the various parts of an URL.
|
||||
///
|
||||
/// DISCLAIMER
|
||||
///
|
||||
/// Copyright 2004-2013 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 2007-2013, triAGENS GmbH, Cologne, Germany
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef TRIAGENS_REST_URL_H
|
||||
#define TRIAGENS_REST_URL_H 1
|
||||
|
||||
#include "Basics/Common.h"
|
||||
|
||||
namespace triagens {
|
||||
namespace rest {
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// --SECTION-- class Url
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @addtogroup Url
|
||||
/// @{
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief Url
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class Url {
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// --SECTION-- constructors and destructors
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @addtogroup Url
|
||||
/// @{
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
public:
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief constructor
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
explicit
|
||||
Url (string const& urlName);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// --SECTION-- public methods
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @addtogroup Url
|
||||
/// @{
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
public:
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief returns the service part
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
string const& service () const;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief returns the host part
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
string const& host () const;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief returns the port
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
uint16_t port () const;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief returns the path part
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
string const& path () const;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// --SECTION-- private variables
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @addtogroup Url
|
||||
/// @{
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
private:
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief host
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
string _host;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief port
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
uint16_t _port;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief service
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
string _service;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief path
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
string _path;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// --SECTION-- MODULE
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// --SECTION-- public functions
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @addtogroup Url
|
||||
/// @{
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief initialises the url components
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void TRI_InitialiseUrl (void);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief shut downs the url components
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void TRI_ShutdownUrl (void);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#endif
|
||||
|
||||
// Local Variables:
|
||||
// mode: outline-minor
|
||||
// outline-regexp: "/// @brief\\|/// {@inheritDoc}\\|/// @addtogroup\\|/// @page\\|// --SECTION--\\|/// @\\}"
|
||||
// End:
|
Loading…
Reference in New Issue