CPPSERV


Home Projects Jobs Clientele Contact

cppserv


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] Fix ChangeLog format, add error handling for getHeaderDate() in headers.cpp



From: Sergey Jukov <sergey@total-knowledge.com>

---
 ChangeLog           |    5 +++--
 headers/headers.cpp |   19 ++++++++++++-------
 2 files changed, 15 insertions(+), 9 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index a6d9bd1..3d8dda8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,7 +1,8 @@
 Sergey Jukov <sergey@total-knowledge.com>            Wed, 13 Sep 2006 16:20:00 -0800
 - Add testing getHeader() and getDateHeader() functionality for
-headers.cpp and headers.h. Add testHeaders.pl for testing date header parser.
-
+  headers.cpp and headers.h. Add testHeaders.pl for testing date header parser.
+  Add error handling in headers.cpp for getDateHeader().
+	
 Ilya A. Volynets-Evenbakh <ilya@total-knowledge.com> Fri, 13 Sep 2006 14:22:11 -0800
 - Fix few copyright headers
 
diff --git a/headers/headers.cpp b/headers/headers.cpp
index cf247e2..4ce4327 100644
--- a/headers/headers.cpp
+++ b/headers/headers.cpp
@@ -20,6 +20,7 @@
 #include "headers.h"
 #include <iostream>
 #include <sstream>
+#include <servlet/ServletException.h>
 
 void HeadersServlet::service(servlet::HttpServletRequest& req, servlet::HttpServletResponse& resp)
 {
@@ -39,13 +40,17 @@ void HeadersServlet::service(servlet::Ht
 	}
 	out<<"============\nProtocol="<<req.getProtocol()<<std::endl;
 	out << "\n==========\nHTTP Method = "+req.getMethod();
-	std:: string testHeaderName = "if-modified-since";
-	out << "\n" << testHeaderName+":"+req.getHeader(testHeaderName); 
-	long l = req.getDateHeader(testHeaderName);
-        std:: stringstream s;
-        s << l;
-	std:: string dateHeader = s.str();
-	out << "\n" << testHeaderName+" value = "+dateHeader; 
+	std::string testHeaderName = "if-modified-since";
+	out<<"\n"<<testHeaderName+":"+req.getHeader(testHeaderName); 
+	try {
+	        long l = req.getDateHeader(testHeaderName);
+		std::stringstream s;
+		s<<l;
+		std::string dateHeader = s.str();
+		out<<"\n"<<testHeaderName+" value = "+dateHeader; 
+	} catch (servlet::ServletException e) {
+	        out<<"\n"<<testHeaderName+" is not formatted correctly";
+	}
 	out<<"</PRE>";
 	renderFooter(out);
 }
-- 
1.4.2


Authoright © Total Knowledge: 2001-2008