myserver-commit
[Top][All Lists]
Advanced

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

[Myserver-commit] [2738] Refactoring on the Cgi class, buildCGIEnvironme


From: Giuseppe Scrivano
Subject: [Myserver-commit] [2738] Refactoring on the Cgi class, buildCGIEnvironmentString moved in the Env class
Date: Wed, 06 Aug 2008 15:55:22 +0000

Revision: 2738
          http://svn.sv.gnu.org/viewvc/?view=rev&root=myserver&revision=2738
Author:   gscrivano
Date:     2008-08-06 15:55:22 +0000 (Wed, 06 Aug 2008)

Log Message:
-----------
Refactoring on the Cgi class, buildCGIEnvironmentString moved in the Env class

Modified Paths:
--------------
    trunk/myserver/include/cgi.h
    trunk/myserver/myserver.dev
    trunk/myserver/src/Makefile.am
    trunk/myserver/src/cgi.cpp
    trunk/myserver/src/fastcgi.cpp
    trunk/myserver/src/isapi.cpp
    trunk/myserver/src/mscgi.cpp
    trunk/myserver/src/scgi.cpp

Added Paths:
-----------
    trunk/myserver/include/env.h
    trunk/myserver/src/env.cpp

Modified: trunk/myserver/include/cgi.h
===================================================================
--- trunk/myserver/include/cgi.h        2008-08-05 21:34:49 UTC (rev 2737)
+++ trunk/myserver/include/cgi.h        2008-08-06 15:55:22 UTC (rev 2738)
@@ -23,8 +23,6 @@
 #include "../include/http_headers.h"
 #include "../include/http_data_handler.h"
 
-extern const char *versionOfSoftware;
-
 class Cgi : public HttpDataHandler
 {
   static int cgiTimeout;
@@ -34,7 +32,6 @@
        virtual int send(HttpThreadContext*, ConnectionPtr s,
                    const char* scriptpath, const char* exec = 0,
                    int execute = 0, int onlyHeader = 0);
-       static void buildCGIEnvironmentString(HttpThreadContext*, char*, int=1);
 };
 #endif
 

Added: trunk/myserver/include/env.h
===================================================================
--- trunk/myserver/include/env.h                                (rev 0)
+++ trunk/myserver/include/env.h        2008-08-06 15:55:22 UTC (rev 2738)
@@ -0,0 +1,34 @@
+/*
+MyServer
+Copyright (C) 2002, 2003, 2004, 2008 Free Software Foundation, Inc.
+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 3 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, see <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef ENV_H
+#define ENV_H
+
+#include "../include/http_response.h"
+#include "../include/http_request.h"
+#include "../include/http_headers.h"
+#include "../include/http_data_handler.h"
+
+extern const char *versionOfSoftware;
+
+class Env
+{
+public:
+       static void buildEnvironmentString(HttpThreadContext*, char*, int = 1);
+};
+
+#endif

Modified: trunk/myserver/myserver.dev
===================================================================
--- trunk/myserver/myserver.dev 2008-08-05 21:34:49 UTC (rev 2737)
+++ trunk/myserver/myserver.dev 2008-08-06 15:55:22 UTC (rev 2738)
@@ -1,7 +1,7 @@
 [Project]
 FileName=myserver.dev
 Name=myserver
-UnitCount=94
+UnitCount=95
 Type=1
 Ver=1
 ObjFiles=
@@ -347,6 +347,16 @@
 BuildCmd=
 
 [Unit31]
+FileName=src\env.cpp
+CompileCpp=1
+Folder=myserver
+Compile=1
+Link=1
+Priority=1000
+OverrideBuildCmd=0
+BuildCmd=
+
+[Unit32]
 FileName=src\securestr.cpp
 CompileCpp=1
 Folder=myserver
@@ -356,7 +366,7 @@
 OverrideBuildCmd=0
 BuildCmd=
 
-[Unit32]
+[Unit33]
 FileName=src\cgi.cpp
 CompileCpp=1
 Folder=myserver
@@ -366,7 +376,7 @@
 OverrideBuildCmd=0
 BuildCmd=
 
-[Unit33]
+[Unit34]
 FileName=src\gzip.cpp
 CompileCpp=1
 Folder=myserver
@@ -376,7 +386,7 @@
 OverrideBuildCmd=0
 BuildCmd=
 
-[Unit34]
+[Unit35]
 FileName=src\cached_file_buffer.cpp
 CompileCpp=1
 Folder=myserver
@@ -386,7 +396,7 @@
 OverrideBuildCmd=0
 BuildCmd=
 
-[Unit35]
+[Unit36]
 FileName=src\plugins_namespace_manager.cpp
 CompileCpp=1
 Folder=myserver
@@ -396,7 +406,7 @@
 OverrideBuildCmd=0
 BuildCmd=
 
-[Unit36]
+[Unit37]
 FileName=src\mime_manager.cpp
 CompileCpp=1
 Folder=myserver
@@ -406,7 +416,7 @@
 OverrideBuildCmd=0
 BuildCmd=
 
-[Unit37]
+[Unit38]
 FileName=src\mscgi.cpp
 CompileCpp=1
 Folder=myserver
@@ -416,7 +426,7 @@
 OverrideBuildCmd=0
 BuildCmd=
 
-[Unit38]
+[Unit39]
 FileName=src\dynamic_protocol.cpp
 CompileCpp=1
 Folder=myserver
@@ -426,7 +436,7 @@
 OverrideBuildCmd=0
 BuildCmd=
 
-[Unit39]
+[Unit40]
 FileName=src\process.cpp
 CompileCpp=1
 Folder=myserver
@@ -436,7 +446,7 @@
 OverrideBuildCmd=0
 BuildCmd=
 
-[Unit40]
+[Unit41]
 FileName=src\protocol.cpp
 CompileCpp=1
 Folder=myserver
@@ -446,7 +456,7 @@
 OverrideBuildCmd=0
 BuildCmd=
 
-[Unit41]
+[Unit42]
 FileName=src\files_utility.cpp
 CompileCpp=1
 Folder=myserver
@@ -456,7 +466,7 @@
 OverrideBuildCmd=0
 BuildCmd=
 
-[Unit42]
+[Unit43]
 FileName=src\ssl.cpp
 CompileCpp=1
 Folder=myserver
@@ -466,7 +476,7 @@
 OverrideBuildCmd=0
 BuildCmd=
 
-[Unit43]
+[Unit44]
 FileName=src\fastcgi.cpp
 CompileCpp=1
 Folder=myserver
@@ -476,7 +486,7 @@
 OverrideBuildCmd=0
 BuildCmd=
 
-[Unit44]
+[Unit45]
 FileName=src\wincgi.cpp
 CompileCpp=1
 Folder=myserver
@@ -486,7 +496,7 @@
 OverrideBuildCmd=0
 BuildCmd=
 
-[Unit45]
+[Unit46]
 FileName=src\plugins_namespace.cpp
 CompileCpp=1
 Folder=myserver
@@ -496,7 +506,7 @@
 OverrideBuildCmd=0
 BuildCmd=
 
-[Unit46]
+[Unit47]
 FileName=src\clients_thread.cpp
 CompileCpp=1
 Folder=myserver
@@ -506,7 +516,7 @@
 OverrideBuildCmd=0
 BuildCmd=
 
-[Unit47]
+[Unit48]
 FileName=src\vhost.cpp
 CompileCpp=1
 Folder=myserver
@@ -516,7 +526,7 @@
 OverrideBuildCmd=0
 BuildCmd=
 
-[Unit48]
+[Unit49]
 FileName=src\http_response.cpp
 CompileCpp=1
 Folder=myserver
@@ -526,7 +536,7 @@
 OverrideBuildCmd=0
 BuildCmd=
 
-[Unit49]
+[Unit50]
 FileName=src\protocol_buffer.cpp
 CompileCpp=1
 Folder=myserver
@@ -536,7 +546,7 @@
 OverrideBuildCmd=0
 BuildCmd=
 
-[Unit50]
+[Unit51]
 FileName=src\stream.cpp
 CompileCpp=1
 Folder=myserver
@@ -546,7 +556,7 @@
 OverrideBuildCmd=0
 BuildCmd=
 
-[Unit51]
+[Unit52]
 FileName=src\home_dir.cpp
 CompileCpp=1
 Folder=myserver
@@ -556,7 +566,7 @@
 OverrideBuildCmd=0
 BuildCmd=
 
-[Unit52]
+[Unit53]
 FileName=src\ftp.cpp
 CompileCpp=1
 Folder=myserver
@@ -566,7 +576,7 @@
 OverrideBuildCmd=0
 BuildCmd=
 
-[Unit53]
+[Unit54]
 FileName=src\http_data_read.cpp
 CompileCpp=1
 Folder=myserver
@@ -576,7 +586,7 @@
 OverrideBuildCmd=0
 BuildCmd=
 
-[Unit54]
+[Unit55]
 FileName=src\connection.cpp
 CompileCpp=1
 Folder=myserver
@@ -586,7 +596,7 @@
 OverrideBuildCmd=0
 BuildCmd=
 
-[Unit55]
+[Unit56]
 FileName=src\scgi.cpp
 CompileCpp=1
 Folder=myserver
@@ -596,7 +606,7 @@
 OverrideBuildCmd=0
 BuildCmd=
 
-[Unit56]
+[Unit57]
 FileName=src\http.cpp
 CompileCpp=1
 Folder=myserver
@@ -606,7 +616,7 @@
 OverrideBuildCmd=0
 BuildCmd=
 
-[Unit57]
+[Unit58]
 FileName=src\http_headers.cpp
 CompileCpp=1
 Folder=myserver
@@ -616,7 +626,7 @@
 OverrideBuildCmd=0
 BuildCmd=
 
-[Unit58]
+[Unit59]
 FileName=src\dyn_filter_file.cpp
 CompileCpp=1
 Folder=myserver
@@ -626,7 +636,7 @@
 OverrideBuildCmd=0
 BuildCmd=
 
-[Unit59]
+[Unit60]
 FileName=src\https.cpp
 CompileCpp=1
 Folder=myserver
@@ -636,7 +646,7 @@
 OverrideBuildCmd=0
 BuildCmd=
 
-[Unit60]
+[Unit61]
 FileName=src\security_cache.cpp
 CompileCpp=1
 Folder=myserver
@@ -646,7 +656,7 @@
 OverrideBuildCmd=0
 BuildCmd=
 
-[Unit61]
+[Unit62]
 FileName=src\find_data.cpp
 CompileCpp=1
 Folder=myserver
@@ -656,7 +666,7 @@
 OverrideBuildCmd=0
 BuildCmd=
 
-[Unit62]
+[Unit63]
 FileName=src\http_dir.cpp
 CompileCpp=1
 Folder=myserver
@@ -666,7 +676,7 @@
 OverrideBuildCmd=0
 BuildCmd=
 
-[Unit63]
+[Unit64]
 FileName=src\mime_utils.cpp
 CompileCpp=1
 Folder=myserver
@@ -676,7 +686,7 @@
 OverrideBuildCmd=0
 BuildCmd=
 
-[Unit64]
+[Unit65]
 FileName=src\control_header.cpp
 CompileCpp=1
 Folder=myserver
@@ -686,7 +696,7 @@
 OverrideBuildCmd=0
 BuildCmd=
 
-[Unit65]
+[Unit66]
 FileName=src\dyn_filters_manager.cpp
 CompileCpp=1
 Folder=myserver
@@ -696,7 +706,7 @@
 OverrideBuildCmd=0
 BuildCmd=
 
-[Unit66]
+[Unit67]
 FileName=src\security.cpp
 CompileCpp=1
 Folder=myserver
@@ -706,7 +716,7 @@
 OverrideBuildCmd=0
 BuildCmd=
 
-[Unit67]
+[Unit68]
 FileName=src\http_thread_context.cpp
 CompileCpp=1
 Folder=myserver
@@ -716,7 +726,7 @@
 OverrideBuildCmd=0
 BuildCmd=
 
-[Unit68]
+[Unit69]
 FileName=src\http_header_checker.cpp
 CompileCpp=1
 Folder=myserver
@@ -726,7 +736,7 @@
 OverrideBuildCmd=0
 BuildCmd=
 
-[Unit69]
+[Unit70]
 FileName=src\event.cpp
 CompileCpp=1
 Folder=myserver
@@ -736,7 +746,7 @@
 OverrideBuildCmd=0
 BuildCmd=
 
-[Unit70]
+[Unit71]
 FileName=src\xml_parser.cpp
 CompileCpp=1
 Folder=myserver
@@ -746,7 +756,7 @@
 OverrideBuildCmd=0
 BuildCmd=
 
-[Unit71]
+[Unit72]
 FileName=src\utility.cpp
 CompileCpp=1
 Folder=myserver
@@ -756,7 +766,7 @@
 OverrideBuildCmd=0
 BuildCmd=
 
-[Unit72]
+[Unit73]
 FileName=src\multicast.cpp
 CompileCpp=1
 Folder=myserver
@@ -766,7 +776,7 @@
 OverrideBuildCmd=0
 BuildCmd=
 
-[Unit73]
+[Unit74]
 FileName=src\plugin.cpp
 CompileCpp=1
 Folder=myserver
@@ -776,7 +786,7 @@
 OverrideBuildCmd=0
 BuildCmd=
 
-[Unit74]
+[Unit75]
 FileName=src\mscgi_manager.cpp
 CompileCpp=1
 Folder=myserver
@@ -786,7 +796,7 @@
 OverrideBuildCmd=0
 BuildCmd=
 
-[Unit75]
+[Unit76]
 FileName=src\read_write_lock.cpp
 CompileCpp=1
 Folder=myserver
@@ -796,7 +806,7 @@
 OverrideBuildCmd=0
 BuildCmd=
 
-[Unit76]
+[Unit77]
 FileName=src\server.cpp
 CompileCpp=1
 Folder=myserver
@@ -806,7 +816,7 @@
 OverrideBuildCmd=0
 BuildCmd=
 
-[Unit77]
+[Unit78]
 FileName=src\dynamic_executor.cpp
 CompileCpp=1
 Folder=myserver
@@ -816,7 +826,7 @@
 OverrideBuildCmd=0
 BuildCmd=
 
-[Unit78]
+[Unit79]
 FileName=src\connections_scheduler.cpp
 CompileCpp=1
 Folder=myserver
@@ -826,7 +836,7 @@
 OverrideBuildCmd=0
 BuildCmd=
 
-[Unit79]
+[Unit80]
 FileName=src\cached_file.cpp
 CompileCpp=1
 Folder=myserver
@@ -836,7 +846,7 @@
 OverrideBuildCmd=0
 BuildCmd=
 
-[Unit80]
+[Unit81]
 FileName=src\http_request.cpp
 CompileCpp=1
 Folder=myserver
@@ -846,7 +856,7 @@
 OverrideBuildCmd=0
 BuildCmd=
 
-[Unit81]
+[Unit82]
 FileName=src\filters_factory.cpp
 CompileCpp=1
 Folder=myserver
@@ -856,7 +866,7 @@
 OverrideBuildCmd=0
 BuildCmd=
 
-[Unit82]
+[Unit83]
 FileName=src\ssl_socket.cpp
 CompileCpp=1
 Folder=myserver
@@ -866,7 +876,7 @@
 OverrideBuildCmd=0
 BuildCmd=
 
-[Unit83]
+[Unit84]
 FileName=src\file.cpp
 CompileCpp=1
 Folder=myserver
@@ -876,7 +886,7 @@
 OverrideBuildCmd=0
 BuildCmd=
 
-[Unit84]
+[Unit85]
 FileName=src\control_protocol.cpp
 CompileCpp=1
 Folder=myserver
@@ -886,7 +896,7 @@
 OverrideBuildCmd=0
 BuildCmd=
 
-[Unit85]
+[Unit86]
 FileName=src\myserver.cpp
 CompileCpp=1
 Folder=myserver
@@ -896,7 +906,7 @@
 OverrideBuildCmd=0
 BuildCmd=
 
-[Unit86]
+[Unit87]
 FileName=src\vhost_manager.cpp
 CompileCpp=1
 Folder=myserver
@@ -906,7 +916,7 @@
 OverrideBuildCmd=0
 BuildCmd=
 
-[Unit87]
+[Unit88]
 FileName=src\http_file.cpp
 CompileCpp=1
 Folder=myserver
@@ -916,7 +926,7 @@
 OverrideBuildCmd=0
 BuildCmd=
 
-[Unit88]
+[Unit89]
 FileName=src\safetime.cpp
 CompileCpp=1
 Folder=myserver
@@ -926,7 +936,7 @@
 OverrideBuildCmd=0
 BuildCmd=
 
-[Unit89]
+[Unit90]
 FileName=src\listen_threads.cpp
 CompileCpp=1
 Folder=myserver
@@ -936,7 +946,7 @@
 OverrideBuildCmd=0
 BuildCmd=
 
-[Unit90]
+[Unit91]
 FileName=src\hash_map.cpp
 CompileCpp=1
 Folder=myserver
@@ -946,7 +956,7 @@
 OverrideBuildCmd=0
 BuildCmd=
 
-[Unit91]
+[Unit92]
 FileName=src\Dev-C++.cpp
 CompileCpp=1
 Folder=myserver
@@ -956,7 +966,7 @@
 OverrideBuildCmd=0
 BuildCmd=
 
-[Unit92]
+[Unit93]
 FileName=src\dyn_http_manager.cpp
 CompileCpp=1
 Folder=myserver
@@ -966,7 +976,7 @@
 OverrideBuildCmd=0
 BuildCmd=
 
-[Unit93]
+[Unit94]
 FileName=src\protocols_manager.cpp
 CompileCpp=1
 Folder=myserver
@@ -976,7 +986,7 @@
 OverrideBuildCmd=0
 BuildCmd=
 
-[Unit94]
+[Unit95]
 FileName=src\plugins_manager.cpp
 CompileCpp=1
 Folder=myserver

Modified: trunk/myserver/src/Makefile.am
===================================================================
--- trunk/myserver/src/Makefile.am      2008-08-05 21:34:49 UTC (rev 2737)
+++ trunk/myserver/src/Makefile.am      2008-08-06 15:55:22 UTC (rev 2738)
@@ -3,7 +3,7 @@
 #BUILT_SOURCES = ../include/ftp_lexer.h ../include/ftp_parser.h
 #AM_YFLAGS = --defines=../include/ftp_parser.h
 bin_PROGRAMS = myserver
-myserver_SOURCES = cached_file_buffer.cpp cached_file.cpp 
cached_file_factory.cpp cgi.cpp clients_thread.cpp connection.cpp 
connections_scheduler.cpp control_header.cpp control_protocol.cpp Dev-C++.cpp 
dynamic_executor.cpp dynamiclib.cpp dynamic_protocol.cpp 
dyn_executor_manager.cpp dyn_filter.cpp dyn_filter_file.cpp 
dyn_filters_manager.cpp dyn_http_command.cpp dyn_http_command_manager.cpp 
dyn_http_manager.cpp dyn_http_manager_list.cpp event.cpp fastcgi.cpp file.cpp 
files_utility.cpp filter.cpp filters_chain.cpp filters_factory.cpp 
generic_plugins_manager.cpp gzip.cpp gzip_decompress.cpp hash_map.cpp 
home_dir.cpp http.cpp http_data_handler.cpp http_data_read.cpp http_dir.cpp 
http_errors.cpp http_file.cpp http_header_checker.cpp http_headers.cpp 
http_request.cpp http_response.cpp https.cpp http_thread_context.cpp isapi.cpp 
find_data.cpp listen_threads.cpp log_manager.cpp md5.cpp mem_buff.cpp 
memory_stream.cpp mime_manager.cpp mime_utils.cpp mscgi_manager.cpp mscgi.cpp 
multicast.cpp mutex.cpp myserver.cpp myserver_regex.cpp pipe.cpp plugin.cpp 
plugins_manager.cpp plugins_namespace.cpp plugins_namespace_manager.cpp 
process.cpp process_server_manager.cpp protocol_buffer.cpp protocol.cpp 
protocols_manager.cpp read_write_lock.cpp recursive_mutex.cpp safetime.cpp 
scgi.cpp securestr.cpp security_cache.cpp security.cpp semaphore.cpp server.cpp 
socket.cpp ssl.cpp ssl_socket.cpp stream.cpp stringutils.cpp thread.cpp 
utility.cpp vhost_manager.cpp vhost.cpp wincgi.cpp xml_parser.cpp ftp_lexer.cpp 
ftp_parser.cpp ftp.cpp
+myserver_SOURCES = cached_file_buffer.cpp cached_file.cpp 
cached_file_factory.cpp cgi.cpp clients_thread.cpp connection.cpp 
connections_scheduler.cpp control_header.cpp control_protocol.cpp Dev-C++.cpp 
dynamic_executor.cpp dynamiclib.cpp dynamic_protocol.cpp 
dyn_executor_manager.cpp dyn_filter.cpp dyn_filter_file.cpp 
dyn_filters_manager.cpp dyn_http_command.cpp dyn_http_command_manager.cpp 
dyn_http_manager.cpp dyn_http_manager_list.cpp env.cpp event.cpp fastcgi.cpp 
file.cpp files_utility.cpp filter.cpp filters_chain.cpp filters_factory.cpp 
generic_plugins_manager.cpp gzip.cpp gzip_decompress.cpp hash_map.cpp 
home_dir.cpp http.cpp http_data_handler.cpp http_data_read.cpp http_dir.cpp 
http_errors.cpp http_file.cpp http_header_checker.cpp http_headers.cpp 
http_request.cpp http_response.cpp https.cpp http_thread_context.cpp isapi.cpp 
find_data.cpp listen_threads.cpp log_manager.cpp md5.cpp mem_buff.cpp 
memory_stream.cpp mime_manager.cpp mime_utils.cpp mscgi_manager.cpp mscgi.cpp 
multicast.cpp mutex.cpp myserver.cpp myserver_regex.cpp pipe.cpp plugin.cpp 
plugins_manager.cpp plugins_namespace.cpp plugins_namespace_manager.cpp 
process.cpp process_server_manager.cpp protocol_buffer.cpp protocol.cpp 
protocols_manager.cpp read_write_lock.cpp recursive_mutex.cpp safetime.cpp 
scgi.cpp securestr.cpp security_cache.cpp security.cpp semaphore.cpp server.cpp 
socket.cpp ssl.cpp ssl_socket.cpp stream.cpp stringutils.cpp thread.cpp 
utility.cpp vhost_manager.cpp vhost.cpp wincgi.cpp xml_parser.cpp ftp_lexer.cpp 
ftp_parser.cpp ftp.cpp
 
 INCLUDES = $(all_includes)
 

Modified: trunk/myserver/src/cgi.cpp
===================================================================
--- trunk/myserver/src/cgi.cpp  2008-08-05 21:34:49 UTC (rev 2737)
+++ trunk/myserver/src/cgi.cpp  2008-08-06 15:55:22 UTC (rev 2738)
@@ -29,11 +29,11 @@
 #include "../include/utility.h"
 #include "../include/mem_buff.h"
 #include "../include/filters_chain.h"
+#include "../include/env.h"
 #include "../include/pipe.h"
 
 #include <string>
 #include <sstream>
-#include <algorithm>
 
 extern "C" {
 #ifdef WIN32
@@ -292,7 +292,7 @@
    *Use the td->buffer2 to build the environment string.
    */
   (td->buffer2->getBuffer())[0] = '\0';
