mirror of
https://github.com/monero-project/monero.git
synced 2024-12-23 12:09:54 +00:00
epee: remove dead HTTP code
http_client.h
This commit is contained in:
parent
365fd45b03
commit
ab7102e31f
5 changed files with 0 additions and 137 deletions
|
@ -72,7 +72,6 @@ namespace http
|
||||||
virtual bool is_connected(bool *ssl = NULL) = 0;
|
virtual bool is_connected(bool *ssl = NULL) = 0;
|
||||||
virtual bool invoke(const boost::string_ref uri, const boost::string_ref method, const boost::string_ref body, std::chrono::milliseconds timeout, const http_response_info** ppresponse_info = NULL, const fields_list& additional_params = fields_list()) = 0;
|
virtual bool invoke(const boost::string_ref uri, const boost::string_ref method, const boost::string_ref body, std::chrono::milliseconds timeout, const http_response_info** ppresponse_info = NULL, const fields_list& additional_params = fields_list()) = 0;
|
||||||
virtual bool invoke_get(const boost::string_ref uri, std::chrono::milliseconds timeout, const std::string& body = std::string(), const http_response_info** ppresponse_info = NULL, const fields_list& additional_params = fields_list()) = 0;
|
virtual bool invoke_get(const boost::string_ref uri, std::chrono::milliseconds timeout, const std::string& body = std::string(), const http_response_info** ppresponse_info = NULL, const fields_list& additional_params = fields_list()) = 0;
|
||||||
virtual bool invoke_post(const boost::string_ref uri, const std::string& body, std::chrono::milliseconds timeout, const http_response_info** ppresponse_info = NULL, const fields_list& additional_params = fields_list()) = 0;
|
|
||||||
virtual uint64_t get_bytes_sent() const = 0;
|
virtual uint64_t get_bytes_sent() const = 0;
|
||||||
virtual uint64_t get_bytes_received() const = 0;
|
virtual uint64_t get_bytes_received() const = 0;
|
||||||
};
|
};
|
||||||
|
|
|
@ -55,20 +55,8 @@ namespace net_utils
|
||||||
http_method_unknown
|
http_method_unknown
|
||||||
};
|
};
|
||||||
|
|
||||||
enum http_content_type
|
|
||||||
{
|
|
||||||
http_content_type_text_html,
|
|
||||||
http_content_type_image_gif,
|
|
||||||
http_content_type_other,
|
|
||||||
http_content_type_not_set
|
|
||||||
};
|
|
||||||
|
|
||||||
typedef std::list<std::pair<std::string, std::string> > fields_list;
|
typedef std::list<std::pair<std::string, std::string> > fields_list;
|
||||||
|
|
||||||
std::string get_value_from_fields_list(const std::string& param_name, const net_utils::http::fields_list& fields);
|
|
||||||
|
|
||||||
std::string get_value_from_uri_line(const std::string& param_name, const std::string& uri);
|
|
||||||
|
|
||||||
static inline void add_field(std::string& out, const boost::string_ref name, const boost::string_ref value)
|
static inline void add_field(std::string& out, const boost::string_ref name, const boost::string_ref value)
|
||||||
{
|
{
|
||||||
out.append(name.data(), name.size()).append(": ");
|
out.append(name.data(), name.size()).append(": ");
|
||||||
|
|
|
@ -32,7 +32,6 @@
|
||||||
#include <boost/regex.hpp>
|
#include <boost/regex.hpp>
|
||||||
#include <boost/optional/optional.hpp>
|
#include <boost/optional/optional.hpp>
|
||||||
#include <boost/utility/string_ref.hpp>
|
#include <boost/utility/string_ref.hpp>
|
||||||
//#include <mbstring.h>
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <cctype>
|
#include <cctype>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
@ -48,57 +47,13 @@
|
||||||
#include "net_parse_helpers.h"
|
#include "net_parse_helpers.h"
|
||||||
#include "syncobj.h"
|
#include "syncobj.h"
|
||||||
|
|
||||||
//#include "shlwapi.h"
|
|
||||||
|
|
||||||
//#pragma comment(lib, "shlwapi.lib")
|
|
||||||
|
|
||||||
#undef MONERO_DEFAULT_LOG_CATEGORY
|
#undef MONERO_DEFAULT_LOG_CATEGORY
|
||||||
#define MONERO_DEFAULT_LOG_CATEGORY "net.http"
|
#define MONERO_DEFAULT_LOG_CATEGORY "net.http"
|
||||||
|
|
||||||
extern epee::critical_section gregexp_lock;
|
|
||||||
|
|
||||||
|
|
||||||
namespace epee
|
namespace epee
|
||||||
{
|
{
|
||||||
namespace net_utils
|
namespace net_utils
|
||||||
{
|
{
|
||||||
|
|
||||||
/*struct url
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
void parse(const std::string& url_s)
|
|
||||||
{
|
|
||||||
const string prot_end("://");
|
|
||||||
string::const_iterator prot_i = search(url_s.begin(), url_s.end(),
|
|
||||||
prot_end.begin(), prot_end.end());
|
|
||||||
protocol_.reserve(distance(url_s.begin(), prot_i));
|
|
||||||
transform(url_s.begin(), prot_i,
|
|
||||||
back_inserter(protocol_),
|
|
||||||
ptr_fun<int,int>(tolower)); // protocol is icase
|
|
||||||
if( prot_i == url_s.end() )
|
|
||||||
return;
|
|
||||||
advance(prot_i, prot_end.length());
|
|
||||||
string::const_iterator path_i = find(prot_i, url_s.end(), '/');
|
|
||||||
host_.reserve(distance(prot_i, path_i));
|
|
||||||
transform(prot_i, path_i,
|
|
||||||
back_inserter(host_),
|
|
||||||
ptr_fun<int,int>(tolower)); // host is icase
|
|
||||||
string::const_iterator query_i = find(path_i, url_s.end(), '?');
|
|
||||||
path_.assign(path_i, query_i);
|
|
||||||
if( query_i != url_s.end() )
|
|
||||||
++query_i;
|
|
||||||
query_.assign(query_i, url_s.end());
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string protocol_;
|
|
||||||
std::string host_;
|
|
||||||
std::string path_;
|
|
||||||
std::string query_;
|
|
||||||
};*/
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
namespace http
|
namespace http
|
||||||
{
|
{
|
||||||
|
@ -135,7 +90,6 @@ namespace net_utils
|
||||||
http_response_info m_response_info;
|
http_response_info m_response_info;
|
||||||
size_t m_len_in_summary;
|
size_t m_len_in_summary;
|
||||||
size_t m_len_in_remain;
|
size_t m_len_in_remain;
|
||||||
//std::string* m_ptarget_buffer;
|
|
||||||
boost::shared_ptr<i_sub_handler> m_pcontent_encoding_handler;
|
boost::shared_ptr<i_sub_handler> m_pcontent_encoding_handler;
|
||||||
reciev_machine_state m_state;
|
reciev_machine_state m_state;
|
||||||
chunked_state m_chunked_state;
|
chunked_state m_chunked_state;
|
||||||
|
@ -300,12 +254,6 @@ namespace net_utils
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
inline bool invoke_post(const boost::string_ref uri, const std::string& body, std::chrono::milliseconds timeout, const http_response_info** ppresponse_info = NULL, const fields_list& additional_params = fields_list()) override
|
|
||||||
{
|
|
||||||
CRITICAL_REGION_LOCAL(m_lock);
|
|
||||||
return invoke(uri, "POST", body, timeout, ppresponse_info, additional_params);
|
|
||||||
}
|
|
||||||
//---------------------------------------------------------------------------
|
|
||||||
bool test(const std::string &s, std::chrono::milliseconds timeout) // TEST FUNC ONLY
|
bool test(const std::string &s, std::chrono::milliseconds timeout) // TEST FUNC ONLY
|
||||||
{
|
{
|
||||||
CRITICAL_REGION_LOCAL(m_lock);
|
CRITICAL_REGION_LOCAL(m_lock);
|
||||||
|
|
|
@ -37,7 +37,6 @@ monero_add_library(epee byte_slice.cpp byte_stream.cpp hex.cpp abstract_http_cli
|
||||||
misc_language.cpp
|
misc_language.cpp
|
||||||
file_io_utils.cpp
|
file_io_utils.cpp
|
||||||
net_parse_helpers.cpp
|
net_parse_helpers.cpp
|
||||||
http_base.cpp
|
|
||||||
${EPEE_HEADERS_PUBLIC}
|
${EPEE_HEADERS_PUBLIC}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -1,71 +0,0 @@
|
||||||
// Copyright (c) 2006-2013, Andrey N. Sabelnikov, www.sabelnikov.net
|
|
||||||
// All rights reserved.
|
|
||||||
//
|
|
||||||
// Redistribution and use in source and binary forms, with or without
|
|
||||||
// modification, are permitted provided that the following conditions are met:
|
|
||||||
// * Redistributions of source code must retain the above copyright
|
|
||||||
// notice, this list of conditions and the following disclaimer.
|
|
||||||
// * Redistributions in binary form must reproduce the above copyright
|
|
||||||
// notice, this list of conditions and the following disclaimer in the
|
|
||||||
// documentation and/or other materials provided with the distribution.
|
|
||||||
// * Neither the name of the Andrey N. Sabelnikov nor the
|
|
||||||
// names of its contributors may be used to endorse or promote products
|
|
||||||
// derived from this software without specific prior written permission.
|
|
||||||
//
|
|
||||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
||||||
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
||||||
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER BE LIABLE FOR ANY
|
|
||||||
// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
||||||
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
||||||
// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
//
|
|
||||||
|
|
||||||
#include "net/http_base.h"
|
|
||||||
#include "memwipe.h"
|
|
||||||
#include "string_tools.h"
|
|
||||||
|
|
||||||
#include <boost/regex.hpp>
|
|
||||||
#include <string>
|
|
||||||
#include <utility>
|
|
||||||
|
|
||||||
#undef MONERO_DEFAULT_LOG_CATEGORY
|
|
||||||
#define MONERO_DEFAULT_LOG_CATEGORY "net.http"
|
|
||||||
|
|
||||||
namespace epee
|
|
||||||
{
|
|
||||||
namespace net_utils
|
|
||||||
{
|
|
||||||
namespace http
|
|
||||||
{
|
|
||||||
std::string get_value_from_fields_list(const std::string& param_name, const net_utils::http::fields_list& fields)
|
|
||||||
{
|
|
||||||
fields_list::const_iterator it = fields.begin();
|
|
||||||
for(; it != fields.end(); ++it)
|
|
||||||
if(!string_tools::compare_no_case(param_name, it->first))
|
|
||||||
break;
|
|
||||||
|
|
||||||
if(it==fields.end())
|
|
||||||
return std::string();
|
|
||||||
|
|
||||||
return it->second;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string get_value_from_uri_line(const std::string& param_name, const std::string& uri)
|
|
||||||
{
|
|
||||||
std::string buff = "([\\?|&])";
|
|
||||||
buff += param_name + "=([^&]*)";
|
|
||||||
boost::regex match_param(buff.c_str(), boost::regex::icase | boost::regex::normal);
|
|
||||||
boost::smatch result;
|
|
||||||
if(boost::regex_search(uri, result, match_param, boost::match_default) && result[0].matched)
|
|
||||||
{
|
|
||||||
return result[2];
|
|
||||||
}
|
|
||||||
return std::string();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in a new issue