net-cpp-2.0.0/ 0000775 0001751 0001751 00000000000 12553403521 013441 5 ustar tvoss tvoss 0000000 0000000 net-cpp-2.0.0/CMakeLists.txt 0000664 0001751 0001751 00000002600 12553403510 016175 0 ustar tvoss tvoss 0000000 0000000 # Copyright © 2013 Canonical Ltd.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 3 as
# published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
#
# Authored by: Thomas Voss
cmake_minimum_required(VERSION 2.8)
project(net-cpp)
find_package(Threads)
include(GNUInstallDirs)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror -Wall -pedantic -Wextra -fvisibility=hidden")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Werror -Wall -fno-strict-aliasing -fvisibility=hidden -fvisibility-inlines-hidden -pedantic -Wextra")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--no-undefined")
set(NET_CPP_VERSION_MAJOR 2)
set(NET_CPP_VERSION_MINOR 0)
set(NET_CPP_VERSION_PATCH 0)
include(CTest)
include_directories(
include/
)
file(GLOB_RECURSE NET_CPP_INTERFACE_HEADERS include/*.h)
add_subdirectory(doc)
add_subdirectory(data)
add_subdirectory(include)
add_subdirectory(src)
add_subdirectory(tests)
net-cpp-2.0.0/symbols.map 0000664 0001751 0001751 00000000345 12553403510 015630 0 ustar tvoss tvoss 0000000 0000000 {
global:
extern "C++" {
core::*;
typeinfo?for?core::*;
typeinfo?name?for?core::*;
VTT?for?core::*;
virtual?thunk?to?core::*;
vtable?for?core::*;
std::hash*;
};
local:
extern "C++" {
*;
};
}; net-cpp-2.0.0/src/ 0000775 0001751 0001751 00000000000 12553403521 014230 5 ustar tvoss tvoss 0000000 0000000 net-cpp-2.0.0/src/CMakeLists.txt 0000664 0001751 0001751 00000003273 12553403510 016773 0 ustar tvoss tvoss 0000000 0000000 # Copyright © 2013 Canonical Ltd.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 3 as
# published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
#
# Authored by: Thomas Voss
find_package(Boost COMPONENTS system serialization REQUIRED)
find_package(CURL REQUIRED)
include_directories(${Boost_INCLUDE_DIRS} ${CURL_INCLUDE_DIRS})
add_library(
net-cpp SHARED
${NET_CPP_INTERFACE_HEADERS}
core/location.cpp
core/net/error.cpp
core/net/uri.cpp
core/net/http/client.cpp
core/net/http/error.cpp
core/net/http/header.cpp
core/net/http/request.cpp
core/net/http/status.cpp
core/net/http/impl/curl/client.cpp
core/net/http/impl/curl/easy.cpp
core/net/http/impl/curl/multi.cpp
core/net/http/impl/curl/shared.cpp
)
target_link_libraries(
net-cpp
${CMAKE_THREAD_LIBS_INIT}
${Boost_LIBRARIES}
${CURL_LIBRARIES}
)
set(symbol_map "${CMAKE_SOURCE_DIR}/symbols.map")
set_target_properties(
net-cpp
PROPERTIES
LINK_FLAGS "${ldflags} -Wl,--version-script,${symbol_map}"
LINK_DEPENDS ${symbol_map}
VERSION ${NET_CPP_VERSION_MAJOR}.${NET_CPP_VERSION_MINOR}.${NET_CPP_VERSION_PATCH}
SOVERSION ${NET_CPP_VERSION_MAJOR}
)
install(
TARGETS net-cpp
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
)
net-cpp-2.0.0/src/core/ 0000775 0001751 0001751 00000000000 12553403521 015160 5 ustar tvoss tvoss 0000000 0000000 net-cpp-2.0.0/src/core/net/ 0000775 0001751 0001751 00000000000 12553403521 015746 5 ustar tvoss tvoss 0000000 0000000 net-cpp-2.0.0/src/core/net/http/ 0000775 0001751 0001751 00000000000 12553403521 016725 5 ustar tvoss tvoss 0000000 0000000 net-cpp-2.0.0/src/core/net/http/client.cpp 0000664 0001751 0001751 00000004614 12553403510 020712 0 ustar tvoss tvoss 0000000 0000000 /*
* Copyright © 2013 Canonical Ltd.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License version 3,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*
* Authored by: Thomas Voß
*/
#include
#include
#include
#include
namespace net = core::net;
namespace http = net::http;
http::Client::Errors::HttpMethodNotSupported::HttpMethodNotSupported(
http::Method method,
const core::Location& loc)
: http::Error("Http method not suppored", loc),
method(method)
{
}
std::shared_ptr http::Client::post_form(
const http::Request::Configuration& configuration,
const std::map& values)
{
std::stringstream ss;
bool first{true};
for (const auto& pair : values)
{
ss << (first ? "" : "&") << url_escape(pair.first) << "=" << url_escape(pair.second);
first = false;
}
return post(configuration, ss.str(), http::ContentType::x_www_form_urlencoded);
}
std::string http::Client::uri_to_string(const core::net::Uri& uri) const
{
std::ostringstream s;
// Start with the host of the URI
s << uri.host;
// Append each of the components of the path
for (const std::string& part : uri.path)
{
s << "/" << url_escape(part);
}
// Append the parameters
bool first = true;
for (const std::pair& query_parameter : uri.query_parameters)
{
if (first)
{
// The first parameter needs a ?
s << "?";
first = false;
}
else
{
// The rest are separated with a &
s << "&";
}
// URL escape the parameters
s << url_escape(query_parameter.first) << "=" << url_escape(query_parameter.second);
}
// We're done
return s.str();
}
net-cpp-2.0.0/src/core/net/http/request.cpp 0000664 0001751 0001751 00000003371 12553403510 021123 0 ustar tvoss tvoss 0000000 0000000 /*
* Copyright © 2013 Canonical Ltd.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License version 3,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*
* Authored by: Thomas Voß
*/
#include
#include