-  buildCGIEnvironmentString(td, td->buffer2->getBuffer());
+  Env::buildEnvironmentString(td, td->buffer2->getBuffer());
   
   /*
    *With this code we execute the CGI process.
@@ -674,243 +674,6 @@
 }
 
 /*!
- *Write the string that contain the CGI environment to cgiEnvString.
- *This function is used by other server side protocols too.
- *\param td The HTTP thread context.
- *\param cgiEnv The zero terminated list of environment string.
- *\param processEnv Specify if add current process environment 
- *variables too.
- */
-void Cgi::buildCGIEnvironmentString(HttpThreadContext* td, char *cgiEnv, 
-                                    int processEnv)
-{
-  MemBuf memCgi;
-  char strTmp[32];
-
-  memCgi.setExternalBuffer(cgiEnv, td->buffer2->getRealLength());
-  memCgi << "SERVER_SOFTWARE=GNU MyServer " << versionOfSoftware;
-
-#ifdef WIN32
-  memCgi << " (WIN32)";
-#else
-#ifdef HOST_STR
-  memCgi << " " << HOST_STR;
-#else
-  memCgi << " (Unknown)";
-#endif
-#endif
-  /* Must use REDIRECT_STATUS for php and others.  */
-  memCgi << end_str << "REDIRECT_STATUS=TRUE";
-  
-  memCgi << end_str << "SERVER_NAME=";
-   memCgi << Server::getInstance()->getServerName();
-
-  memCgi << end_str << "SERVER_SIGNATURE=";
-  memCgi << "<address>GNU MyServer ";
-  memCgi << versionOfSoftware;
-  memCgi << "</address>";
-
-  memCgi << end_str << "SERVER_PROTOCOL=";
-  memCgi << td->request.ver.c_str();  
-  
-  {
-    MemBuf portBuffer;
-    portBuffer.uintToStr( td->connection->getLocalPort());
-    memCgi << end_str << "SERVER_PORT="<< portBuffer;
-  }
-
-  memCgi << end_str << "SERVER_ADMIN=";
-  memCgi << Server::getInstance()->getServerAdmin();
-
-  memCgi << end_str << "REQUEST_METHOD=";
-  memCgi << td->request.cmd.c_str();
-
-  memCgi << end_str << "REQUEST_URI=";
-  
-   memCgi << td->request.uri.c_str();
-
-  memCgi << end_str << "QUERY_STRING=";
-  memCgi << td->request.uriOpts.c_str();
-
-  memCgi << end_str << "GATEWAY_INTERFACE=CGI/1.1";
-
-  if(td->request.contentLength.length())
-  {
-    memCgi << end_str << "CONTENT_LENGTH=";
-    memCgi << td->request.contentLength.c_str();
-  }
-  else
-  {
-    u_long fs = 0;
-    ostringstream stream;
- 
-    if(td->inputData.getHandle())
-      fs = td->inputData.getFileSize();
-
-    stream << fs;
-
-    memCgi << end_str << "CONTENT_LENGTH=" << stream.str().c_str();
-  }
-
-
-  if(td->request.rangeByteBegin || td->request.rangeByteEnd)
-  {
-    ostringstream rangeBuffer;
-    memCgi << end_str << "HTTP_RANGE=" << td->request.rangeType << "=" ;
-    if(td->request.rangeByteBegin)
-    {
-      rangeBuffer << static_cast<int>(td->request.rangeByteBegin);
-      memCgi << rangeBuffer.str();
-    }
-    memCgi << "-";
-    if(td->request.rangeByteEnd)
-    {
-      rangeBuffer << td->request.rangeByteEnd;
-      memCgi << rangeBuffer.str();
-    }   
-
-  }
-
-  if(td->cgiRoot.length())
-  {
-    memCgi << end_str << "CGI_ROOT=";
-    memCgi << td->cgiRoot;
-  }
-
-  if(td->connection->getIpAddr()[0])
-  {
-    memCgi << end_str << "REMOTE_ADDR=";
-    memCgi << td->connection->getIpAddr();
-  }
-
-  if(td->connection->getPort())
-  {
-    MemBuf remotePortBuffer;
-    remotePortBuffer.MemBuf::uintToStr(td->connection->getPort() );
-     memCgi << end_str << "REMOTE_PORT=" << remotePortBuffer;
-  }
-
-  if(td->connection->getLogin()[0])
-  {
-    memCgi << end_str << "REMOTE_USER=";
-    memCgi << td->connection->getLogin();
-  }
-  
-  if(td->http->getProtocolOptions() & PROTOCOL_USES_SSL)
-    memCgi << end_str << "SSL=ON";
-  else
-    memCgi << end_str << "SSL=OFF";
-
-
-  if(td->pathInfo.length())
-  {
-    memCgi << end_str << "PATH_INFO=";
-    memCgi << td->pathInfo;
-      
-    memCgi << end_str << "PATH_TRANSLATED=";
-    memCgi << td->pathTranslated;
-  }
-  else
-  {
-    memCgi << end_str << "PATH_TRANSLATED=";
-    memCgi << td->filenamePath;
-  }
-
-   memCgi << end_str << "SCRIPT_FILENAME=";
-  memCgi << td->filenamePath;
-  
-  /*
-   *For the DOCUMENT_URI and SCRIPT_NAME copy the 
-   *requested uri without the pathInfo.
-   */
-  memCgi << end_str << "SCRIPT_NAME=";
-  memCgi << td->request.uri.c_str();
-
-  memCgi << end_str << "SCRIPT_URL=";
-  memCgi << td->request.uri.c_str();
-
-  memCgi << end_str << "DATE_GMT=";
-  getRFC822GMTTime(strTmp, HTTP_RESPONSE_DATE_DIM);
-  memCgi << strTmp;
-
-   memCgi << end_str << "DATE_LOCAL=";
-  getRFC822LocalTime(strTmp, HTTP_RESPONSE_DATE_DIM);
-  memCgi << strTmp;
-
-  memCgi << end_str << "DOCUMENT_ROOT=";
-  memCgi << td->connection->host->getDocumentRoot();
-
-  memCgi << end_str << "DOCUMENT_URI=";
-  memCgi << td->request.uri.c_str();
-  
-  memCgi << end_str << "DOCUMENT_NAME=";
-  memCgi << td->filenamePath;
-
-  if(td->connection->getLogin()[0])
-  {
-      memCgi << end_str << "REMOTE_IDENT=";
-      memCgi << td->connection->getLogin();
-  }
-
-  if(td->request.auth.length())
-  {
-    memCgi << end_str << "AUTH_TYPE=";
-    memCgi << td->request.auth.c_str();
-  }
-
-
-  {
-    HttpRequestHeader::Entry* e = td->request.other.get("Content-Type");
-    if(e)
-    {
-      memCgi << end_str << "CONTENT_TYPE=";
-      memCgi << e->value->c_str();
-    }
-  }
-
-
-  {
-
-    HashMap<string, HttpRequestHeader::Entry*>::Iterator it = 
td->request.begin();
-    for(; it != td->request.end(); it++)
-    {
-      HttpRequestHeader::Entry* en = *it;
-      string name;
-
-      name.assign("HTTP_");
-      name.append(en->name->c_str());
-      transform(name.begin()+5, name.end(), name.begin()+5, ::toupper);
-      for(int i = name.length(); i > 5; i--)
-        if(name[i] == '-')
-          name[i] = '_';
-
-      memCgi  << end_str << name.c_str() << "=" << en->value->c_str();
-    }
-  }
-
-#ifdef WIN32
-  if(processEnv)
-  {
-    LPTSTR lpszVariable; 
-    LPVOID lpvEnv; 
-    lpvEnv = Server::getInstance()->getEnvString();
-    memCgi << end_str;
-    if (lpvEnv)
-      for (lpszVariable = (LPTSTR) lpvEnv; *lpszVariable; lpszVariable++) 
-      { 
-        if(((char*)lpszVariable)[0]  != '=' )
-        {
-          memCgi << (char*)lpszVariable << end_str;
-        }
-        while(*lpszVariable)
-          *lpszVariable++;
-      }
-  }
-#endif
-  memCgi << end_str << end_str  << end_str  << end_str  << end_str  ;
-}
-
-/*!
  *Set the CGI timeout for the new processes.
  *\param nt The new timeout value.
  */

