Skip to content

Commit

Permalink
Merge pull request yuwenyong#23 from yuwenyong/dev
Browse files Browse the repository at this point in the history
v3.3.3
  • Loading branch information
yuwenyong authored Feb 10, 2019
2 parents 676946b + bbc954c commit ada617a
Show file tree
Hide file tree
Showing 31 changed files with 599 additions and 292 deletions.
428 changes: 382 additions & 46 deletions README.md

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions example/helloworld/helloworld.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
using namespace net4cxx;


class HelloWorldApp: public AppBootstrapper {
class HelloWorldApp: public Bootstrapper {
public:
using AppBootstrapper::AppBootstrapper;
using Bootstrapper::Bootstrapper;

void onRun() override {
NET4CXX_LOG_INFO(gAppLog, "Hello world!");
Expand Down
4 changes: 2 additions & 2 deletions example/httpclient/httpclient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
using namespace net4cxx;


class HTTPClientApp: public AppBootstrapper {
class HTTPClientApp: public Bootstrapper {
public:
using AppBootstrapper::AppBootstrapper;
using Bootstrapper::Bootstrapper;

void onRun() {
auto request = HTTPRequest::create("https://www.baidu.com/")
Expand Down
4 changes: 2 additions & 2 deletions example/httpserver/httpserver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,9 @@ class Book: public RequestHandler {
}
};

class HTTPServerApp: public AppBootstrapper {
class HTTPServerApp: public Bootstrapper {
public:
using AppBootstrapper::AppBootstrapper;
using Bootstrapper::Bootstrapper;

void onRun() override {
auto webApp = makeWebApp<WebApp>({
Expand Down
4 changes: 2 additions & 2 deletions example/tcpclient/tcpclient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,9 @@ class MyFactory: public ClientFactory {
//};


class TCPClientApp: public AppBootstrapper {
class TCPClientApp: public Bootstrapper {
public:
using AppBootstrapper::AppBootstrapper;
using Bootstrapper::Bootstrapper;

void onRun() override {
// reactor()->connectTCP("localhost", "28001", std::make_shared<MyFactory>());
Expand Down
4 changes: 2 additions & 2 deletions example/tcpserver/tcpserver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ class MyFactory: public Factory {
};


class TCPServerApp: public AppBootstrapper {
class TCPServerApp: public Bootstrapper {
public:
using AppBootstrapper::AppBootstrapper;
using Bootstrapper::Bootstrapper;

void onRun() override {
// TCPServerEndpoint endpoint(reactor(), "28001");
Expand Down
4 changes: 2 additions & 2 deletions example/udpclient/udpclient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ class MyProtocol: public DatagramProtocol, public std::enable_shared_from_this<M
};


class UDPClientApp: public AppBootstrapper {
class UDPClientApp: public Bootstrapper {
public:
using AppBootstrapper::AppBootstrapper;
using Bootstrapper::Bootstrapper;

void onRun() override {
reactor()->connectUDP("127.0.0.1", 28002, std::make_shared<MyProtocol>());
Expand Down
4 changes: 2 additions & 2 deletions example/udpserver/udpserver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ class MyProtocol: public DatagramProtocol, public std::enable_shared_from_this<M
};


class UDPServerApp: public AppBootstrapper {
class UDPServerApp: public Bootstrapper {
public:
using AppBootstrapper::AppBootstrapper;
using Bootstrapper::Bootstrapper;

void onRun() override {
auto conn = reactor()->listenUDP(28002, std::make_shared<MyProtocol>());
Expand Down
4 changes: 2 additions & 2 deletions example/websocketclient/websocketclient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ class BroadcastClientFactory: public WebSocketClientFactory {
};


class WebSocketClientApp: public AppBootstrapper {
class WebSocketClientApp: public Bootstrapper {
public:
using AppBootstrapper::AppBootstrapper;
using Bootstrapper::Bootstrapper;

void onRun() override {
auto factory = std::make_shared<BroadcastClientFactory>("ws://127.0.0.1:9000");
Expand Down
4 changes: 2 additions & 2 deletions example/websocketserver/websocketserver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,9 @@ ProtocolPtr BroadcastServerFactory::buildProtocol(const Address &address) {
}


class WebSocketServerApp: public AppBootstrapper {
class WebSocketServerApp: public Bootstrapper {
public:
using AppBootstrapper::AppBootstrapper;
using Bootstrapper::Bootstrapper;

void onRun() override {
auto factory = std::make_shared<BroadcastServerFactory>("ws://127.0.0.1:9000");
Expand Down
10 changes: 4 additions & 6 deletions src/net4cxx/common/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,13 @@
#define BOOST_ENABLE_ASSERT_DEBUG_HANDLER
#define BOOST_ALL_DYN_LINK

#ifdef NET4CXX_DEBUG
# if PLATFORM != PLATFORM_APPLE
#if PLATFORM != PLATFORM_APPLE
# ifdef NET4CXX_DEBUG
# define BOOST_STACKTRACE_USE_BACKTRACE
# else
# define BOOST_STACKTRACE_USE_NOOP
# endif
#else
# define BOOST_STACKTRACE_USE_NOOP
#endif

#if PLATFORM == PLATFORM_APPLE
# define BOOST_STACKTRACE_LINK
#endif

Expand Down
2 changes: 1 addition & 1 deletion src/net4cxx/common/define.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ NS_END
#endif


#define NET4CXX_VERSION "3.3.2"
#define NET4CXX_VERSION "3.3.3"
#define NET4CXX_VER "net4cxx/" NET4CXX_VERSION


Expand Down
120 changes: 0 additions & 120 deletions src/net4cxx/common/email/utils.cpp

This file was deleted.

33 changes: 0 additions & 33 deletions src/net4cxx/common/email/utils.h

This file was deleted.

7 changes: 7 additions & 0 deletions src/net4cxx/common/threading/taskpool.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,13 @@ class NET4CXX_COMMON_API TaskPool {
std::vector<std::thread> _threads;
};


template <typename ValueT>
bool isReady(const std::future<ValueT> &fut) {
return fut.wait_for(std::chrono::milliseconds::zero()) == std::future_status::ready;
}


NS_END

#endif //NET4CXX_COMMON_THREADING_TASKPOOL_H
8 changes: 8 additions & 0 deletions src/net4cxx/core/network/reactor.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,14 @@ class NET4CXX_COMMON_API Reactor {
}
}

size_t getSubReactorCount() const {
return _reactorPool.size();
}

Reactor* getSubReactor(size_t index) {
return index < _reactorPool.size() ? &_reactorPool[index] : nullptr;
}

static Reactor *current() {
return _current;
}
Expand Down
1 change: 1 addition & 0 deletions src/net4cxx/net4cxx.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,6 @@
#include "net4cxx/plugins/websocket/websocket.h"

#include "net4cxx/shared/bootstrap/bootstrapper.h"
#include "net4cxx/shared/bootstrap/reactorthread.h"

#endif //NET4CXX_NET4CXX_H
22 changes: 9 additions & 13 deletions src/net4cxx/plugins/web/httputil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
//

#include "net4cxx/plugins/web/httputil.h"
#include "net4cxx/common/email/utils.h"
#include "net4cxx/common/httputils/cookie.h"
#include "net4cxx/shared/global/loggers.h"

Expand Down Expand Up @@ -352,26 +351,23 @@ std::tuple<std::string, StringMap> HTTPUtil::parseHeader(const std::string &line
StringVector parts = parseParam(";" + line);
std::string key = std::move(parts[0]);
parts.erase(parts.begin());
QueryArgList params{{"Dummy", "value"}};
StringMap pdict;
size_t i;
std::string name, value;
for (auto &p: parts) {
i = p.find('=');
if (i != std::string::npos) {
name = boost::to_lower_copy(boost::trim_copy(p.substr(0, i)));
value = boost::trim_copy(p.substr(i + 1));
params.emplace_back(std::move(name), std::move(value));
}
}
params = EMailUtils::decodeParams(std::move(params));
params.erase(params.begin());
StringMap pdict;
for (auto &kv: params) {
value = EMailUtils::collapseRFC2231Value(kv.second);
if (value.size() >= 2 && value.front() == '\"' && value.back() == '\"') {
value = value.substr(1, value.size() - 2);
if (value.size() >= 2 && value.front() == '\"' && value.back() == '\"') {
value = value.substr(1, value.size() - 2);
boost::replace_all(value, "\\\\", "\\");
boost::replace_all(value, "\\\"", "\"");
}
pdict[std::move(name)] = std::move(value);
} else {
pdict[p] = "";
}
pdict[std::move(kv.first)] = std::move(value);
}
return std::make_tuple(std::move(key), std::move(pdict));
}
Expand Down
Loading

0 comments on commit ada617a

Please sign in to comment.