CPPSERV


Home Projects Jobs Clientele Contact
CPPSERV Documentation Download TODO Mailing lists Bug tracker News RSS Feed Browse source

ForwardedRequestWrapper.h

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 2006 by Ilya A. Volynets-Evenbakh                       *
00003  *   ilya@total-knowledge.com                                              *
00004  *                                                                         *
00005  *   This program is free software; you can redistribute it and/or modify  *
00006  *   it under the terms of the GNU General Public License as published by  *
00007  *   the Free Software Foundation; either version 2 of the License, or     *
00008  *   (at your option) any later version.                                   *
00009  *                                                                         *
00010  *   This program is distributed in the hope that it will be useful,       *
00011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00013  *   GNU General Public License for more details.                          *
00014  *                                                                         *
00015  *   You should have received a copy of the GNU General Public License     *
00016  *   along with this program; if not, write to the                         *
00017  *   Free Software Foundation, Inc.,                                       *
00018  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
00019  ***************************************************************************/
00020 #ifndef _FORWARDED_REQUEST_WRAPPER_H_
00021 #define _FORWARDED_REQUEST_WRAPPER_H_
00022 
00023 #include <servlet/HttpServletRequestWrapper.h>
00024 #include <sstream>
00025 #include <container/serverconfig/appcontext.h>
00026 
00027 namespace container
00028 {
00029 class ForwardedRequestWrapper:
00030     public servlet::HttpServletRequestWrapper
00031 {
00032 private:
00033     serverconfig::AppContext& m_context;
00034     std::string m_uri;
00035     std::string m_path;
00036 public:
00041     ForwardedRequestWrapper(servlet::HttpServletRequest* request,
00042                 serverconfig::AppContext& ctx,
00043                 const std::string& uri, const std::string& path)
00044         : servlet::HttpServletRequestWrapper(request)
00045         , m_context(ctx)
00046         , m_uri(uri)
00047         , m_path(path)
00048     {}
00049 
00050     virtual std::string getContextPath() {
00051     return m_context.getUriBase();
00052     }
00053 
00054     virtual std::string getRequestURI() {
00055     return m_uri;
00056     }
00057 
00058     virtual std::string getRequestURL() {
00059         std::stringstream url;
00060     url<<getScheme()<<"://"<<getServerName()<<':'<<getServerPort()<<getRequestURI();
00061     return url.str();
00062     }
00063 
00064     virtual std::string getServletPath() {
00065     return m_path;
00066     }
00067 };
00068 
00069 }
00070 #endif

SourceForge.net Logo