Added: trunk/myserver/src/env.cpp
===================================================================
--- trunk/myserver/src/env.cpp                          (rev 0)
+++ trunk/myserver/src/env.cpp  2008-08-06 15:55:22 UTC (rev 2738)
@@ -0,0 +1,273 @@
+/*
+MyServer
+Copyright (C) 2002, 2003, 2004, 2006, 2007, 2008 Free Software Foundation, Inc.
+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 3 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, see <http://www.gnu.org/licenses/>.
+*/
+
+#include "../stdafx.h"
+#include "../include/env.h"
+#include "../include/http_headers.h"
+#include "../include/http.h"
+#include "../include/http_errors.h"
+#include "../include/server.h"
+
+#include <string>
+#include <sstream>
+#include <algorithm>
+
+extern "C" {
+#ifdef WIN32
+#include <direct.h>
+#endif
+#include <string.h>
+}
+
+using namespace std;
+
+/*!
+ *Write the string that contain the CGI environment to cgiEnvString.
+ *This function is used by other server side protocols too.
+ *\param td The HTTP thread context.
+ *\param cgiEnv The zero terminated list of environment string.
+ *\param processEnv Specify if add current process environment 
+ *variables too.
+ */
+void Env::buildEnvironmentString(HttpThreadContext* td, char *cgiEnv, 
+                                 int processEnv)
+{
+  MemBuf memCgi;
+  char strTmp[32];
+
+  memCgi.setExternalBuffer(cgiEnv, td->buffer2->getRealLength());
+  memCgi << "SERVER_SOFTWARE=GNU MyServer " << versionOfSoftware;
+
+#ifdef WIN32
+  memCgi << " (WIN32)";
+#else
+#ifdef HOST_STR
+  memCgi << " " << HOST_STR;
+#else
+  memCgi << " (Unknown)";
+#endif
+#endif
+  /* Must use REDIRECT_STATUS for php and others.  */
+  memCgi << end_str << "REDIRECT_STATUS=TRUE";
+  
+  memCgi << end_str << "SERVER_NAME=";
+   memCgi << Server::getInstance()->getServerName();
+
+  memCgi << end_str << "SERVER_SIGNATURE=";
+  memCgi << "<address>GNU MyServer ";
+  memCgi << versionOfSoftware;
+  memCgi << "</address>";
+
+  memCgi << end_str << "SERVER_PROTOCOL=";
+  memCgi << td->request.ver.c_str();  
+  
+  {
+    MemBuf portBuffer;
+    portBuffer.uintToStr( td->connection->getLocalPort());
+    memCgi << end_str << "SERVER_PORT="<< portBuffer;
+  }
+
+  memCgi << end_str << "SERVER_ADMIN=";
+  memCgi << Server::getInstance()->getServerAdmin();
+
+  memCgi << end_str << "REQUEST_METHOD=";
+  memCgi << td->request.cmd.c_str();
+
+  memCgi << end_str << "REQUEST_URI=";
+  
+   memCgi << td->request.uri.c_str();
+
+  memCgi << end_str << "QUERY_STRING=";
+  memCgi << td->request.uriOpts.c_str();
+
+  memCgi << end_str << "GATEWAY_INTERFACE=CGI/1.1";
+
+  if(td->request.contentLength.length())
+  {
+    memCgi << end_str << "CONTENT_LENGTH=";
+    memCgi << td->request.contentLength.c_str();
+  }
+  else
+  {
+    u_long fs = 0;
+    ostringstream stream;
+ 
+    if(td->inputData.getHandle())
+      fs = td->inputData.getFileSize();
+
+    stream << fs;
+
+    memCgi << end_str << "CONTENT_LENGTH=" << stream.str().c_str();
+  }
+
+
+  if(td->request.rangeByteBegin || td->request.rangeByteEnd)
+  {
+    ostringstream rangeBuffer;
+    memCgi << end_str << "HTTP_RANGE=" << td->request.rangeType << "=" ;
+    if(td->request.rangeByteBegin)
+    {
+      rangeBuffer << static_cast<int>(td->request.rangeByteBegin);
+      memCgi << rangeBuffer.str();
+    }
+    memCgi << "-";
+    if(td->request.rangeByteEnd)
+    {
+      rangeBuffer << td->request.rangeByteEnd;
+      memCgi << rangeBuffer.str();
+    }   
+
+  }
+
+  if(td->cgiRoot.length())
+  {
+    memCgi << end_str << "CGI_ROOT=";
+    memCgi << td->cgiRoot;
+  }
+
+  if(td->connection->getIpAddr()[0])
+  {
+    memCgi << end_str << "REMOTE_ADDR=";
+    memCgi << td->connection->getIpAddr();
+  }
+
+  if(td->connection->getPort())
+  {
+    MemBuf remotePortBuffer;
+    remotePortBuffer.MemBuf::uintToStr(td->connection->getPort() );
+     memCgi << end_str << "REMOTE_PORT=" << remotePortBuffer;
+  }
+
+  if(td->connection->getLogin()[0])
+  {
+    memCgi << end_str << "REMOTE_USER=";
+    memCgi << td->connection->getLogin();
+  }
+  
+  if(td->http->getProtocolOptions() & PROTOCOL_USES_SSL)
+    memCgi << end_str << "SSL=ON";
+  else
+    memCgi << end_str << "SSL=OFF";
+
+
+  if(td->pathInfo.length())
+  {
+    memCgi << end_str << "PATH_INFO=";
+    memCgi << td->pathInfo;
+      
+    memCgi << end_str << "PATH_TRANSLATED=";
+    memCgi << td->pathTranslated;
+  }
+  else
+  {
+    memCgi << end_str << "PATH_TRANSLATED=";
+    memCgi << td->filenamePath;
+  }
+
+   memCgi << end_str << "SCRIPT_FILENAME=";
+  memCgi << td->filenamePath;
+  
+  /*
+   *For the DOCUMENT_URI and SCRIPT_NAME copy the 
+   *requested uri without the pathInfo.
+   */
+  memCgi << end_str << "SCRIPT_NAME=";
+  memCgi << td->request.uri.c_str();
+
+  memCgi << end_str << "SCRIPT_URL=";
+  memCgi << td->request.uri.c_str();
+
+  memCgi << end_str << "DATE_GMT=";
+  getRFC822GMTTime(strTmp, HTTP_RESPONSE_DATE_DIM);
+  memCgi << strTmp;
+
+   memCgi << end_str << "DATE_LOCAL=";
+  getRFC822LocalTime(strTmp, HTTP_RESPONSE_DATE_DIM);
+  memCgi << strTmp;
+
+  memCgi << end_str << "DOCUMENT_ROOT=";
+  memCgi << td->connection->host->getDocumentRoot();
+
+  memCgi << end_str << "DOCUMENT_URI=";
+  memCgi << td->request.uri.c_str();
+  
+  memCgi << end_str << "DOCUMENT_NAME=";
+  memCgi << td->filenamePath;
+
+  if(td->connection->getLogin()[0])
+  {
+      memCgi << end_str << "REMOTE_IDENT=";
+      memCgi << td->connection->getLogin();
+  }
+
+  if(td->request.auth.length())
+  {
+    memCgi << end_str << "AUTH_TYPE=";
+    memCgi << td->request.auth.c_str();
+  }
+
+
+  {
+    HttpRequestHeader::Entry* e = td->request.other.get("Content-Type");
+    if(e)
+    {
+      memCgi << end_str << "CONTENT_TYPE=";
+      memCgi << e->value->c_str();
+    }
+  }
+
+
+  {
+
+    HashMap<string, HttpRequestHeader::Entry*>::Iterator it = 
td->request.begin();
+    for(; it != td->request.end(); it++)
+    {
+      HttpRequestHeader::Entry* en = *it;
+      string name;
+
+      name.assign("HTTP_");
+      name.append(en->name->c_str());
+      transform(name.begin()+5, name.end(), name.begin()+5, ::toupper);
+      for(int i = name.length(); i > 5; i--)
+        if(name[i] == '-')
+          name[i] = '_';
+
+      memCgi  << end_str << name.c_str() << "=" << en->value->c_str();
+    }
+  }
+
+#ifdef WIN32
+  if(processEnv)
+  {
+    LPTSTR lpszVariable; 
+    LPVOID lpvEnv; 
+    lpvEnv = Server::getInstance()->getEnvString();
+    memCgi << end_str;
+    if (lpvEnv)
+      for (lpszVariable = (LPTSTR) lpvEnv; *lpszVariable; lpszVariable++) 
+      { 
+        if(((char*)lpszVariable)[0]  != '=' )
+        {
+          memCgi << (char*)lpszVariable << end_str;
+        }
+        while(*lpszVariable)
+          *lpszVariable++;
+      }
+  }
+#endif
+  memCgi << end_str << end_str  << end_str  << end_str  << end_str  ;
+}

