CPPSERV


Home Projects Jobs Clientele Contact

cppserv


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

[PATCH] Code syncronization



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

---
 ChangeLog              |   14 ++++++++++++++
 headers/headers.cpp    |   13 ++++++++++++-
 headers/headers.h      |   11 ++++++++++-
 headers/testHeaders.pl |   40 ++++++++++++++++++++++++++++++++++++++++
 4 files changed, 76 insertions(+), 2 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 348d607..a2b1a35 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+Sergey Jukov <sergey@total-knowledge>                Tue, 13 Sep 2006 13:20:00 -0800 
+- Code syncronization
+	
+Sergey Jukov <sergey@total-knowledge>                Tue, 13 Sep 2006 13:00:00 -0800 
+- Add query string test functionality to headers/headers.cpp and headers/header.h.
+
+Sergey Jukov <sergey@total-knowledge>                Tue, 13 Sep 2006 11:00:00 -0800 
+- Fix copyright issue in headers/headers.cpp and headers/header.h.
+	
+Sergey Jukov <sergey@total-knowledge>                Tue, 13 Sep 2006 10:30:00 -0800 
+- Add getHeader() and getDateHeader() test functionality to
+headers.cpp. Add testHeader perl script.
+	
 Sergey Jukov <sergey@total-knowledge.com>            Mon, 4 Sep 2006 22:10:03 -0800
 - Add Utils servlet test scripts
 
@@ -5,6 +18,7 @@ Sergey Jukov <sergey@total-knowledge.com
 - changed ServletRequest to HttpServletRequest and ServletResponse to
   HttpServletresponse in service() function signiture.
 
+>>>>>>> baa6296b87cb9d760e7998650c3490248ab6c79e/ChangeLog
 Ilya A. Volynets-Evenbakh <ilya@total-knowledge.com> Fri, 7 Aug 2006 15:54:11 -0800
 - Add IndexServlet that lists all servlets in current context
 - Fix "make dist" (lots of header files didn't get in)
diff --git a/headers/headers.cpp b/headers/headers.cpp
index 5a4369f..6fb3002 100644
--- a/headers/headers.cpp
+++ b/headers/headers.cpp
@@ -1,5 +1,5 @@
 /***************************************************************************
- *   Copyright (C) 2004 by Ilya A. Volynets-Evenbakh                       *
+ *   Copyright (C) 2004-2006 by Ilya A. Volynets-Evenbakh                  *
  *   ilya@total-knowledge.com                                              *
  *                                                                         *
  *   This program is free software; you can redistribute it and/or modify  *
@@ -18,6 +18,8 @@
  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
  ***************************************************************************/
 #include "headers.h"
+#include <iostream>
+#include <sstream>
 
 void HeadersServlet::service(servlet::HttpServletRequest& req, servlet::HttpServletResponse& resp)
 {
@@ -36,6 +38,15 @@ void HeadersServlet::service(servlet::Ht
 		    out<<*it<<':'<<*vit<<std::endl;
 	}
 	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; 
+	out << "\nQuery String: "+req.getQueryString(); 
 	out<<"</PRE>";
 	renderFooter(out);
 }
diff --git a/headers/headers.h b/headers/headers.h
index 2d270d9..9a807cf 100644
--- a/headers/headers.h
+++ b/headers/headers.h
@@ -1,5 +1,5 @@
 /***************************************************************************
- *   Copyright (C) 2004 by Ilya A. Volynets-Evenbakh                       *
+ *   Copyright (C) 2004-2006 by Ilya A. Volynets-Evenbakh                  *
  *   ilya@total-knowledge.com                                              *
  *                                                                         *
  *   This program is free software; you can redistribute it and/or modify  *
@@ -30,6 +30,15 @@ This servlet demonstrates how to set res
 at request headers.
 It displays a page, with values of all request headers,
 and sends X-Test-Header: header. It also sets Pragma: no-cache
+It displays HTTP method with which this request was made, work of getHeader()
+which returns the value of specified request header(null if there was no such 
+header in HTTP request) and getDateHeader() which returns the number of 
+milliseconds since January 1, 1970 GMT, or -1 if the named header was not 
+included with the request. Throws IllegalArgumentException if the header value
+can't be converted to a date.
+Example provided for If-Modified-Since HTTP request header using testHeaders.pl
+It demonstrates work of getQueryString() function, if no query string provided,
+returns null.
 
 @author Ilya A. Volynets-Evenbakh
 */
diff --git a/headers/testHeaders.pl b/headers/testHeaders.pl
new file mode 100644
index 0000000..c5cf559
--- /dev/null
+++ b/headers/testHeaders.pl
@@ -0,0 +1,40 @@
+use LWP::UserAgent;
+$ua = LWP::UserAgent->new;
+
+my $req = HTTP::Request->new(POST => 'http://localhost/~sergey/csp/HeadersServlet');
+$req->content_type('application/x-www-form-urlencoded');
+$req->content('key=value');
+
+my $headerName = "If-Modified-Since";
+
+my @headerValues = (
+'Tue, 9 Sep 2006 12:45:26 GMT',
+'Mon, 33 Sep 06 12:00:00 GMT',
+''
+);
+
+
+
+foreach $headerValue (@headerValues)
+{
+
+    $req->header($headerName => $headerValue);
+
+    my $res = $ua->request($req);
+
+    if ($res->is_success) {
+
+	print $res->content."\n\n------------------------------------------------------\n\n\n";
+
+    }
+    else {
+	print $res->status_line, "\n";
+    }
+
+}
+
+
+
+
+
+
-- 
1.4.2


Authoright © Total Knowledge: 2001-2008