From b0546e1277c1e855384fe507d7c540ab6b602cd3 Mon Sep 17 00:00:00 2001 From: antao Date: Tue, 4 Sep 2018 11:19:12 +0800 Subject: [PATCH] Change some code --- examples/simple_example/TimeFilter.cpp | 8 ++++---- lib/src/FileUpload.cc | 2 +- lib/src/HttpServer.cc | 3 +-- lib/src/SharedLibManager.cc | 6 +++--- lib/src/Utilities.cc | 2 +- lib/src/WebSockectConnectionImpl.h | 2 +- 6 files changed, 11 insertions(+), 12 deletions(-) diff --git a/examples/simple_example/TimeFilter.cpp b/examples/simple_example/TimeFilter.cpp index 9f0ac345..7e964ef7 100755 --- a/examples/simple_example/TimeFilter.cpp +++ b/examples/simple_example/TimeFilter.cpp @@ -3,8 +3,6 @@ // #include "TimeFilter.h" -#include -#include #define VDate "visitDate" void TimeFilter::doFilter(const HttpRequestPtr& req, const FilterCallback &cb, @@ -26,8 +24,10 @@ void TimeFilter::doFilter(const HttpRequestPtr& req, } else { - auto res=std::shared_ptr(drogon::HttpResponse::newHttpResponse()); - res->setBody("Visit interval should be at least 10 seconds"); + Json::Value json; + json["result"]="error"; + json["message"]="Visit interval should be at least 10 seconds"; + auto res=HttpResponse::newHttpJsonResponse(json); cb(res); return; } diff --git a/lib/src/FileUpload.cc b/lib/src/FileUpload.cc index 5a201443..9a0f2d62 100755 --- a/lib/src/FileUpload.cc +++ b/lib/src/FileUpload.cc @@ -39,7 +39,7 @@ int FileUpload::parse(const HttpRequest &req) std::cout << "boundary[" << boundary << "]" << std::endl; std::string content = req.query(); std::string::size_type pos1, pos2; - pos1 = pos2 = 0; + pos1 = 0; pos2 = content.find(boundary); while (1) { diff --git a/lib/src/HttpServer.cc b/lib/src/HttpServer.cc index 2a94fca0..8b49100c 100755 --- a/lib/src/HttpServer.cc +++ b/lib/src/HttpServer.cc @@ -165,7 +165,7 @@ void HttpServer::onRequest(const TcpConnectionPtr& conn, const HttpRequestPtr& r response->setCloseConnection(_close); if(response->getContentTypeCode()getBody().length()>4096&& + response->getBody().length()>1024&& req->getHeader("Accept-Encoding").find("gzip")!=std::string::npos) { //use gzip @@ -195,7 +195,6 @@ void HttpServer::onRequest(const TcpConnectionPtr& conn, const HttpRequestPtr& r conn->shutdown(); } - }); diff --git a/lib/src/SharedLibManager.cc b/lib/src/SharedLibManager.cc index a961ffe2..6c72694d 100755 --- a/lib/src/SharedLibManager.cc +++ b/lib/src/SharedLibManager.cc @@ -104,9 +104,9 @@ void SharedLibManager::managerLibs() return; } - { - std::ofstream fout(lockFile); - } +// { +// std::ofstream fout(lockFile); +// } std::string cmd="drogon_ctl create view "; cmd.append(filename).append(" -o ").append(libPath); LOG_TRACE< ret; std::string::size_type pos1, pos2; - pos1 = pos2 = 0; + pos2 = 0; pos1 = str.find(separator); while (pos1 != std::string::npos) { diff --git a/lib/src/WebSockectConnectionImpl.h b/lib/src/WebSockectConnectionImpl.h index 60ea83d6..da923d7e 100644 --- a/lib/src/WebSockectConnectionImpl.h +++ b/lib/src/WebSockectConnectionImpl.h @@ -6,7 +6,7 @@ namespace drogon{ class WebSocketConnectionImpl:public WebSocketConnection { public: - WebSocketConnectionImpl(const trantor::TcpConnectionPtr &conn); + explicit WebSocketConnectionImpl(const trantor::TcpConnectionPtr &conn); virtual void send(const char *msg,uint64_t len) override; virtual void send(const std::string &msg) override;