diff options
| author | Comment <tim@gray.(none)> | 2013-02-14 00:10:51 +0000 |
|---|---|---|
| committer | Comment <tim@gray.(none)> | 2013-02-14 00:10:51 +0000 |
| commit | 9f746d958099458dc11afdf410fb0b24ee510cac (patch) | |
| tree | a6fe326b796b31ba7ab28d257fe2daf8d47bcb72 | |
| parent | a16a35c3c0844984fc2886bd1f95ad9ddec3584b (diff) | |
URI segmentation
| -rw-r--r-- | rotord/rotord.cpp | 21 | ||||
| -rw-r--r-- | rotord/rotord.h | 1 |
2 files changed, 19 insertions, 3 deletions
diff --git a/rotord/rotord.cpp b/rotord/rotord.cpp index ccb770b..965d290 100644 --- a/rotord/rotord.cpp +++ b/rotord/rotord.cpp @@ -14,7 +14,7 @@ void RotorRequestHandler::handleRequest(HTTPServerRequest& request,HTTPServerRes std::ostream& ostr = response.send(); ostr << "<html><head><title>RotorServer powered by " "POCO C++ Libraries</title>"; - ostr << "<meta http-equiv=\"refresh\" content=\"1\"></head>"; + ostr << "</head>"; ostr << "<body><p style=\"text-align: center; " "font-size: 48px;\">"; ostr << dt; @@ -27,8 +27,23 @@ RotorRequestHandlerFactory::RotorRequestHandlerFactory(const std::string& format HTTPRequestHandler* RotorRequestHandlerFactory::createRequestHandler(const HTTPServerRequest& request){ Application& app = Application::instance(); - app.logger().information("Request from "+ request.clientAddress().toString()+": "+request.getURI()); - if (request.getURI() == "/") + + Poco::URI theuri=Poco::URI(request.getURI()); + std::vector <std::string> segments; + theuri.getPathSegments(segments); + + std::ostringstream ostr; + ostr << segments.size(); + + std::string out; + for (uint i=0;i<segments.size();i++) { + out+=segments[i]; + out+=" "; + } + + app.logger().information("Request from "+ request.clientAddress().toString()+" "+ostr.str()+" segments: "+out); + + if (segments.size() == 0) return new RotorRequestHandler(_format); else return 0; diff --git a/rotord/rotord.h b/rotord/rotord.h index c5f632b..41c97d4 100644 --- a/rotord/rotord.h +++ b/rotord/rotord.h @@ -17,6 +17,7 @@ #include "Poco/Util/HelpFormatter.h" #include <iostream> +#include <sstream> #include "Poco/URI.h" using Poco::Net::ServerSocket; |
