[prev in list] [next in list] [prev in thread] [next in thread] 

List:       helix-server-cvs
Subject:    [Server-cvs]
From:       dcollins () helixcommunity ! org
Date:       2009-10-14 23:12:59
Message-ID: 200910150023.n9F0NHxD025474 () mailer ! progressive-comp ! com
[Download RAW message or body]

Update of /cvsroot/server/protocol/http
In directory cvs01.internal.helixcommunity.org:/tmp/cvs-serv27665/server/protocol/http


Modified Files:
	httpbaseproto.cpp httpprot.cpp 
Log Message:
Synopsis
========
Improves Helix Server support for HTTP/1.1

Branches: HEAD
Reviewer: Jamie


Description
===========

This provides a few updates to the server's HTTP/1.1 support:

1) HTTP clients sending valid but unsupported HTTP requests were
not being sent a response but having their connection terminated,
since these requests never made it past the HTTP protocol sniffer.
By adding several known HTTP messages we can provide better responses.
I noticed this since VLC sends PROPFIND requests, we should send them
a 405 Method Not Allowed, along with list of supported messages.

2) The header used to communicate the supported HTTP messages was named
incorrectly.  I was using the RTSP-style name "Public", whereas for HTTP
the header is called "Allow".

3) Forcing content to be non-cacheable was made configurable.  By default
we send the no-cache headers, but if you add the following top-level
config item to the config file we will not force this (they will still
be used for Admin system requests.)

    <Var HTTPCacheable="0"/>

This latter item will probably be extended later to be mount-point
specific.  For now it is server-wide.


Files Affected
==============

server/engine/netio/http_sniffer.cpp
server/protocol/http/httpprot.cpp


Testing Performed
=================

Unit Tests:
- N/A.

Integration Tests:
- Tested in tandem with iPhone byte-range support.
- Tested the 405 response with VLC.

Leak Tests:
- Not performed.

Performance Tests:
- Not performed.

Platforms Tested: linux-rhel5-i686
Build verified: linux-rhel5-i686


QA Hints
========
* N/A


Index: httpprot.cpp
===================================================================
RCS file: /cvsroot/server/protocol/http/httpprot.cpp,v
retrieving revision 1.61
retrieving revision 1.62
diff -u -d -r1.61 -r1.62
--- httpprot.cpp	14 Oct 2009 20:47:52 -0000	1.61
+++ httpprot.cpp	14 Oct 2009 23:12:57 -0000	1.62
@@ -256,6 +256,8 @@
 STDMETHODIMP_(void)
 HTTPProtocol::OnRequest(HTTPRequestMessage* pMsg)
 {
+    HTTPResponseMessage* pResp = NULL;
+
     HX_RELEASE(m_pRequest);
     HX_VECTOR_DELETE(m_pszMimeType);
     m_posting = FALSE;
@@ -335,17 +337,27 @@
     //    break;
 #endif
 
-    default:
+    case HTTPMessage::T_UNKNOWN:
         // We can only get these on persistent connections since
         // the first message needs to get past the HTTP protocol sniffer.
         // If it doesn't know what it is and no other protocol claims it,
         // we won't make it here, the server will just close the socket.
-        HTTPResponseMessage* pResp = makeResponseMessage("501");
+        pResp = makeResponseMessage("501");
         DPRINTF(D_INFO, ("HTTP: 501 Not Implemented\n"));
         if (SUCCEEDED(sendResponse(pResp)))
 	    SetStatus(501);
         HX_DELETE(pResp);
         break;
+
+    default:
+        // These are known HTTP messages which we do not support
+        pResp = makeResponseMessage("405");
+        pResp->addHeader("Allow", HTTP11_REQUESTS_SUPPORTED);
+        DPRINTF(D_INFO, ("HTTP: 405 Method Not Allowed: %s\n", pMsg->tagStr()));
+        if (SUCCEEDED(sendResponse(pResp)))
+           SetStatus(405);
+        HX_DELETE(pResp);
+        break;
     }
 }
 
@@ -897,17 +909,23 @@
     }
 #endif
 
-    // all content should be listed as non-cacheable
+    // all content should be listed as non-cacheable unless configured otherwise
 #ifdef HELIX_FEATURE_SERVER_HTTP11
-    if (m_major_version == 1 && m_minor_version == 1)
+    Client* pClient = m_pDemux->GetClient();
+    INT32 ulCacheable = 0;
+    pClient->m_pProc->pc->registry->GetInt("config.HTTPCacheable", &ulCacheable, \
pClient->m_pProc); +    if (ulCacheable == 0)
     {
-        pMsg->addHeader("Cache-Control", "no-store, no-cache, must-revalidate, \
post-check=0, pre-check=0"); +        if (m_major_version == 1 && m_minor_version == \
1) +        {
+            pMsg->addHeader("Cache-Control", "no-store, no-cache, must-revalidate, \
post-check=0, pre-check=0"); +        }
+        // This header is for HTTP/1.0, but always add it even if this
+        // is HTTP/1.1 in case some proxy in-between or client doesn't
+        // understand Cache-Control: no-store.
+        pMsg->addHeader("Pragma", "no-cache");
     }
 #endif
-    // This header is for HTTP/1.0, but always add it even if this
-    // is HTTP/1.1 in case some proxy in-between or client doesn't
-    // understand Cache-Control: no-store.
-    pMsg->addHeader("Pragma", "no-cache");
 
     UINT32 ulErrNo = atoi(pErrNo);
 
@@ -1305,7 +1323,7 @@
     UTCTimeRep timeNow;
     pResp->addHeader("Date",   timeNow.asRFC1123String());
     SetVersionHeader(pResp);
-    pResp->addHeader("Public", HTTP11_REQUESTS_SUPPORTED);
+    pResp->addHeader("Allow", HTTP11_REQUESTS_SUPPORTED);
     pResp->addHeader("Content-Length", "0");
 
     if (SUCCEEDED(sendResponse(pResp)))

Index: httpbaseproto.cpp
===================================================================
RCS file: /cvsroot/server/protocol/http/httpbaseproto.cpp,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- httpbaseproto.cpp	13 Oct 2009 18:44:41 -0000	1.8
+++ httpbaseproto.cpp	14 Oct 2009 23:12:57 -0000	1.9
@@ -345,6 +345,31 @@
             method = (const char*)"COPY";
         }
         break;
+        case HTTPMessage::T_CONNECT:
+        {
+            method = (const char*)"CONNECT";
+        }
+        break;
+        case HTTPMessage::T_PROPFIND:
+        {
+            method = (const char*)"PROPFIND";
+        }
+        break;
+        case HTTPMessage::T_MKCOL:
+        {
+            method = (const char*)"MKCOL";
+        }
+        break;
+        case HTTPMessage::T_LOCK:
+        {
+            method = (const char*)"LOCK";
+        }
+        break;
+        case HTTPMessage::T_UNLOCK:
+        {
+            method = (const char*)"UNLOCK";
+        }
+        break;
 #endif
         default:
         {


_______________________________________________
Server-cvs mailing list
Server-cvs@helixcommunity.org
http://lists.helixcommunity.org/mailman/listinfo/server-cvs


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic