summaryrefslogtreecommitdiff
path: root/rotord
diff options
context:
space:
mode:
authorComment <tim@gray.(none)>2013-02-14 00:10:51 +0000
committerComment <tim@gray.(none)>2013-02-14 00:10:51 +0000
commit9f746d958099458dc11afdf410fb0b24ee510cac (patch)
treea6fe326b796b31ba7ab28d257fe2daf8d47bcb72 /rotord
parenta16a35c3c0844984fc2886bd1f95ad9ddec3584b (diff)
URI segmentation
Diffstat (limited to 'rotord')
-rw-r--r--rotord/rotord.cpp21
-rw-r--r--rotord/rotord.h1
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;