[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[PATCH] Add attributes/ for request attributes test
From: Sergey Jukov <sergey@total-knowledge.com>
---
ChangeLog | 3 +++
Makefile.adon | 2 +-
attributes/Makefile.adon | 3 +++
attributes/attributes.cpp | 48 +++++++++++++++++++++++++++++++++++++++++++++
attributes/attributes.h | 45 ++++++++++++++++++++++++++++++++++++++++++
engine.xml | 1 +
6 files changed, 101 insertions(+), 1 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 3d8dda8..0b24474 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,6 @@
+Sergey Jukov <sergey@total-knowledge.com> Thu, 14 Sep 2006 14:20:00 -0800
+- Add attributes/ for testing work of request attributes
+
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.
diff --git a/Makefile.adon b/Makefile.adon
index 4dbcc31..b477c92 100644
--- a/Makefile.adon
+++ b/Makefile.adon
@@ -1,2 +1,2 @@
-ADON_SUBDIRS := csp-store hello utils fileupload redirect cookies session headers sharedata params BooksODBC database index
+ADON_SUBDIRS := csp-store hello attributes utils fileupload redirect cookies session headers sharedata params BooksODBC database index
EXTRA_DIST := README engine.xml
diff --git a/attributes/Makefile.adon b/attributes/Makefile.adon
new file mode 100644
index 0000000..5de684e
--- /dev/null
+++ b/attributes/Makefile.adon
@@ -0,0 +1,3 @@
+noinst_LTLIBRARIES := AttributesServlet
+AttributesServlet_SOURCES := attributes.cpp
+noinst_HEADERS := attributes.h
diff --git a/attributes/attributes.cpp b/attributes/attributes.cpp
new file mode 100644
index 0000000..e9946d5
--- /dev/null
+++ b/attributes/attributes.cpp
@@ -0,0 +1,48 @@
+/***************************************************************************
+ * 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 *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+#include "attributes.h"
+#include <iostream>
+#include <sstream>
+
+void AttributesServlet::service(servlet::HttpServletRequest& req, servlet::HttpServletResponse& resp)
+{
+ std::ostream &out = resp.getOutputStream();
+ renderHeader(out);
+ out<<"<PRE>";
+ out<<"\nRequest URI: "+req.getRequestURI();
+ out<<"\nRequest URL: "+req.getRequestURL();
+ out<<"\nContext Path: "+req.getContextPath();
+ out<<"\nServletPath: "+req.getServletPath();
+ out<<"\nQuery String: "+req.getQueryString();
+ out<<"</PRE>";
+ renderFooter(out);
+}
+
+void AttributesServlet::renderHeader(std::ostream& out)
+{
+ out<<"<html>\n <head>\n <title>Sample Headers Servlet for CPPSERV</title>\n </head>\n <body>";
+}
+
+void AttributesServlet::renderFooter(std::ostream& out)
+{
+ out<<"\n </body>\n</html>";
+}
+
+EXPORT_SERVLET(AttributesServlet)
diff --git a/attributes/attributes.h b/attributes/attributes.h
new file mode 100644
index 0000000..9189689
--- /dev/null
+++ b/attributes/attributes.h
@@ -0,0 +1,45 @@
+/***************************************************************************
+ * 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 *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+#ifndef TESTSERVLET2_H
+#define TESTSERVLET2_H
+
+#include <servlet/HttpServlet.h>
+#include <servlet/HttpServletRequest.h>
+#include <servlet/HttpServletResponse.h>
+#include <iostream>
+
+/**
+This servlet demonstrates work of getRequestURI(), getRequestURL(),
+getContextPath() and getServletPath() functions.
+It returns the query string that is contained in the request URL
+after the path. If no query string provided, returns null.
+
+@author Sergey Jukov
+*/
+class AttributesServlet : public servlet::HttpServlet
+{
+private:
+ void renderHeader(std::ostream&);
+ void renderFooter(std::ostream&);
+public:
+ virtual void service(servlet::HttpServletRequest& req, servlet::HttpServletResponse& resp);
+};
+
+#endif
diff --git a/engine.xml b/engine.xml
index 4dec2a8..5105f49 100644
--- a/engine.xml
+++ b/engine.xml
@@ -5,6 +5,7 @@
<app name="test">
<servlet name="IndexServlet" dso="./debug/index/IndexServlet.so"/>
<servlet name="HelloServlet" dso="./debug/hello/HelloServlet.so"/>
+ <servlet name="AttributesServlet" dso="./debug/attributes/AttributesServlet.so"/>
<servlet name="FileUploadServlet" dso="./debug/fileupload/FileUploadServlet.so"/>
<servlet name="RedirectServlet" dso="./debug/redirect/RedirectServlet.so"/>
<servlet name="CookiesServlet" dso="./debug/cookies/CookiesServlet.so"/>
--
1.4.2