Unverified Commit e655d4a0 authored by Kip's avatar Kip Committed by GitHub

Merge pull request #873 from Tachi107/issue-187-fix

Fix #187
parents c3b6e014 270bbefe
...@@ -17,9 +17,8 @@ ...@@ -17,9 +17,8 @@
#endif #endif
using namespace Pistache; using namespace Pistache;
using namespace Pistache::Http;
class XProtocolVersion : public Header::Header { class XProtocolVersion : public Http::Header::Header {
public: public:
NAME("X-Protocol-Version"); NAME("X-Protocol-Version");
...@@ -68,5 +67,5 @@ private: ...@@ -68,5 +67,5 @@ private:
}; };
int main() { int main() {
Header::Registry::instance().registerHeader<XProtocolVersion>(); Http::Header::Registry::instance().registerHeader<XProtocolVersion>();
} }
...@@ -11,11 +11,10 @@ ...@@ -11,11 +11,10 @@
#include <pistache/net.h> #include <pistache/net.h>
using namespace Pistache; using namespace Pistache;
using namespace Pistache::Http;
int main(int argc, char *argv[]) { int main(int argc, char *argv[]) {
if (argc < 2) { if (argc < 2) {
std::cerr << "Usage: http_client page [count]" << std::endl; std::cerr << "Usage: http_client page [count]\n";
return 1; return 1;
} }
...@@ -60,12 +59,12 @@ int main(int argc, char *argv[]) { ...@@ -60,12 +59,12 @@ int main(int argc, char *argv[]) {
barrier.wait_for(std::chrono::seconds(5)); barrier.wait_for(std::chrono::seconds(5));
auto end = std::chrono::system_clock::now(); auto end = std::chrono::system_clock::now();
std::cout << "Summary of execution" << std::endl std::cout << "Summary of execution\n"
<< "Total number of requests sent : " << count << std::endl << "Total number of requests sent : " << count << '\n'
<< "Total number of responses received: " << "Total number of responses received: "
<< completedRequests.load() << std::endl << completedRequests.load() << '\n'
<< "Total number of requests failed : " << failedRequests.load() << "Total number of requests failed : " << failedRequests.load()
<< std::endl << '\n'
<< "Total time of execution : " << "Total time of execution : "
<< std::chrono::duration_cast<std::chrono::milliseconds>(end - << std::chrono::duration_cast<std::chrono::milliseconds>(end -
start) start)
......
...@@ -12,7 +12,6 @@ ...@@ -12,7 +12,6 @@
#include <pistache/endpoint.h> #include <pistache/endpoint.h>
#include <pistache/common.h> #include <pistache/common.h>
using namespace std;
using namespace Pistache; using namespace Pistache;
struct LoadMonitor { struct LoadMonitor {
...@@ -165,8 +164,8 @@ int main(int argc, char *argv[]) { ...@@ -165,8 +164,8 @@ int main(int argc, char *argv[]) {
Address addr(Ipv4::any(), port); Address addr(Ipv4::any(), port);
cout << "Cores = " << hardware_concurrency() << endl; std::cout << "Cores = " << hardware_concurrency() << std::endl;
cout << "Using " << thr << " threads" << endl; std::cout << "Using " << thr << " threads" << std::endl;
auto server = std::make_shared<Http::Endpoint>(addr); auto server = std::make_shared<Http::Endpoint>(addr);
......
...@@ -8,7 +8,7 @@ public: ...@@ -8,7 +8,7 @@ public:
HTTP_PROTOTYPE(HelloHandler) HTTP_PROTOTYPE(HelloHandler)
void onRequest(const Http::Request& request, Http::ResponseWriter response) override{ void onRequest(const Http::Request& request, Http::ResponseWriter response) override {
UNUSED(request); UNUSED(request);
response.send(Pistache::Http::Code::Ok, "Hello World\n"); response.send(Pistache::Http::Code::Ok, "Hello World\n");
} }
......
...@@ -10,7 +10,6 @@ ...@@ -10,7 +10,6 @@
#include <pistache/thirdparty/serializer/rapidjson.h> #include <pistache/thirdparty/serializer/rapidjson.h>
using namespace std;
using namespace Pistache; using namespace Pistache;
namespace Generic { namespace Generic {
...@@ -145,8 +144,8 @@ int main(int argc, char *argv[]) { ...@@ -145,8 +144,8 @@ int main(int argc, char *argv[]) {
Address addr(Ipv4::any(), port); Address addr(Ipv4::any(), port);
cout << "Cores = " << hardware_concurrency() << endl; std::cout << "Cores = " << hardware_concurrency() << std::endl;
cout << "Using " << thr << " threads" << endl; std::cout << "Using " << thr << " threads" << std::endl;
BankerService banker(addr); BankerService banker(addr);
......
...@@ -10,7 +10,6 @@ ...@@ -10,7 +10,6 @@
#include <pistache/router.h> #include <pistache/router.h>
#include <pistache/endpoint.h> #include <pistache/endpoint.h>
using namespace std;
using namespace Pistache; using namespace Pistache;
void printCookies(const Http::Request& req) { void printCookies(const Http::Request& req) {
...@@ -158,8 +157,8 @@ int main(int argc, char *argv[]) { ...@@ -158,8 +157,8 @@ int main(int argc, char *argv[]) {
Address addr(Ipv4::any(), port); Address addr(Ipv4::any(), port);
cout << "Cores = " << hardware_concurrency() << endl; std::cout << "Cores = " << hardware_concurrency() << std::endl;
cout << "Using " << thr << " threads" << endl; std::cout << "Using " << thr << " threads" << std::endl;
StatsEndpoint stats(addr); StatsEndpoint stats(addr);
......
...@@ -32,8 +32,8 @@ fetchOp ...@@ -32,8 +32,8 @@ fetchOp
[](const User& user) { return fetchUserInfo(user); }, [](const User& user) { return fetchUserInfo(user); },
Async::Throw) Async::Throw)
.then( .then(
[](const UserInfo& info) { std::cout << "User name = " << info.name << std::endl; }, [](const UserInfo& info) { std::cout << "User name = " << info.name << '\n'; },
[](exception_ptr ptr) { std::cout << "An exception occured during user retrieval" << std::endl;} [](exception_ptr ptr) { std::cerr << "An exception occured during user retrieval\n";}
); );
``` ```
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment