myserver-commit
[Top][All Lists]
Advanced

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

[myserver-commit] [SCM] GNU MyServer branch, master, updated. b78c1582c4


From: Giuseppe Scrivano
Subject: [myserver-commit] [SCM] GNU MyServer branch, master, updated. b78c1582c451a266d9cdb97c4d01634a1a6c766d
Date: Sun, 27 Sep 2009 09:28:37 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU MyServer".

The branch, master has been updated
       via  b78c1582c451a266d9cdb97c4d01634a1a6c766d (commit)
      from  c1a004a4dbe93748127a1bcf09b265cca2dab034 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------


commit b78c1582c451a266d9cdb97c4d01634a1a6c766d
Author: Giuseppe Scrivano <address@hidden>
Date:   Sun Sep 27 11:24:36 2009 +0200

    Remove some members from the `HttpResponseHeader' struct.
    
    If the same header field is found several times, then it is joined on
    a single line comma separed.

diff --git a/myserver/include/protocol/http/http_response.h 
b/myserver/include/protocol/http/http_response.h
index 579f801..a362efd 100644
--- a/myserver/include/protocol/http/http_response.h
+++ b/myserver/include/protocol/http/http_response.h
@@ -27,24 +27,11 @@ using namespace std;
 
 /*! Max length for a HTTP response fields. */
 # define HTTP_RESPONSE_VER_DIM 10
-# define HTTP_RESPONSE_SERVER_NAME_DIM 64
-# define HTTP_RESPONSE_CONTENT_TYPE_DIM 48
-# define HTTP_RESPONSE_CONTENT_RANGE_DIM 32
-# define HTTP_RESPONSE_CONNECTION_DIM 32
-# define HTTP_RESPONSE_MIME_VER_DIM 8
-# define HTTP_RESPONSE_COOKIE_DIM 8192
-# define HTTP_RESPONSE_CONTENT_LENGTH_DIM 8
-# define HTTP_RESPONSE_ERROR_TYPE_DIM 32
-# define HTTP_RESPONSE_LOCATION_DIM MAX_PATH
-# define HTTP_RESPONSE_DATE_DIM 32
-# define HTTP_RESPONSE_DATE_EXPIRES_DIM 32
-# define HTTP_RESPONSE_CACHE_CONTROL_DIM 64
-# define HTTP_RESPONSE_AUTH_DIM 256
-# define HTTP_RESPONSE_OTHER_DIM 512
-# define HTTP_RESPONSE_LAST_MODIFIED_DIM 32
+# define HTTP_RESPONSE_OTHER_DIM 4096
+
 
 /*!
- *Structure to describe an HTTP response
+ * Structure to describe an HTTP response
  */
 struct HttpResponseHeader : public HttpHeader
 {
@@ -81,10 +68,6 @@ struct HttpResponseHeader : public HttpHeader
   };
        int httpStatus;
        string ver;
-       string serverName;
-       string contentType;
-       string connection;
-       string cookie;
        string contentLength;
        string errorType;
 
diff --git a/myserver/src/http_handler/cgi/cgi.cpp 
b/myserver/src/http_handler/cgi/cgi.cpp
index df68e9c..7851192 100644
--- a/myserver/src/http_handler/cgi/cgi.cpp
+++ b/myserver/src/http_handler/cgi/cgi.cpp
@@ -492,7 +492,7 @@ int Cgi::sendHeader (HttpThreadContext* td, Pipe 
&stdOutFile, FiltersChain& chai
   if (!nph)
     {
       if (keepalive)
-        td->response.connection.assign ("keep-alive");
+        td->response.setValue ("Connection", "keep-alive");
 
       /* Send the header.  */
       if (headerSize)
diff --git a/myserver/src/http_handler/http_dir/http_dir.cpp 
b/myserver/src/http_handler/http_dir/http_dir.cpp
index d048d61..57df24d 100644
--- a/myserver/src/http_handler/http_dir/http_dir.cpp
+++ b/myserver/src/http_handler/http_dir/http_dir.cpp
@@ -337,7 +337,7 @@ int HttpDir::send(HttpThreadContext* td,
 
   checkDataChunks(td, &keepalive, &useChunks);
 
-  td->response.contentType.assign("text/html");
+  td->response.setValue ("ContentType", "text/html");
 
   if(!td->appendOutputs)
   {
diff --git a/myserver/src/http_handler/http_file/http_file.cpp 
b/myserver/src/http_handler/http_file/http_file.cpp
index cc82bd4..7e4a576 100644
--- a/myserver/src/http_handler/http_file/http_file.cpp
+++ b/myserver/src/http_handler/http_file/http_file.cpp
@@ -55,7 +55,7 @@ int HttpFile::putFile (HttpThreadContext* td,
 
     if(td->request.isKeepAlive())
       {
-        td->response.connection.assign("keep-alive");
+        td->response.setValue ("Connection", "keep-alive");
         keepalive = 1;
       }
 
@@ -260,7 +260,7 @@ int HttpFile::send (HttpThreadContext* td, const char 
*filenamePath,
     if (lastMT == -1)
       return td->http->raiseHTTPError(500);
 
-    getRFC822GMTTime (lastMT, tmpTime, HTTP_RESPONSE_LAST_MODIFIED_DIM);
+    getRFC822GMTTime (lastMT, tmpTime, 32);
     td->response.setValue ("Last-Modified", tmpTime.c_str ());
 
     HttpRequestHeader::Entry *ifModifiedSince =
@@ -453,9 +453,9 @@ int HttpFile::send (HttpThreadContext* td, const char 
*filenamePath,
       }
 
     if (keepalive)
-      td->response.connection.assign("keep-alive");
+      td->response.setValue ("Connection", "keep-alive");
     else
-      td->response.connection.assign("close");
+      td->response.setValue ("Connection", "close");
 
     if (useModifiers)
       {
diff --git a/myserver/src/http_handler/mscgi/mscgi_manager.cpp 
b/myserver/src/http_handler/mscgi/mscgi_manager.cpp
index 289bca1..17a00bb 100644
--- a/myserver/src/http_handler/mscgi/mscgi_manager.cpp
+++ b/myserver/src/http_handler/mscgi/mscgi_manager.cpp
@@ -1,6 +1,6 @@
 /*
 MyServer
-Copyright (C) 2002, 2003, 2004, 2006, 2007, 2008 Free Software Foundation, Inc.
+Copyright (C) 2002, 2003, 2004, 2006, 2007, 2008, 2009 Free Software 
Foundation, Inc.
 This library is free software; you can redistribute it and/or
 modify it under the terms of the GNU Lesser General Public
 License as published by the Free Software Foundation; either
@@ -250,7 +250,7 @@ MsCgiData* MscgiManager::getCgiData()
  */
 void MscgiManager::setContentType(const char * type)
 {
-  td->response.contentType.assign(type, HTTP_RESPONSE_CONTENT_TYPE_DIM);
+  td->response.setValue ("ContentType", type);
 }
 
 /*!
diff --git a/myserver/src/protocol/http/env/env.cpp 
b/myserver/src/protocol/http/env/env.cpp
index aa5aaca..d1e7d72 100644
--- a/myserver/src/protocol/http/env/env.cpp
+++ b/myserver/src/protocol/http/env/env.cpp
@@ -26,7 +26,8 @@ along with this program.  If not, see 
<http://www.gnu.org/licenses/>.
 #include <sstream>
 #include <algorithm>
 
-extern "C" {
+extern "C"
+{
 #ifdef WIN32
 # include <direct.h>
 #endif
@@ -179,11 +180,11 @@ void Env::buildEnvironmentString(HttpThreadContext* td, 
char *cgiEnv,
   memCgi << td->request.uri.c_str();
 
   memCgi << end_str << "DATE_GMT=";
-  getRFC822GMTTime(strTmp, HTTP_RESPONSE_DATE_DIM);
+  getRFC822GMTTime(strTmp, 32);
   memCgi << strTmp;
 
   memCgi << end_str << "DATE_LOCAL=";
-  getRFC822LocalTime(strTmp, HTTP_RESPONSE_DATE_DIM);
+  getRFC822LocalTime(strTmp, 32);
   memCgi << strTmp;
 
   memCgi << end_str << "DOCUMENT_ROOT=";
diff --git a/myserver/src/protocol/http/http.cpp 
b/myserver/src/protocol/http/http.cpp
index 02cb972..e2d38a4 100644
--- a/myserver/src/protocol/http/http.cpp
+++ b/myserver/src/protocol/http/http.cpp
@@ -102,7 +102,7 @@ int Http::optionsHTTPRESOURCE (string& filename, int 
yetmapped)
       if (ret != 200)
         return raiseHTTPError (ret);
 
-      getRFC822GMTTime (time, HTTP_RESPONSE_DATE_DIM);
+      getRFC822GMTTime (time, 32);
       td->secondaryBuffer->setLength (0);
       *td->secondaryBuffer << "HTTP/1.1 200 OK\r\n";
       *td->secondaryBuffer << "Date: " << time;
@@ -150,7 +150,7 @@ int Http::traceHTTPRESOURCE (string& filename, int 
yetmapped)
         return raiseHTTPError (ret);
 
       tmp.intToStr (contentLength, tmpStr, 12);
-      getRFC822GMTTime (time, HTTP_RESPONSE_DATE_DIM);
+      getRFC822GMTTime (time, 32);
 
       td->secondaryBuffer->setLength (0);
       *td->secondaryBuffer << "HTTP/1.1 200 OK\r\n";
@@ -408,10 +408,7 @@ int Http::preprocessHttpRequest (string& filename, int 
yetmapped, int* permissio
   try
     {
       if (td->request.isKeepAlive ())
-        {
-          td->response.connection.assign ("keep-alive");
-        }
-
+        td->response.setValue("Connection", "keep-alive");
 
       ret = getFilePermissions (filename, directory, file,
                                 td->filenamePath, yetmapped, permissions);
@@ -643,17 +640,15 @@ Http::sendHTTPResource (string& uri, int systemrequest, 
int onlyHeader,
           return processDefaultFile (uri, td->permissions, onlyHeader);
         }
 
-      td->response.contentType[0] = '\0';
-
       /* If not specified differently, set the default content type to 
text/html.  */
       if (td->mime)
         {
-          td->response.contentType.assign (td->mime->mimeType);
+          td->response.setValue ("ContentType", td->mime->mimeType.c_str ());
           cgiManager = td->mime->cgiManager.c_str ();
         }
       else
         {
-          td->response.contentType.assign ("text/html");
+          td->response.setValue ("ContentType", "text/html");
           cgiManager = "";
         }
 
@@ -712,7 +707,7 @@ int Http::logHTTPaccess ()
 
       *td->secondaryBuffer << " [";
 
-      getLocalLogFormatDate (time, HTTP_RESPONSE_DATE_DIM);
+      getLocalLogFormatDate (time, 32);
       *td->secondaryBuffer << time << "] \"";
 
       if (td->request.cmd.length ())
@@ -1327,7 +1322,7 @@ int Http::requestAuthorization ()
       return raiseHTTPError (501);
     }
   *td->secondaryBuffer << "Date: ";
-  getRFC822GMTTime (time, HTTP_RESPONSE_DATE_DIM);
+  getRFC822GMTTime (time, 32);
   *td->secondaryBuffer << time
           << "\r\n\r\n";
   if (td->connection->socket->send (td->secondaryBuffer->getBuffer (),
@@ -1376,10 +1371,9 @@ int Http::raiseHTTPError (int ID)
       td->lastError = ID;
 
       HttpHeaders::buildDefaultHTTPResponseHeader (&(td->response));
+
       if (connection && !stringcmpi (connection->value->c_str (), 
"keep-alive"))
-        {
-          td->response.connection.assign ("keep-alive");
-        }
+        td->response.setValue ("Connection", "keep-alive");
 
       td->response.httpStatus = ID;
 
@@ -1530,7 +1524,7 @@ Internal Server Error\n\
   *td->secondaryBuffer << tmp;
   *td->secondaryBuffer << "\r\n";
   *td->secondaryBuffer << "Date: ";
-  getRFC822GMTTime (time, HTTP_RESPONSE_DATE_DIM);
+  getRFC822GMTTime (time, 32);
   *td->secondaryBuffer << time;
   *td->secondaryBuffer << "\r\n\r\n";
 
@@ -1720,7 +1714,7 @@ int Http::sendHTTPRedirect (const char *newURL)
     *td->secondaryBuffer << "Connection: close\r\n";
 
   *td->secondaryBuffer << "Date: ";
-  getRFC822GMTTime (time, HTTP_RESPONSE_DATE_DIM);
+  getRFC822GMTTime (time, 32);
   *td->secondaryBuffer << time
           << "\r\n\r\n";
   if (td->connection->socket->send (td->secondaryBuffer->getBuffer (),
@@ -1752,7 +1746,7 @@ int Http::sendHTTPNonModified ()
   else
     *td->secondaryBuffer << "Connection: close\r\n";
 
-  getRFC822GMTTime (time, HTTP_RESPONSE_DATE_DIM);
+  getRFC822GMTTime (time, 32);
 
   *td->secondaryBuffer << "Date: " << time << "\r\n\r\n";
 
diff --git a/myserver/src/protocol/http/http_headers.cpp 
b/myserver/src/protocol/http/http_headers.cpp
index 1bb3136..e4fa388 100644
--- a/myserver/src/protocol/http/http_headers.cpp
+++ b/myserver/src/protocol/http/http_headers.cpp
@@ -68,31 +68,6 @@ u_long HttpHeaders::buildHTTPResponseHeader (char *str,
   else
     pos += sprintf (str,"%s 200 OK\r\n",response->ver.c_str ());
 
-  if (response->serverName.length ())
-    {
-      pos += myserver_strlcpy (pos, "Server: ", MAX-(long)(pos-str));
-      pos += myserver_strlcpy (pos, response->serverName.c_str (), 
MAX-(long)(pos-str));
-      pos += myserver_strlcpy (pos, "\r\n", MAX-(long)(pos-str));
-    }
-  else
-    {
-      pos += myserver_strlcpy (pos, "Server: GNU MyServer ", 
MAX-(long)(pos-str));
-      pos += myserver_strlcpy (pos, MYSERVER_VERSION,  MAX-(long)(pos-str));
-      pos += myserver_strlcpy (pos, "\r\n", MAX-(long)(pos-str));
-    }
-
-  if (response->connection.length ())
-    {
-      pos += myserver_strlcpy (pos,"Connection: ", MAX-(long)(pos-str));
-      pos += myserver_strlcpy (pos, response->connection.c_str (),
-                             MAX-(long)(pos-str));
-      pos += myserver_strlcpy (pos, "\r\n", MAX-(long)(pos-str));
-    }
-  else
-    {
-      pos += myserver_strlcpy (pos, "Connection: Close\r\n", 
MAX-(long)(pos-str));
-    }
-
   if (response->contentLength.length ())
     {
       /*
@@ -109,48 +84,17 @@ u_long HttpHeaders::buildHTTPResponseHeader (char *str,
         }
     }
 
-  if (response->cookie.length ())
+  HashMap<string, HttpResponseHeader::Entry*>::Iterator it =
+    response->other.begin();
+  for (; it != response->other.end(); it++)
     {
-      string cookie;
-      const char *token = response->cookie.c_str ();
-      int max = response->cookie.length ();
-      while (token)
-        {
-          int len = getCharInString (token, "\n", max);
-          if (len == -1 || *token=='\n')
-        break;
-          cookie.assign ("Set-Cookie: ");
-          cookie.append (token, len);
-          cookie.append ("\r\n");
-          pos += myserver_strlcpy (pos, cookie.c_str (), MAX-(long)(pos-str));
-          token += len + 1;
-        }
-    }
-
-  if (response->contentType.length ())
-    {
-      pos += myserver_strlcpy (pos, "Content-Type: ", MAX-(long)(pos-str));
-      pos += myserver_strlcpy (pos, response->contentType.c_str (), 
MAX-(long)(pos-str));
+      HttpResponseHeader::Entry *e = *it;
+      pos += myserver_strlcpy (pos, e->name->c_str (), MAX-(long)(pos-str));
+      pos += myserver_strlcpy (pos, ": ", MAX-(long)(pos-str));
+      pos += myserver_strlcpy (pos, e->value->c_str (), MAX-(long)(pos-str));
       pos += myserver_strlcpy (pos, "\r\n", MAX-(long)(pos-str));
     }
 
-  if (response->other.size ())
-    {
-      HashMap<string, HttpResponseHeader::Entry*>::Iterator it =
-        response->other.begin();
-    for (; it != response->other.end(); it++)
-      {
-        HttpResponseHeader::Entry *e = *it;
-        if (e)
-          {
-            pos += myserver_strlcpy (pos, e->name->c_str (), 
MAX-(long)(pos-str));
-            pos += myserver_strlcpy (pos, ": ", MAX-(long)(pos-str));
-            pos += myserver_strlcpy (pos, e->value->c_str (), 
MAX-(long)(pos-str));
-            pos += myserver_strlcpy (pos, "\r\n", MAX-(long)(pos-str));
-          }
-      }
-    }
-
   pos += myserver_strlcpy (pos, "Accept-Ranges: bytes\r\n", 
MAX-(long)(pos-str));
 
   pos += myserver_strlcpy (pos, "\r\n", MAX-(long)(pos-str));
@@ -252,11 +196,9 @@ void 
HttpHeaders::buildDefaultHTTPResponseHeader(HttpResponseHeader* response)
 {
   resetHTTPResponse(response);
 
-  response->contentType.assign ("text/html");
+  response->setValue ("Content-Type", "text/html");
   response->ver.assign ("HTTP/1.1");
-
-  response->serverName.assign ("GNU MyServer ");
-  response->serverName.append (MYSERVER_VERSION);
+  response->setValue ("Server", "GNU MyServer " MYSERVER_VERSION);
 }
 
 /*!
@@ -1024,17 +966,6 @@ int HttpHeaders::buildHTTPResponseHeaderStruct(const char 
*input,
         if (token)
           response->errorType.assign (token);
       }
-    else if (!strcmpi(command,"Server"))
-      {
-        token = strtok (NULL, "\r\n\0" );
-        lineControlled = 1;
-
-        while (token && *token == ' ')
-          token++;
-
-        if (token)
-          response->serverName.assign (token);
-      }
     else if (!strcmpi(command,"Status"))
       {
         token = strtok (NULL, "\r\n\0" );
@@ -1043,37 +974,11 @@ int HttpHeaders::buildHTTPResponseHeaderStruct(const 
char *input,
         while (token && *token == ' ')
           token++;
 
-        /*! If the response status is different from 200 don't modify it. */
+        /* If the response status is different from 200 don't modify it. */
         if (response->httpStatus == 200)
           if (token)
             response->httpStatus = atoi(token);
       }
-    else if (!strcmpi(command,"Content-Type"))
-      {
-        token = strtok (NULL, "\r\n\0" );
-        lineControlled = 1;
-
-        while (token && *token == ' ')
-          token++;
-
-        if (token)
-          response->contentType.assign (token);
-      }
-    else if (!strcmpi(command,"Set-Cookie"))
-      {
-        token = strtok (NULL, "\r\n\0" );
-        lineControlled = 1;
-
-        while (token && *token == ' ')
-          token++;
-
-        if (token)
-          {
-            /* Divide multiple cookies.  */
-            response->cookie.append(token );
-            response->cookie.append("\n");
-          }
-      }
     else if (!strcmpi (command, "Content-Length"))
       {
         token = strtok (NULL, "\r\n\0" );
@@ -1084,14 +989,6 @@ int HttpHeaders::buildHTTPResponseHeaderStruct(const char 
*input,
 
         response->contentLength.assign (token);
       }
-    else if (!strcmpi (command, "Connection"))
-      {
-        token = strtok (NULL, "\r\n\0" );
-        lineControlled = 1;
-
-        if (token)
-          response->connection.assign (token);
-      }
 
     /*
      *If the line is not controlled arrive with the token
@@ -1106,24 +1003,28 @@ int HttpHeaders::buildHTTPResponseHeaderStruct(const 
char *input,
 
         if (token)
           {
-            HttpResponseHeader::Entry *e;
+            
             if (strlen (command) > HTTP_RESPONSE_OTHER_DIM ||
                 strlen (token) > HTTP_RESPONSE_OTHER_DIM)
-              return 0;
+              {
+                validResponse = 0;
+                break;
+              }
 
-            e = new HttpResponseHeader::Entry();
-            if (e)
+            HttpResponseHeader::Entry *old = NULL;
+            HttpResponseHeader::Entry *e = new HttpResponseHeader::Entry();
+            e->name->assign (command);
+            string cmdString (command);
+            old = response->other.put (cmdString, e);
+            if (old)
               {
-                e->name->assign (command);
-                e->value->assign (token);
-                {
-                  HttpResponseHeader::Entry *old = 0;
-                  string cmdString (command);
-                  old = response->other.put (cmdString, e);
-                  if (old)
-                    delete old;
-                }
+                e->value->assign (*old->value);
+                e->value->append (", ");
+                e->value->append (token);
+                delete old;
               }
+            else
+              e->value->assign (token);
           }
       }
     token = strtok (NULL, cmdSeps);
diff --git a/myserver/src/protocol/http/http_response.cpp 
b/myserver/src/protocol/http/http_response.cpp
index 2749859..e592557 100644
--- a/myserver/src/protocol/http/http_response.cpp
+++ b/myserver/src/protocol/http/http_response.cpp
@@ -47,10 +47,6 @@ HttpResponseHeader::~HttpResponseHeader ()
 void HttpResponseHeader::free()
 {
   ver.clear ();
-  serverName.clear ();
-  contentType.clear ();
-  connection.clear ();
-  cookie.clear ();
   contentLength.clear ();
   errorType.clear ();
 
@@ -73,41 +69,6 @@ string* HttpResponseHeader::getValue (const char* name, 
string* out)
       return &ver;
     }
 
-  if (!strcmpi (name, "Server"))
-    {
-      if (out)
-        out->assign (serverName.c_str ());
-      return &ver;
-    }
-
-  if (!strcmpi (name, "Content-Type"))
-    {
-      if (out)
-        out->assign (contentType.c_str ());
-      return &contentType;
-    }
-
-  if (!strcmpi (name, "Connection"))
-    {
-      if (out)
-        out->assign (connection.c_str ());
-      return &connection;
-    }
-
-  if (!strcmpi (name, "Content-Type"))
-    {
-      if (out)
-        out->assign (contentType.c_str ());
-      return &contentType;
-    }
-
-  if (!strcmpi (name, "Cookie"))
-    {
-      if (out)
-        out->assign (cookie.c_str ());
-      return &cookie;
-    }
-
   if (!strcmpi (name, "Content-Length"))
     {
       if (out)
@@ -136,36 +97,6 @@ string* HttpResponseHeader::setValue (const char* name, 
const char* in)
       return &ver;
     }
 
-  if (!strcmpi (name, "Server"))
-    {
-      serverName.assign (in);
-      return &serverName;
-    }
-
-  if (!strcmpi (name, "Content-Type"))
-    {
-      contentType.assign (in);
-      return &contentType;
-    }
-
-  if (!strcmpi (name, "Connection"))
-    {
-      connection.assign (in);
-      return &connection;
-    }
-
-  if (!strcmpi (name, "Content-Type"))
-    {
-      contentType.assign (in);
-      return &contentType;
-    }
-
-  if (!strcmpi (name, "Cookie"))
-    {
-      cookie.assign (in);
-      return &cookie;
-    }
-
   if (!strcmpi (name, "Content-Length"))
     {
       contentLength.assign (in);
diff --git a/myserver/tests/test_http_response.cpp 
b/myserver/tests/test_http_response.cpp
index d8af7a9..9519b09 100644
--- a/myserver/tests/test_http_response.cpp
+++ b/myserver/tests/test_http_response.cpp
@@ -1,19 +1,19 @@
 /*
- MyServer
- Copyright (C) 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/>.
- */
+  MyServer
+  Copyright (C) 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 <ctype.h>
 
@@ -36,22 +36,23 @@ class TestHttpResponse : public CppUnit::TestFixture
   CPPUNIT_TEST_SUITE( TestHttpResponse );
   CPPUNIT_TEST( testSimpleHeader );
   CPPUNIT_TEST( testInvalidResponse );
+  CPPUNIT_TEST( testJoinField );
   CPPUNIT_TEST( testValidResponse );
   CPPUNIT_TEST( testReset );
   CPPUNIT_TEST_SUITE_END();
 
 public:
-  void setUp()
+  void setUp ()
   {
 
   }
 
-  void tearDown()
+  void tearDown ()
   {
 
   }
 
-  void testSimpleHeader()
+  void testSimpleHeader ()
   {
     HttpResponseHeader header;
     const char * responseStr = "HTTP/1.1 200 Success\r\nContent-Length: 
0\r\n\r\n";
@@ -65,7 +66,29 @@ public:
     CPPUNIT_ASSERT(ret != 0);
   }
 
-  void testValidResponse()
+  void testJoinField ()
+  {
+    HttpResponseHeader header;
+    u_long nbtr;
+    const char * responseStr =
+      "HTTP/1.1 200 Success\r\n\
+Content-Length: 0\r\n\
+ToJoin: a\r\n\
+ToJoin: b\r\n";
+
+    int ret = HttpHeaders::buildHTTPResponseHeaderStruct(responseStr, &header, 
&nbtr);
+    CPPUNIT_ASSERT(ret != 0);
+
+    string *v = header.getValue ("ToJoin", NULL);
+    CPPUNIT_ASSERT(v);
+
+    CPPUNIT_ASSERT(v->find ("a") != string::npos);
+    CPPUNIT_ASSERT(v->find ("b") != string::npos);
+    CPPUNIT_ASSERT(v->find (",") != string::npos);
+    CPPUNIT_ASSERT(v->find ("x") == string::npos);
+  }
+
+  void testValidResponse ()
   {
     HttpResponseHeader header;
     const char * responseStr = "HTTP/1.1 200 Success\r\nContent-Length: 
0\r\n\r\n";
@@ -80,7 +103,7 @@ public:
   }
 
 
-  void testInvalidResponse()
+  void testInvalidResponse ()
   {
     HttpResponseHeader header;
     const char * responseStr = "Not really HTTP response";
@@ -102,21 +125,16 @@ public:
     CPPUNIT_ASSERT_EQUAL(ret, 0);
   }
 
-  void testReset()
+  void testReset ()
   {
     HttpResponseHeader header;
 
     HttpHeaders::resetHTTPResponse(&header);
 
     CPPUNIT_ASSERT(header.ver.length() == 0);
-    CPPUNIT_ASSERT(header.serverName.length() == 0);
-    CPPUNIT_ASSERT(header.contentType.length() == 0);
-    CPPUNIT_ASSERT(header.connection.length() == 0);
-    CPPUNIT_ASSERT(header.cookie.length() == 0);
     CPPUNIT_ASSERT(header.contentLength.length() == 0);
     CPPUNIT_ASSERT(header.errorType.length() == 0);
- }
-
+  }
 
   void testStatusType ()
   {

-----------------------------------------------------------------------

Summary of changes:
 myserver/include/protocol/http/http_response.h    |   23 +---
 myserver/src/http_handler/cgi/cgi.cpp             |    2 +-
 myserver/src/http_handler/http_dir/http_dir.cpp   |    2 +-
 myserver/src/http_handler/http_file/http_file.cpp |    8 +-
 myserver/src/http_handler/mscgi/mscgi_manager.cpp |    4 +-
 myserver/src/protocol/http/env/env.cpp            |    7 +-
 myserver/src/protocol/http/http.cpp               |   30 ++---
 myserver/src/protocol/http/http_headers.cpp       |  153 ++++-----------------
 myserver/src/protocol/http/http_response.cpp      |   69 ---------
 myserver/tests/test_http_response.cpp             |   72 ++++++----
 10 files changed, 99 insertions(+), 271 deletions(-)


hooks/post-receive
-- 
GNU MyServer




reply via email to

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