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. c1a004a4db


From: Giuseppe Scrivano
Subject: [myserver-commit] [SCM] GNU MyServer branch, master, updated. c1a004a4dbe93748127a1bcf09b265cca2dab034
Date: Sat, 26 Sep 2009 20:42:55 +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  c1a004a4dbe93748127a1bcf09b265cca2dab034 (commit)
      from  41ff453f65e602d4cf87cc433556236b6acb217b (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 c1a004a4dbe93748127a1bcf09b265cca2dab034
Author: Giuseppe Scrivano <address@hidden>
Date:   Sat Sep 26 22:42:15 2009 +0200

    Remove some members from the `HttpResponseHeader' struct, leaving their 
definitions in the hash map.

diff --git a/myserver/include/protocol/http/http_response.h 
b/myserver/include/protocol/http/http_response.h
index bc6b901..579f801 100644
--- a/myserver/include/protocol/http/http_response.h
+++ b/myserver/include/protocol/http/http_response.h
@@ -1,7 +1,7 @@
 /* -*- mode: c++ -*- */
 /*
 MyServer
-Copyright (C) 2002, 2003, 2004, 2008 Free Software Foundation, Inc.
+Copyright (C) 2002, 2003, 2004, 2008, 2009 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
@@ -84,15 +84,10 @@ struct HttpResponseHeader : public HttpHeader
        string serverName;
        string contentType;
        string connection;
-       string mimeVer;
        string cookie;
        string contentLength;
        string errorType;
-       string lastModified;
-       string location;
-       string date;
-       string dateExp;
-       string auth;
+
        HashMap<string,HttpResponseHeader::Entry*> other;
   HttpResponseHeader();
   ~HttpResponseHeader();
diff --git a/myserver/src/http_handler/fastcgi/fastcgi.cpp 
b/myserver/src/http_handler/fastcgi/fastcgi.cpp
index 12aef47..59b929b 100644
--- a/myserver/src/http_handler/fastcgi/fastcgi.cpp
+++ b/myserver/src/http_handler/fastcgi/fastcgi.cpp
@@ -751,12 +751,13 @@ int FastCgi::handleHeader (FcgiContext* con, 
FiltersChain* chain, bool* response
 
   if(!con->td->appendOutputs)
   {
-    if(con->td->response.location[0])
-    {
-      *responseCompleted = true;
-      
con->td->http->sendHTTPRedirect((char*)con->td->response.location.c_str());
-      return 0;
-    }
+    string *location = con->td->response.getValue ("Location", NULL);
+    if (location)
+      {
+        *responseCompleted = true;
+        con->td->http->sendHTTPRedirect (location->c_str ());
+        return 0;
+      }
 
     u_long hdrLen = 
HttpHeaders::buildHTTPResponseHeader(con->td->secondaryBuffer->getBuffer(),
                                                          &con->td->response);
diff --git a/myserver/src/http_handler/http_file/http_file.cpp 
b/myserver/src/http_handler/http_file/http_file.cpp
index 98047fe..cc82bd4 100644
--- a/myserver/src/http_handler/http_file/http_file.cpp
+++ b/myserver/src/http_handler/http_file/http_file.cpp
@@ -261,13 +261,13 @@ int HttpFile::send (HttpThreadContext* td, const char 
*filenamePath,
       return td->http->raiseHTTPError(500);
 
     getRFC822GMTTime (lastMT, tmpTime, HTTP_RESPONSE_LAST_MODIFIED_DIM);
-    td->response.lastModified.assign (tmpTime);
+    td->response.setValue ("Last-Modified", tmpTime.c_str ());
 
     HttpRequestHeader::Entry *ifModifiedSince =
       td->request.other.get ("Last-Modified");
 
     if (ifModifiedSince && ifModifiedSince->value->length () &&
-       !ifModifiedSince->value->compare(td->response.lastModified.c_str ()))
+        !ifModifiedSince->value->compare (tmpTime))
       return td->http->sendHTTPNonModified ();
 
     file = Server::getInstance ()->getCachedFiles ()->open (filenamePath);
diff --git a/myserver/src/protocol/http/http.cpp 
b/myserver/src/protocol/http/http.cpp
index 7c8c164..02cb972 100644
--- a/myserver/src/protocol/http/http.cpp
+++ b/myserver/src/protocol/http/http.cpp
@@ -1424,9 +1424,6 @@ int Http::raiseHTTPError (int ID)
           return sendHTTPRedirect (nURL.str ().c_str ());
         }
 
-      getRFC822GMTTime (time, HTTP_RESPONSE_DATE_EXPIRES_DIM);
-      td->response.dateExp.assign (time);
-
       if (useMessagesFiles)
         {
           string page;
diff --git a/myserver/src/protocol/http/http_headers.cpp 
b/myserver/src/protocol/http/http_headers.cpp
index e935b51..1bb3136 100644
--- a/myserver/src/protocol/http/http_headers.cpp
+++ b/myserver/src/protocol/http/http_headers.cpp
@@ -81,14 +81,6 @@ u_long HttpHeaders::buildHTTPResponseHeader (char *str,
       pos += myserver_strlcpy (pos, "\r\n", MAX-(long)(pos-str));
     }
 
-  if (response->lastModified.length ())
-    {
-      pos += myserver_strlcpy (pos,"Last-Modified: ", MAX-(long)(pos-str));
-      pos += myserver_strlcpy (pos, response->lastModified.c_str (),
-                               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));
@@ -135,13 +127,6 @@ u_long HttpHeaders::buildHTTPResponseHeader (char *str,
         }
     }
 
-  if (response->mimeVer.length ())
-    {
-      pos += myserver_strlcpy (pos, "MIME-Version: ", MAX-(long)(pos-str));
-      pos += myserver_strlcpy (pos, response->mimeVer.c_str (), 
MAX-(long)(pos-str));
-      pos += myserver_strlcpy (pos, "\r\n", MAX-(long)(pos-str));
-    }
-
   if (response->contentType.length ())
     {
       pos += myserver_strlcpy (pos, "Content-Type: ", MAX-(long)(pos-str));
@@ -149,35 +134,6 @@ u_long HttpHeaders::buildHTTPResponseHeader (char *str,
       pos += myserver_strlcpy (pos, "\r\n", MAX-(long)(pos-str));
     }
 
-  if (response->date.length ())
-    {
-      pos += myserver_strlcpy(pos, "Date: ", MAX-(long)(pos-str));
-      pos += myserver_strlcpy(pos, response->date.c_str (), 
MAX-(long)(pos-str));
-      pos += myserver_strlcpy(pos, "\r\n", MAX-(long)(pos-str));
-    }
-
-  if (response->dateExp.length ())
-    {
-      pos += myserver_strlcpy (pos, "Expires: ", MAX-(long)(pos-str));
-      pos += myserver_strlcpy (pos, response->dateExp.c_str (), 
MAX-(long)(pos-str));
-      pos += myserver_strlcpy (pos, "\r\n", MAX-(long)(pos-str));
-    }
-
-  if (response->auth.length ())
-    {
-      pos += myserver_strlcpy(pos, "WWW-Authenticate: ", MAX-(long)(pos-str));
-      pos += myserver_strlcpy(pos, response->auth.c_str (), 
MAX-(long)(pos-str));
-      pos += myserver_strlcpy(pos, "\r\n", MAX-(long)(pos-str));
-    }
-
-  if (response->location.length ())
-    {
-      pos += myserver_strlcpy (pos, "Location: ", MAX - (long)(pos - str));
-      pos += myserver_strlcpy (pos, response->location.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 =
@@ -294,23 +250,13 @@ u_long HttpHeaders::buildHTTPRequestHeader (char * 
str,HttpRequestHeader* reques
  */
 void HttpHeaders::buildDefaultHTTPResponseHeader(HttpResponseHeader* response)
 {
-  string date;
   resetHTTPResponse(response);
-  /*!
-   * By default use:
-   * -# the MIME type of the page equal to text/html.
-   * -# the version of the HTTP protocol to 1.1.
-   * -# the date of the page and the expire date to the current time.
-   * -# set the name of the server.
-   * -# set the page that it is not an error page.
-   */
+
   response->contentType.assign ("text/html");
   response->ver.assign ("HTTP/1.1");
-  getRFC822GMTTime(date,HTTP_RESPONSE_DATE_DIM);
-  response->date.assign (date);
-  response->dateExp.assign (date);
+
   response->serverName.assign ("GNU MyServer ");
-  response->serverName.append(MYSERVER_VERSION);
+  response->serverName.append (MYSERVER_VERSION);
 }
 
 /*!
@@ -1089,28 +1035,6 @@ int HttpHeaders::buildHTTPResponseHeaderStruct(const 
char *input,
         if (token)
           response->serverName.assign (token);
       }
-    else if (!strcmpi(command,"Location"))
-      {
-        token = strtok (NULL, "\r\n\0" );
-        lineControlled = 1;
-
-        while (token && *token == ' ')
-          token++;
-
-        if (token)
-          response->location.assign (token);
-      }
-    else if (!strcmpi(command,"Last-Modified"))
-      {
-        token = strtok (NULL, "\r\n\0" );
-        lineControlled = 1;
-
-        while (token && *token == ' ')
-          token++;
-
-        if (token)
-          response->lastModified.assign (token);
-    }
     else if (!strcmpi(command,"Status"))
       {
         token = strtok (NULL, "\r\n\0" );
@@ -1124,17 +1048,6 @@ int HttpHeaders::buildHTTPResponseHeaderStruct(const 
char *input,
           if (token)
             response->httpStatus = atoi(token);
       }
-    else if (!strcmpi(command,"Date"))
-      {
-        token = strtok (NULL, "\r\n\0" );
-        lineControlled = 1;
-
-        while (token && *token == ' ')
-          token++;
-
-        if (token)
-          response->date.assign (token);
-      }
     else if (!strcmpi(command,"Content-Type"))
       {
         token = strtok (NULL, "\r\n\0" );
@@ -1146,17 +1059,6 @@ int HttpHeaders::buildHTTPResponseHeaderStruct(const 
char *input,
         if (token)
           response->contentType.assign (token);
       }
-    else if (!strcmpi(command,"MIME-Version"))
-      {
-        token = strtok (NULL, "\r\n\0" );
-        lineControlled = 1;
-
-        while (token && *token == ' ')
-          token++;
-
-        if (token)
-          response->mimeVer.assign (token);
-      }
     else if (!strcmpi(command,"Set-Cookie"))
       {
         token = strtok (NULL, "\r\n\0" );
@@ -1190,13 +1092,7 @@ int HttpHeaders::buildHTTPResponseHeaderStruct(const 
char *input,
         if (token)
           response->connection.assign (token);
       }
-    else if (!strcmpi (command,"Expires"))
-      {
-        token = strtok (NULL, "\r\n\0" );
-        lineControlled = 1;
-        if (token)
-          response->dateExp.assign (token);
-      }
+
     /*
      *If the line is not controlled arrive with the token
      *at the end of the line.
diff --git a/myserver/src/protocol/http/http_response.cpp 
b/myserver/src/protocol/http/http_response.cpp
index b6876d3..2749859 100644
--- a/myserver/src/protocol/http/http_response.cpp
+++ b/myserver/src/protocol/http/http_response.cpp
@@ -1,18 +1,18 @@
 /*
-MyServer
-Copyright (C) 2005, 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/>.
+  MyServer
+  Copyright (C) 2005, 2007, 2008, 2009 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"
@@ -25,7 +25,7 @@ using namespace std;
 /*!
  *Create the object.
  */
-HttpResponseHeader::HttpResponseHeader()
+HttpResponseHeader::HttpResponseHeader ()
 {
   free();
 }
@@ -34,10 +34,10 @@ HttpResponseHeader::HttpResponseHeader()
 /*!
  *Destroy the object.
  */
-HttpResponseHeader::~HttpResponseHeader()
+HttpResponseHeader::~HttpResponseHeader ()
 {
-  HashMap<string, HttpResponseHeader::Entry*>::Iterator it = other.begin();
-  for(;it != other.end(); it++)
+  HashMap<string, HttpResponseHeader::Entry*>::Iterator it = other.begin ();
+  for (;it != other.end(); it++)
     delete (*it);
 }
 
@@ -46,234 +46,146 @@ HttpResponseHeader::~HttpResponseHeader()
  */
 void HttpResponseHeader::free()
 {
-  ver.clear();
-  serverName.clear();
-  contentType.clear();
-  connection.clear();
-  mimeVer.clear();
-  cookie.clear();
-  contentLength.clear();
-  errorType.clear();
-  location.clear();
-  date.clear();
-  auth.clear();
-  dateExp.clear();
-  {
-    HashMap<string, HttpResponseHeader::Entry*>::Iterator it = other.begin();
-    for(;it != other.end(); it++){
-      delete (*it);
-    }
-  }
-  other.clear();
-  lastModified.clear();
+  ver.clear ();
+  serverName.clear ();
+  contentType.clear ();
+  connection.clear ();
+  cookie.clear ();
+  contentLength.clear ();
+  errorType.clear ();
+
+  HashMap<string, HttpResponseHeader::Entry*>::Iterator it = other.begin ();
+  for (;it != other.end (); it++)
+    delete (*it);
+
+  other.clear ();
 }
 
 /*!
  *Get the value of the [name] field.
  */
-string* HttpResponseHeader::getValue(const char* name, string* out)
+string* HttpResponseHeader::getValue (const char* name, string* out)
 {
-  if(!strcmpi(name, "Ver"))
-  {
-    if(out)
-      out->assign(ver.c_str());
-    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, "MIME-Version"))
-  {
-    if(out)
-      out->assign(mimeVer.c_str());
-    return &mimeVer;
-  }
-
-  if(!strcmpi(name, "Cookie"))
-  {
-    if(out)
-      out->assign(cookie.c_str());
-    return &cookie;
-  }
+  if (!strcmpi (name, "Ver"))
+    {
+      if (out)
+        out->assign (ver.c_str ());
+      return &ver;
+    }
 
-  if(!strcmpi(name, "Content-Length"))
-  {
-    if(out)
-      out->assign(contentLength.c_str());
-    return &contentLength;
-  }
+  if (!strcmpi (name, "Server"))
+    {
+      if (out)
+        out->assign (serverName.c_str ());
+      return &ver;
+    }
 
-  if(!strcmpi(name, "Last-Modified"))
-  {
-    if(out)
-      out->assign(lastModified.c_str());
-    return &lastModified;
-  }
+  if (!strcmpi (name, "Content-Type"))
+    {
+      if (out)
+        out->assign (contentType.c_str ());
+      return &contentType;
+    }
 
-  if(!strcmpi(name, "Location"))
-  {
-    if(out)
-      out->assign(location.c_str());
-    return &location;
-  }
+  if (!strcmpi (name, "Connection"))
+    {
+      if (out)
+        out->assign (connection.c_str ());
+      return &connection;
+    }
 
-  if(!strcmpi(name, "Date"))
-  {
-    if(out)
-      out->assign(date.c_str());
-    return &date;
-  }
+  if (!strcmpi (name, "Content-Type"))
+    {
+      if (out)
+        out->assign (contentType.c_str ());
+      return &contentType;
+    }
 
-  if(!strcmpi(name, "Date-Expires"))
-  {
-    if(out)
-      out->assign(dateExp.c_str());
-    return &dateExp;
-  }
+  if (!strcmpi (name, "Cookie"))
+    {
+      if (out)
+        out->assign (cookie.c_str ());
+      return &cookie;
+    }
 
-  if(!strcmpi(name, "WWW-Authenticate"))
-  {
-    if(out)
-      out->assign(auth.c_str());
-    return &auth;
-  }
+  if (!strcmpi (name, "Content-Length"))
+    {
+      if (out)
+        out->assign (contentLength.c_str ());
+      return &contentLength;
+    }
 
-  {
-    HttpResponseHeader::Entry *e = other.get(name);
-    if(e)
+  HttpResponseHeader::Entry *e = other.get(name);
+  if (e)
     {
-      if(out)
-        out->assign(*(e->value));
+      if (out)
+        out->assign (*(e->value));
       return e->value;
     }
-    return 0;
-  }
+  return 0;
 }
 
-
 /*!
  *Set the value of the [name] field to [in].
  */
-string* HttpResponseHeader::setValue(const char* name, const char* in)
+string* HttpResponseHeader::setValue (const char* name, const char* in)
 {
-  if(!strcmpi(name, "Ver"))
-  {
-    ver.assign(in);
-    return &ver;
-  }
-
-  if(!strcmpi(name, "Server"))
-  {
-    serverName.assign(in);
-    return &ver;
-  }
-
-  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, "MIME-Version"))
-  {
-    mimeVer.assign(in);
-    return &mimeVer;
-  }
+  if (!strcmpi (name, "Ver"))
+    {
+      ver.assign (in);
+      return &ver;
+    }
 
-  if(!strcmpi(name, "Cookie"))
-  {
-    cookie.assign(in);
-    return &cookie;
-  }
+  if (!strcmpi (name, "Server"))
+    {
+      serverName.assign (in);
+      return &serverName;
+    }
 
-  if(!strcmpi(name, "Content-Length"))
-  {
-    contentLength.assign(in);
-    return &contentLength;
-  }
+  if (!strcmpi (name, "Content-Type"))
+    {
+      contentType.assign (in);
+      return &contentType;
+    }
 
-  if(!strcmpi(name, "Last-Modified"))
-  {
-    lastModified.assign(in);
-    return &lastModified;
-  }
+  if (!strcmpi (name, "Connection"))
+    {
+      connection.assign (in);
+      return &connection;
+    }
 
-  if(!strcmpi(name, "Location"))
-  {
-    location.assign(in);
-    return &location;
-  }
+  if (!strcmpi (name, "Content-Type"))
+    {
+      contentType.assign (in);
+      return &contentType;
+    }
 
-  if(!strcmpi(name, "Date"))
-  {
-    date.assign(in);
-    return &date;
-  }
+  if (!strcmpi (name, "Cookie"))
+    {
+      cookie.assign (in);
+      return &cookie;
+    }
 
-  if(!strcmpi(name, "Date-Expires"))
-  {
-    dateExp.assign(in);
-    return &dateExp;
-  }
+  if (!strcmpi (name, "Content-Length"))
+    {
+      contentLength.assign (in);
+      return &contentLength;
+    }
 
-  if(!strcmpi(name, "WWW-Authenticate"))
   {
-    auth.assign(in);
-    return &auth;
-  }
-
- {
-   HttpResponseHeader::Entry *e = other.get(name);
-   if(e)
-   {
-     e->value->assign(in);
-     return (e->value);
-   }
-   else
-   {
-     e = new HttpResponseHeader::Entry;
-     e->name->assign(name);
-     e->value->assign(in);
-     other.put(*e->name, e);
-   }
+    HttpResponseHeader::Entry *e = other.get(name);
+    if (e)
+      {
+        e->value->assign (in);
+        return (e->value);
+      }
+    else
+      {
+        e = new HttpResponseHeader::Entry;
+        e->name->assign (name);
+        e->value->assign (in);
+        other.put (*e->name, e);
+      }
 
     return 0;
   }
@@ -283,7 +195,7 @@ string* HttpResponseHeader::setValue(const char* name, 
const char* in)
  *Get the kind of HTTP status code specified by the httpStatus variable.
  *\return the HTTP status kind.
  */
-int HttpResponseHeader::getStatusType()
+int HttpResponseHeader::getStatusType ()
 {
   if (httpStatus < 200)
     return HttpResponseHeader::INFORMATIONAL;
diff --git a/myserver/tests/test_http_response.cpp 
b/myserver/tests/test_http_response.cpp
index 9f9b649..d8af7a9 100644
--- a/myserver/tests/test_http_response.cpp
+++ b/myserver/tests/test_http_response.cpp
@@ -112,14 +112,9 @@ public:
     CPPUNIT_ASSERT(header.serverName.length() == 0);
     CPPUNIT_ASSERT(header.contentType.length() == 0);
     CPPUNIT_ASSERT(header.connection.length() == 0);
-    CPPUNIT_ASSERT(header.mimeVer.length() == 0);
     CPPUNIT_ASSERT(header.cookie.length() == 0);
     CPPUNIT_ASSERT(header.contentLength.length() == 0);
     CPPUNIT_ASSERT(header.errorType.length() == 0);
-    CPPUNIT_ASSERT(header.location.length() == 0);
-    CPPUNIT_ASSERT(header.date.length() == 0);
-    CPPUNIT_ASSERT(header.auth.length() == 0);
-    CPPUNIT_ASSERT(header.dateExp.length() == 0);
  }
 
 

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

Summary of changes:
 myserver/include/protocol/http/http_response.h    |    9 +-
 myserver/src/http_handler/fastcgi/fastcgi.cpp     |   13 +-
 myserver/src/http_handler/http_file/http_file.cpp |    4 +-
 myserver/src/protocol/http/http.cpp               |    3 -
 myserver/src/protocol/http/http_headers.cpp       |  112 +-------
 myserver/src/protocol/http/http_response.cpp      |  346 ++++++++-------------
 myserver/tests/test_http_response.cpp             |    5 -
 7 files changed, 144 insertions(+), 348 deletions(-)


hooks/post-receive
-- 
GNU MyServer




reply via email to

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