Fix style warnings reported by cpplint.
This commit is contained in:
+24
-14
@@ -6,8 +6,8 @@
|
||||
},
|
||||
{
|
||||
"directory": "/home/adam/github/webcc/build/src/webcc",
|
||||
"command": "/usr/bin/c++ -DBOOST_ASIO_NO_DEPRECATED -DWEBCC_ENABLE_LOG -DWEBCC_ENABLE_SOAP -I/home/adam/github/webcc/src -I/home/adam/github/webcc/third_party -std=c++11 -o CMakeFiles/webcc.dir/common.cc.o -c /home/adam/github/webcc/src/webcc/common.cc",
|
||||
"file": "/home/adam/github/webcc/src/webcc/common.cc"
|
||||
"command": "/usr/bin/c++ -DBOOST_ASIO_NO_DEPRECATED -DWEBCC_ENABLE_LOG -DWEBCC_ENABLE_SOAP -I/home/adam/github/webcc/src -I/home/adam/github/webcc/third_party -std=c++11 -o CMakeFiles/webcc.dir/globals.cc.o -c /home/adam/github/webcc/src/webcc/globals.cc",
|
||||
"file": "/home/adam/github/webcc/src/webcc/globals.cc"
|
||||
},
|
||||
{
|
||||
"directory": "/home/adam/github/webcc/build/src/webcc",
|
||||
@@ -66,8 +66,18 @@
|
||||
},
|
||||
{
|
||||
"directory": "/home/adam/github/webcc/build/src/webcc",
|
||||
"command": "/usr/bin/c++ -DBOOST_ASIO_NO_DEPRECATED -DWEBCC_ENABLE_LOG -DWEBCC_ENABLE_SOAP -I/home/adam/github/webcc/src -I/home/adam/github/webcc/third_party -std=c++11 -o CMakeFiles/webcc.dir/rest_server.cc.o -c /home/adam/github/webcc/src/webcc/rest_server.cc",
|
||||
"file": "/home/adam/github/webcc/src/webcc/rest_server.cc"
|
||||
"command": "/usr/bin/c++ -DBOOST_ASIO_NO_DEPRECATED -DWEBCC_ENABLE_LOG -DWEBCC_ENABLE_SOAP -I/home/adam/github/webcc/src -I/home/adam/github/webcc/third_party -std=c++11 -o CMakeFiles/webcc.dir/rest_client.cc.o -c /home/adam/github/webcc/src/webcc/rest_client.cc",
|
||||
"file": "/home/adam/github/webcc/src/webcc/rest_client.cc"
|
||||
},
|
||||
{
|
||||
"directory": "/home/adam/github/webcc/build/src/webcc",
|
||||
"command": "/usr/bin/c++ -DBOOST_ASIO_NO_DEPRECATED -DWEBCC_ENABLE_LOG -DWEBCC_ENABLE_SOAP -I/home/adam/github/webcc/src -I/home/adam/github/webcc/third_party -std=c++11 -o CMakeFiles/webcc.dir/rest_request_handler.cc.o -c /home/adam/github/webcc/src/webcc/rest_request_handler.cc",
|
||||
"file": "/home/adam/github/webcc/src/webcc/rest_request_handler.cc"
|
||||
},
|
||||
{
|
||||
"directory": "/home/adam/github/webcc/build/src/webcc",
|
||||
"command": "/usr/bin/c++ -DBOOST_ASIO_NO_DEPRECATED -DWEBCC_ENABLE_LOG -DWEBCC_ENABLE_SOAP -I/home/adam/github/webcc/src -I/home/adam/github/webcc/third_party -std=c++11 -o CMakeFiles/webcc.dir/rest_service_manager.cc.o -c /home/adam/github/webcc/src/webcc/rest_service_manager.cc",
|
||||
"file": "/home/adam/github/webcc/src/webcc/rest_service_manager.cc"
|
||||
},
|
||||
{
|
||||
"directory": "/home/adam/github/webcc/build/src/webcc",
|
||||
@@ -84,6 +94,16 @@
|
||||
"command": "/usr/bin/c++ -DBOOST_ASIO_NO_DEPRECATED -DWEBCC_ENABLE_LOG -DWEBCC_ENABLE_SOAP -I/home/adam/github/webcc/src -I/home/adam/github/webcc/third_party -std=c++11 -o CMakeFiles/webcc.dir/utility.cc.o -c /home/adam/github/webcc/src/webcc/utility.cc",
|
||||
"file": "/home/adam/github/webcc/src/webcc/utility.cc"
|
||||
},
|
||||
{
|
||||
"directory": "/home/adam/github/webcc/build/src/webcc",
|
||||
"command": "/usr/bin/c++ -DBOOST_ASIO_NO_DEPRECATED -DWEBCC_ENABLE_LOG -DWEBCC_ENABLE_SOAP -I/home/adam/github/webcc/src -I/home/adam/github/webcc/third_party -std=c++11 -o CMakeFiles/webcc.dir/soap_request_handler.cc.o -c /home/adam/github/webcc/src/webcc/soap_request_handler.cc",
|
||||
"file": "/home/adam/github/webcc/src/webcc/soap_request_handler.cc"
|
||||
},
|
||||
{
|
||||
"directory": "/home/adam/github/webcc/build/src/webcc",
|
||||
"command": "/usr/bin/c++ -DBOOST_ASIO_NO_DEPRECATED -DWEBCC_ENABLE_LOG -DWEBCC_ENABLE_SOAP -I/home/adam/github/webcc/src -I/home/adam/github/webcc/third_party -std=c++11 -o CMakeFiles/webcc.dir/soap_xml.cc.o -c /home/adam/github/webcc/src/webcc/soap_xml.cc",
|
||||
"file": "/home/adam/github/webcc/src/webcc/soap_xml.cc"
|
||||
},
|
||||
{
|
||||
"directory": "/home/adam/github/webcc/build/src/webcc",
|
||||
"command": "/usr/bin/c++ -DBOOST_ASIO_NO_DEPRECATED -DWEBCC_ENABLE_LOG -DWEBCC_ENABLE_SOAP -I/home/adam/github/webcc/src -I/home/adam/github/webcc/third_party -std=c++11 -o CMakeFiles/webcc.dir/soap_message.cc.o -c /home/adam/github/webcc/src/webcc/soap_message.cc",
|
||||
@@ -99,16 +119,6 @@
|
||||
"command": "/usr/bin/c++ -DBOOST_ASIO_NO_DEPRECATED -DWEBCC_ENABLE_LOG -DWEBCC_ENABLE_SOAP -I/home/adam/github/webcc/src -I/home/adam/github/webcc/third_party -std=c++11 -o CMakeFiles/webcc.dir/soap_response.cc.o -c /home/adam/github/webcc/src/webcc/soap_response.cc",
|
||||
"file": "/home/adam/github/webcc/src/webcc/soap_response.cc"
|
||||
},
|
||||
{
|
||||
"directory": "/home/adam/github/webcc/build/src/webcc",
|
||||
"command": "/usr/bin/c++ -DBOOST_ASIO_NO_DEPRECATED -DWEBCC_ENABLE_LOG -DWEBCC_ENABLE_SOAP -I/home/adam/github/webcc/src -I/home/adam/github/webcc/third_party -std=c++11 -o CMakeFiles/webcc.dir/soap_xml.cc.o -c /home/adam/github/webcc/src/webcc/soap_xml.cc",
|
||||
"file": "/home/adam/github/webcc/src/webcc/soap_xml.cc"
|
||||
},
|
||||
{
|
||||
"directory": "/home/adam/github/webcc/build/src/webcc",
|
||||
"command": "/usr/bin/c++ -DBOOST_ASIO_NO_DEPRECATED -DWEBCC_ENABLE_LOG -DWEBCC_ENABLE_SOAP -I/home/adam/github/webcc/src -I/home/adam/github/webcc/third_party -std=c++11 -o CMakeFiles/webcc.dir/soap_server.cc.o -c /home/adam/github/webcc/src/webcc/soap_server.cc",
|
||||
"file": "/home/adam/github/webcc/src/webcc/soap_server.cc"
|
||||
},
|
||||
{
|
||||
"directory": "/home/adam/github/webcc/build/src/webcc",
|
||||
"command": "/usr/bin/c++ -DBOOST_ASIO_NO_DEPRECATED -DWEBCC_ENABLE_LOG -DWEBCC_ENABLE_SOAP -I/home/adam/github/webcc/src -I/home/adam/github/webcc/third_party -std=c++11 -o CMakeFiles/webcc.dir/soap_client.cc.o -c /home/adam/github/webcc/src/webcc/soap_client.cc",
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
#include "webcc/globals.h"
|
||||
|
||||
#include <utility> // for move()
|
||||
|
||||
namespace webcc {
|
||||
|
||||
// NOTE:
|
||||
|
||||
@@ -1,14 +1,9 @@
|
||||
#include "webcc/http_async_client.h"
|
||||
|
||||
#if WEBCC_DEBUG_OUTPUT
|
||||
#include <iostream>
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
#include "boost/asio.hpp"
|
||||
#else
|
||||
#include "boost/asio/connect.hpp"
|
||||
//#include "boost/asio/ip/tcp.hpp"
|
||||
#include "boost/asio/read.hpp"
|
||||
#include "boost/asio/write.hpp"
|
||||
#endif
|
||||
@@ -119,11 +114,6 @@ void HttpAsyncClient::HandleRead(boost::system::error_code ec,
|
||||
return;
|
||||
}
|
||||
|
||||
#if WEBCC_DEBUG_OUTPUT
|
||||
// NOTE: the content XML might not be well formated.
|
||||
std::cout.write(buffer_.data(), length);
|
||||
#endif
|
||||
|
||||
// Parse the response piece just read.
|
||||
// If the content has been fully received, next time flag "finished_"
|
||||
// will be set.
|
||||
@@ -158,12 +148,6 @@ void HttpAsyncClient::HandleRead(boost::system::error_code ec,
|
||||
// return error;
|
||||
//}
|
||||
//}
|
||||
|
||||
//#if WEBCC_DEBUG_OUTPUT
|
||||
// std::cout << std::endl;
|
||||
// std::cout << "--- RESPONSE (PARSED) ---" << std::endl;
|
||||
// std::cout << *response << std::endl;
|
||||
//#endif
|
||||
}
|
||||
|
||||
} // namespace webcc
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
#include "webcc/http_client.h"
|
||||
|
||||
#include "boost/date_time/posix_time/posix_time.hpp"
|
||||
#include "boost/lambda/bind.hpp"
|
||||
#include "boost/lambda/lambda.hpp"
|
||||
#include <string>
|
||||
|
||||
#include "boost/asio/connect.hpp"
|
||||
#include "boost/asio/read.hpp"
|
||||
#include "boost/asio/write.hpp"
|
||||
#include "boost/date_time/posix_time/posix_time.hpp"
|
||||
#include "boost/lambda/bind.hpp"
|
||||
#include "boost/lambda/lambda.hpp"
|
||||
|
||||
#include "webcc/logger.h"
|
||||
#include "webcc/http_request.h"
|
||||
@@ -26,10 +28,9 @@ static const int kReceiveMaxSeconds = 30;
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
HttpClient::HttpClient()
|
||||
: socket_(io_context_)
|
||||
, timeout_seconds_(kReceiveMaxSeconds)
|
||||
, deadline_timer_(io_context_) {
|
||||
|
||||
: socket_(io_context_),
|
||||
timeout_seconds_(kReceiveMaxSeconds),
|
||||
deadline_timer_(io_context_) {
|
||||
deadline_timer_.expires_at(boost::posix_time::pos_infin);
|
||||
|
||||
// Start the persistent actor that checks for deadline expiry.
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
|
||||
#include <cassert>
|
||||
#include <string>
|
||||
#include <utility> // for move()
|
||||
#include <vector>
|
||||
|
||||
#include "webcc/globals.h"
|
||||
|
||||
|
||||
@@ -8,12 +8,12 @@
|
||||
namespace webcc {
|
||||
|
||||
HttpParser::HttpParser(HttpMessage* message)
|
||||
: message_(message)
|
||||
, content_length_(kInvalidLength)
|
||||
, start_line_parsed_(false)
|
||||
, content_length_parsed_(false)
|
||||
, header_parsed_(false)
|
||||
, finished_(false) {
|
||||
: message_(message),
|
||||
content_length_(kInvalidLength),
|
||||
start_line_parsed_(false),
|
||||
content_length_parsed_(false),
|
||||
header_parsed_(false),
|
||||
finished_(false) {
|
||||
}
|
||||
|
||||
Error HttpParser::Parse(const char* data, std::size_t len) {
|
||||
|
||||
@@ -35,7 +35,6 @@ protected:
|
||||
|
||||
bool IsContentFull() const;
|
||||
|
||||
protected:
|
||||
// The result HTTP message.
|
||||
HttpMessage* message_;
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#define WEBCC_HTTP_REQUEST_H_
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "boost/asio/buffer.hpp" // for const_buffer
|
||||
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
#ifndef WEBCC_HTTP_REQUEST_PARSER_H_
|
||||
#define WEBCC_HTTP_REQUEST_PARSER_H_
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "webcc/http_parser.h"
|
||||
|
||||
namespace webcc {
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#define WEBCC_HTTP_RESPONSE_H_
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "boost/asio/buffer.hpp" // for const_buffer
|
||||
|
||||
|
||||
@@ -7,16 +7,15 @@
|
||||
namespace webcc {
|
||||
|
||||
HttpResponseParser::HttpResponseParser(HttpResponse* response)
|
||||
: HttpParser(response)
|
||||
, response_(response) {
|
||||
: HttpParser(response), response_(response) {
|
||||
}
|
||||
|
||||
Error HttpResponseParser::ParseStartLine(const std::string& line) {
|
||||
response_->set_start_line(line + "\r\n");
|
||||
|
||||
size_t off = 0;
|
||||
std::size_t off = 0;
|
||||
|
||||
size_t pos = line.find(' ');
|
||||
std::size_t pos = line.find(' ');
|
||||
if (pos == std::string::npos) {
|
||||
return kHttpStartLineError;
|
||||
}
|
||||
@@ -39,8 +38,6 @@ Error HttpResponseParser::ParseStartLine(const std::string& line) {
|
||||
return kHttpStartLineError;
|
||||
}
|
||||
|
||||
off = pos + 1; // Skip space.
|
||||
|
||||
if (response_->status() != HttpStatus::kOK) {
|
||||
return kHttpStatusError;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
#ifndef WEBCC_HTTP_RESPONSE_PARSER_H_
|
||||
#define WEBCC_HTTP_RESPONSE_PARSER_H_
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "webcc/http_parser.h"
|
||||
|
||||
namespace webcc {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "webcc/http_server.h"
|
||||
|
||||
#include <csignal>
|
||||
#include <utility>
|
||||
|
||||
#include "webcc/http_request_handler.h"
|
||||
#include "webcc/logger.h"
|
||||
@@ -12,13 +13,10 @@ using tcp = boost::asio::ip::tcp;
|
||||
namespace webcc {
|
||||
|
||||
HttpServer::HttpServer(unsigned short port, std::size_t workers)
|
||||
: signals_(io_context_)
|
||||
, workers_(workers) {
|
||||
|
||||
: signals_(io_context_) , workers_(workers) {
|
||||
// Register to handle the signals that indicate when the server should exit.
|
||||
// It is safe to register for the same signal multiple times in a program,
|
||||
// provided all registration for the specified signal is made through asio.
|
||||
// TODO: Verify if this works for Windows.
|
||||
signals_.add(SIGINT);
|
||||
signals_.add(SIGTERM);
|
||||
#if defined(SIGQUIT)
|
||||
@@ -32,7 +30,6 @@ HttpServer::HttpServer(unsigned short port, std::size_t workers)
|
||||
// For more details about SO_REUSEADDR, see:
|
||||
// https://msdn.microsoft.com/en-us/library/windows/desktop/ms740621(v=vs.85).aspx
|
||||
// http://www.andy-pearce.com/blog/posts/2013/Feb/so_reuseaddr-on-windows/
|
||||
// TODO: SO_EXCLUSIVEADDRUSE
|
||||
acceptor_.reset(new tcp::acceptor(io_context_,
|
||||
tcp::endpoint(tcp::v4(), port),
|
||||
true)); // reuse_addr
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "webcc/http_session.h"
|
||||
|
||||
#include <utility> // for move()
|
||||
#include <vector>
|
||||
|
||||
#include "boost/asio/write.hpp"
|
||||
@@ -12,9 +13,9 @@ namespace webcc {
|
||||
|
||||
HttpSession::HttpSession(boost::asio::ip::tcp::socket socket,
|
||||
HttpRequestHandler* handler)
|
||||
: socket_(std::move(socket))
|
||||
, request_handler_(handler)
|
||||
, request_parser_(&request_) {
|
||||
: socket_(std::move(socket)),
|
||||
request_handler_(handler),
|
||||
request_parser_(&request_) {
|
||||
}
|
||||
|
||||
void HttpSession::Start() {
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
#include <array>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
#include "boost/asio/ip/tcp.hpp" // for ip::tcp::socket
|
||||
|
||||
|
||||
+2
-1
@@ -4,7 +4,8 @@
|
||||
|
||||
#include <cassert>
|
||||
#include <cstdarg>
|
||||
#include <mutex>
|
||||
#include <mutex> // NOLINT
|
||||
#include <string>
|
||||
|
||||
#include "boost/thread.hpp" // For thread ID.
|
||||
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
#include "webcc/rest_request_handler.h"
|
||||
|
||||
#include <utility> // for move()
|
||||
#include <vector>
|
||||
|
||||
#include "webcc/logger.h"
|
||||
#include "webcc/url.h"
|
||||
|
||||
@@ -28,7 +31,6 @@ void RestRequestHandler::HandleSession(HttpSessionPtr session) {
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO: Only for GET?
|
||||
UrlQuery query;
|
||||
Url::SplitQuery(url.query(), &query);
|
||||
|
||||
@@ -39,7 +41,6 @@ void RestRequestHandler::HandleSession(HttpSessionPtr session) {
|
||||
session->request().content(),
|
||||
&content);
|
||||
if (!ok) {
|
||||
// TODO: Could be other than kBadRequest.
|
||||
session->SendResponse(HttpStatus::kBadRequest);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
|
||||
// HTTP server handling REST requests.
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "webcc/http_request_handler.h"
|
||||
#include "webcc/rest_service_manager.h"
|
||||
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
|
||||
// HTTP server handling REST requests.
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "webcc/http_server.h"
|
||||
#include "webcc/rest_request_handler.h"
|
||||
#include "webcc/rest_service.h"
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
// NOTE:
|
||||
// The design of RestListService and RestDetailService is very similar to
|
||||
// XxxListView and XxxDetailView in Django Rest Framework.
|
||||
// XxxListView and XxxDetailView in Python Django Rest Framework.
|
||||
// Deriving from them instead of RestService can simplify your own REST services
|
||||
// a lot. But if you find the filtered parameters cannot meet your needs, feel
|
||||
// free to derive from RestService directly.
|
||||
@@ -19,7 +19,7 @@ namespace webcc {
|
||||
|
||||
class UrlQuery;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
// Base class for your REST service.
|
||||
class RestService {
|
||||
@@ -40,7 +40,7 @@ class RestService {
|
||||
|
||||
typedef std::shared_ptr<RestService> RestServicePtr;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
class RestListService : public RestService {
|
||||
public:
|
||||
@@ -64,7 +64,7 @@ class RestListService : public RestService {
|
||||
}
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
class RestDetailService : public RestService {
|
||||
public:
|
||||
|
||||
@@ -23,10 +23,8 @@ bool RestServiceManager::AddService(RestServicePtr service,
|
||||
try {
|
||||
// Compile the regex.
|
||||
item.url_regex.assign(url, flags);
|
||||
|
||||
service_items_.push_back(std::move(item));
|
||||
return true;
|
||||
|
||||
} catch (std::regex_error& e) {
|
||||
LOG_ERRO("URL is not a valid regular expression: %s", e.what());
|
||||
return false;
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
#ifndef WEBCC_REST_SERVICE_MANAGER_H_
|
||||
#define WEBCC_REST_SERVICE_MANAGER_H_
|
||||
|
||||
#include <regex>
|
||||
#include <regex> // NOLINT
|
||||
#include <string>
|
||||
#include <utility> // for move()
|
||||
#include <vector>
|
||||
|
||||
#include "webcc/rest_service.h"
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "webcc/soap_client.h"
|
||||
|
||||
#include <cassert>
|
||||
#include <utility> // for move()
|
||||
|
||||
#include "webcc/http_client.h"
|
||||
#include "webcc/http_request.h"
|
||||
|
||||
@@ -18,17 +18,18 @@ void SoapMessage::ToXml(std::string* xml_string) {
|
||||
|
||||
pugi::xml_document xdoc;
|
||||
|
||||
// TODO:
|
||||
// TODO(Adam):
|
||||
// When save with format_default, declaration will be generated
|
||||
// automatically but without encoding.
|
||||
// pugi::xml_node xdecl = xdoc.prepend_child(pugi::node_declaration);
|
||||
// xdecl.append_attribute("version").set_value("1.0");
|
||||
|
||||
pugi::xml_node xroot = soap_xml::AddChild(xdoc, soapenv_ns_.name, "Envelope");
|
||||
pugi::xml_node xroot = soap_xml::AddChild(soapenv_ns_.name, "Envelope",
|
||||
&xdoc);
|
||||
|
||||
soap_xml::AddNSAttr(xroot, soapenv_ns_.name, soapenv_ns_.url);
|
||||
|
||||
pugi::xml_node xbody = soap_xml::AddChild(xroot, soapenv_ns_.name, "Body");
|
||||
pugi::xml_node xbody = soap_xml::AddChild(soapenv_ns_.name, "Body", &xroot);
|
||||
|
||||
ToXmlBody(xbody);
|
||||
|
||||
|
||||
@@ -24,11 +24,11 @@ const std::string& SoapRequest::GetParameter(const std::string& key) const {
|
||||
}
|
||||
|
||||
void SoapRequest::ToXmlBody(pugi::xml_node xbody) {
|
||||
pugi::xml_node xop = soap_xml::AddChild(xbody, service_ns_.name, operation_);
|
||||
pugi::xml_node xop = soap_xml::AddChild(service_ns_.name, operation_, &xbody);
|
||||
soap_xml::AddNSAttr(xop, service_ns_.name, service_ns_.url);
|
||||
|
||||
for (Parameter& p : parameters_) {
|
||||
pugi::xml_node xparam = soap_xml::AddChild(xop, service_ns_.name, p.key());
|
||||
pugi::xml_node xparam = soap_xml::AddChild(service_ns_.name, p.key(), &xop);
|
||||
xparam.text().set(p.value().c_str());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#ifndef WEBCC_SOAP_REQUEST_H_
|
||||
#define WEBCC_SOAP_REQUEST_H_
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "webcc/soap_message.h"
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
#include "webcc/soap_request_handler.h"
|
||||
|
||||
#include <utility> // for move()
|
||||
|
||||
#include "webcc/logger.h"
|
||||
#include "webcc/soap_request.h"
|
||||
#include "webcc/soap_response.h"
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#define WEBCC_SOAP_REQUEST_HANDLER_H_
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
|
||||
#include "webcc/http_request_handler.h"
|
||||
|
||||
|
||||
@@ -6,14 +6,12 @@
|
||||
namespace webcc {
|
||||
|
||||
void SoapResponse::ToXmlBody(pugi::xml_node xbody) {
|
||||
pugi::xml_node xop = soap_xml::AddChild(xbody,
|
||||
service_ns_.name,
|
||||
operation_ + "Response");
|
||||
pugi::xml_node xop = soap_xml::AddChild(service_ns_.name,
|
||||
operation_ + "Response", &xbody);
|
||||
soap_xml::AddNSAttr(xop, service_ns_.name, service_ns_.url);
|
||||
|
||||
pugi::xml_node xresult = soap_xml::AddChild(xop,
|
||||
service_ns_.name,
|
||||
result_name_);
|
||||
pugi::xml_node xresult = soap_xml::AddChild(service_ns_.name, result_name_,
|
||||
&xop);
|
||||
xresult.text().set(result_.c_str());
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
#ifndef WEBCC_SOAP_RESPONSE_H_
|
||||
#define WEBCC_SOAP_RESPONSE_H_
|
||||
|
||||
#include <string>
|
||||
#include <utility> // for move()
|
||||
|
||||
#include "webcc/soap_message.h"
|
||||
|
||||
namespace webcc {
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
|
||||
// HTTP server handling SOAP requests.
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "webcc/soap_request_handler.h"
|
||||
#include "webcc/http_server.h"
|
||||
|
||||
|
||||
@@ -38,17 +38,18 @@ std::string GetNameNoPrefix(const pugi::xml_node& xnode) {
|
||||
return name;
|
||||
}
|
||||
|
||||
pugi::xml_node AddChild(pugi::xml_node& xnode, const std::string& ns,
|
||||
const std::string& name) {
|
||||
return xnode.append_child((ns + ":" + name).c_str());
|
||||
pugi::xml_node AddChild(const std::string& ns, const std::string& name,
|
||||
pugi::xml_node* xnode) {
|
||||
return xnode->append_child((ns + ":" + name).c_str());
|
||||
}
|
||||
|
||||
pugi::xml_node GetChild(pugi::xml_node& xnode, const std::string& ns,
|
||||
pugi::xml_node GetChild(const pugi::xml_node& xnode, const std::string& ns,
|
||||
const std::string& name) {
|
||||
return xnode.child((ns + ":" + name).c_str());
|
||||
}
|
||||
|
||||
pugi::xml_node GetChildNoNS(pugi::xml_node& xnode, const std::string& name) {
|
||||
pugi::xml_node GetChildNoNS(const pugi::xml_node& xnode,
|
||||
const std::string& name) {
|
||||
pugi::xml_node xchild = xnode.first_child();
|
||||
while (xchild) {
|
||||
std::string child_name = xchild.name();
|
||||
@@ -80,7 +81,7 @@ void AddNSAttr(pugi::xml_node& xnode, const std::string& ns_name,
|
||||
AddAttr(xnode, "xmlns", ns_name, ns_url);
|
||||
}
|
||||
|
||||
std::string GetNSAttr(pugi::xml_node& xnode, const std::string& ns_name) {
|
||||
std::string GetNSAttr(const pugi::xml_node& xnode, const std::string& ns_name) {
|
||||
std::string attr_name = "xmlns:" + ns_name;
|
||||
return xnode.attribute(attr_name.c_str()).as_string();
|
||||
}
|
||||
|
||||
@@ -26,14 +26,15 @@ std::string GetNameNoPrefix(const pugi::xml_node& xnode);
|
||||
// Add a child with the given name which is prefixed by a namespace.
|
||||
// E.g., AppendChild(xnode, "soapenv", "Envelope") will append a child with
|
||||
// name "soapenv:Envelope".
|
||||
pugi::xml_node AddChild(pugi::xml_node& xnode, const std::string& ns,
|
||||
const std::string& name);
|
||||
pugi::xml_node AddChild(const std::string& ns, const std::string& name,
|
||||
pugi::xml_node* xnode);
|
||||
|
||||
pugi::xml_node GetChild(pugi::xml_node& xnode, const std::string& ns,
|
||||
pugi::xml_node GetChild(const pugi::xml_node& xnode, const std::string& ns,
|
||||
const std::string& name);
|
||||
|
||||
// TODO: Remove
|
||||
pugi::xml_node GetChildNoNS(pugi::xml_node& xnode, const std::string& name);
|
||||
pugi::xml_node GetChildNoNS(const pugi::xml_node& xnode,
|
||||
const std::string& name);
|
||||
|
||||
// Add an attribute with the given name which is prefixed by a namespace.
|
||||
void AddAttr(pugi::xml_node& xnode, const std::string& ns,
|
||||
@@ -50,7 +51,8 @@ void AddNSAttr(pugi::xml_node& xnode, const std::string& ns_name,
|
||||
// Get namespace attribute value.
|
||||
// E.g., if the given namespace name is "soapenv", the value of
|
||||
// attribute "xmlns:soapenv" will be returned.
|
||||
std::string GetNSAttr(pugi::xml_node& xnode, const std::string& ns_name);
|
||||
std::string GetNSAttr(const pugi::xml_node& xnode,
|
||||
const std::string& ns_name);
|
||||
|
||||
// An XML writer writing to a referenced string.
|
||||
// Example:
|
||||
|
||||
+5
-4
@@ -2,10 +2,11 @@
|
||||
|
||||
#include <algorithm>
|
||||
#include <sstream>
|
||||
#include <utility> // for move()
|
||||
|
||||
namespace webcc {
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// -----------------------------------------------------------------------------
|
||||
// Helper functions to decode URL string.
|
||||
|
||||
// Convert a hex character digit to a decimal character value.
|
||||
@@ -58,7 +59,7 @@ static bool Decode(const std::string& encoded, std::string* raw) {
|
||||
return true;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
UrlQuery::UrlQuery(const std::map<std::string, std::string>& map) {
|
||||
for (auto& pair : map) {
|
||||
@@ -116,7 +117,7 @@ UrlQuery::ConstIterator UrlQuery::Find(const std::string& key) const {
|
||||
[&key](const Parameter& p) { return p.key() == key; });
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
Url::Url(const std::string& str, bool decode) {
|
||||
if (!decode || str.find('%') == std::string::npos) {
|
||||
@@ -128,7 +129,7 @@ Url::Url(const std::string& str, bool decode) {
|
||||
if (Decode(str, &decoded)) {
|
||||
Init(decoded);
|
||||
} else {
|
||||
// TODO: Exception?
|
||||
// TODO(Adam): Exception?
|
||||
Init(str);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ namespace webcc {
|
||||
|
||||
// Print the resolved endpoints.
|
||||
// NOTE: Endpoint is one word, don't use "end point".
|
||||
void DumpEndpoints(tcp::resolver::results_type& endpoints) {
|
||||
void DumpEndpoints(const tcp::resolver::results_type& endpoints) {
|
||||
std::cout << "Endpoints: " << endpoints.size() << std::endl;
|
||||
|
||||
tcp::resolver::results_type::iterator it = endpoints.begin();
|
||||
|
||||
+2
-1
@@ -7,7 +7,8 @@ namespace webcc {
|
||||
|
||||
// Print the resolved endpoints.
|
||||
// NOTE: Endpoint is one word, don't use "end point".
|
||||
void DumpEndpoints(boost::asio::ip::tcp::resolver::results_type& endpoints);
|
||||
void DumpEndpoints(
|
||||
const boost::asio::ip::tcp::resolver::results_type& endpoints);
|
||||
|
||||
} // namespace webcc
|
||||
|
||||
|
||||
Reference in New Issue
Block a user