Modified: trunk/myserver/src/fastcgi.cpp
===================================================================
--- trunk/myserver/src/fastcgi.cpp      2008-08-05 21:34:49 UTC (rev 2737)
+++ trunk/myserver/src/fastcgi.cpp      2008-08-06 15:55:22 UTC (rev 2738)
@@ -21,7 +21,7 @@
  *On that site you can find samples and all the supported languages.
  */
 #include "../include/fastcgi.h"
-#include "../include/cgi.h"
+#include "../include/env.h"
 #include "../include/http.h"
 #include "../include/stringutils.h"
 #include "../include/server.h"
@@ -202,7 +202,7 @@
 #endif
   }
 
-  Cgi::buildCGIEnvironmentString(td, td->buffer->getBuffer());
+  Env::buildEnvironmentString(td, td->buffer->getBuffer());
   sizeEnvString = buildFASTCGIEnvironmentString(td,td->buffer->getBuffer(),
                                                 td->buffer2->getBuffer());
   if(sizeEnvString == -1)

Modified: trunk/myserver/src/isapi.cpp
===================================================================
--- trunk/myserver/src/isapi.cpp        2008-08-05 21:34:49 UTC (rev 2737)
+++ trunk/myserver/src/isapi.cpp        2008-08-06 15:55:22 UTC (rev 2738)
@@ -1,6 +1,6 @@
 /*
 MyServer
-Copyright (C) 2002, 2003, 2004, 2007 Free Software Foundation, Inc.
+Copyright (C) 2002, 2003, 2004, 2007, 2008 Free Software Foundation, Inc.
 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 3 of the License, or
@@ -21,7 +21,7 @@
 #include "../include/server.h"
 #include "../include/file.h"
 #include "../include/files_utility.h"
-#include "../include/cgi.h"
+#include "../include/env.h"
 #include "../include/dynamiclib.h"
 
 #include <string>
@@ -933,7 +933,7 @@
     FilesUtility::splitPath(tmp, td->scriptDir, td->scriptFile);
   }
   connTable[connIndex].envString[0]='\0';
-  Cgi::buildCGIEnvironmentString(td,connTable[connIndex].envString);
+  Env::buildEnvironmentString(td,connTable[connIndex].envString);
   
   ZeroMemory(&ExtCtrlBlk, sizeof(ExtCtrlBlk));
   ExtCtrlBlk.cbSize = sizeof(ExtCtrlBlk);

Modified: trunk/myserver/src/mscgi.cpp
===================================================================
--- trunk/myserver/src/mscgi.cpp        2008-08-05 21:34:49 UTC (rev 2737)
+++ trunk/myserver/src/mscgi.cpp        2008-08-06 15:55:22 UTC (rev 2738)
@@ -19,7 +19,7 @@
 #include "../include/http.h"
 #include "../include/server.h"
 #include "../include/security.h"
-#include "../include/cgi.h"
+#include "../include/env.h"
 #include "../include/mime_utils.h"
 #include "../include/file.h"
 #include "../include/files_utility.h"
@@ -96,7 +96,7 @@
     FilesUtility::splitPath(exec, td->scriptDir, td->scriptFile);
   }
 
-  Cgi::buildCGIEnvironmentString(td,data.envString);
+  Env::buildEnvironmentString(td,data.envString);
   
   chain.setProtocol(td->http);
   chain.setProtocolData(td);

Modified: trunk/myserver/src/scgi.cpp
===================================================================
--- trunk/myserver/src/scgi.cpp 2008-08-05 21:34:49 UTC (rev 2737)
+++ trunk/myserver/src/scgi.cpp 2008-08-06 15:55:22 UTC (rev 2738)
@@ -15,7 +15,7 @@
 along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 #include "../include/scgi.h"
-#include "../include/cgi.h"
+#include "../include/env.h"
 #include "../include/http.h"
 #include "../include/stringutils.h"
 #include "../include/server.h"
@@ -168,7 +168,7 @@
 #endif
   }
 
-  Cgi::buildCGIEnvironmentString(td, td->buffer->getBuffer());
+  Env::buildEnvironmentString(td, td->buffer->getBuffer());
   sizeEnvString = buildScgiEnvironmentString(td,td->buffer->getBuffer(),
                                              td->buffer2->getBuffer());
   if(sizeEnvString == -1)






reply via email to

[Prev in Thread] Current Thread [Next in Thread]