rtpproxy.cpp
上传用户:zhongxx05
上传日期:2007-06-06
资源大小:33641k
文件大小:3k
源码类别:

Symbian

开发平台:

C/C++

  1. /*
  2.  *   This routine should contain RTSP related utility functions.
  3.  */
  4. #include "hxtypes.h"
  5. #include "hxresult.h"
  6. #include "hxcom.h"  
  7. #include "hxcomm.h"
  8. #include "hxcore.h"
  9. #include "hxfiles.h"
  10. // pncont
  11. #include "hxstring.h"
  12. #include "chxpckts.h"
  13. #include "mimescan.h"
  14. #include "rtpproxy.h"
  15. BOOL proxiesSupportFlash4(IHXBuffer* pViaStr)
  16. {
  17.     BOOL cachesFlash4 = TRUE;
  18.     HX_RESULT err = HXR_FAIL;
  19.     // check via header to verify that al proxies support RS 8.0 features
  20.     // (ie latest flash datatype)
  21.     const char* pHeaderValues = (const char*) pViaStr->GetBuffer();
  22.     MIMEInputStream input(pHeaderValues, strlen(pHeaderValues));
  23.     MIMEScanner scanner(input);
  24.     CHXString strViaFinal;
  25.     MIMEToken nextTok = scanner.nextToken(",");
  26.     while(nextTok.hasValue() || (nextTok.lastChar() != MIMEToken::T_EOL) && (nextTok.lastChar() != MIMEToken::T_EOF))
  27.     {
  28.         if (nextTok.hasValue())
  29.         {
  30.             CHXString strViaToken = nextTok.value();
  31.             // per spec there should be a protocol/version string there, ie "RTSP/1.0"
  32.             // or "1.0". Old RealProxies used non-compliant psuedonym only!
  33.             int nVerOffset = strViaToken.Find("RealProxy Version");
  34.             if(nVerOffset == -1)
  35.             {
  36.                 // oops, there is a proxy here that does not support flash 4
  37.                 cachesFlash4 = FALSE;
  38.                 break;
  39.             }
  40.         }
  41.         
  42.         nextTok = scanner.nextToken(",");
  43.     }
  44.     return cachesFlash4;
  45. }
  46. void AddNoCacheHeader(IUnknown* pContext, IHXRequest* pRequest)
  47. {
  48.     // Add the "Cache-Control: no-cache" response header so that Proxies
  49.     // don't think they can cache our dynamically generated content
  50.     IHXCommonClassFactory* pCCF;
  51.     if (pContext && pRequest)
  52.     {
  53. pContext->QueryInterface(IID_IHXCommonClassFactory,
  54.     (void**)&pCCF);
  55.         IHXValues* pResHeaders = NULL;
  56.         pRequest->GetResponseHeaders(pResHeaders);
  57.         if (!pResHeaders)
  58.         {
  59.             IUnknown* pUnknown = NULL;
  60.             pCCF->CreateInstance(CLSID_IHXKeyValueList,
  61.                 (void**)&pUnknown);
  62.             pUnknown->QueryInterface(IID_IHXValues,
  63.                 (void**)&pResHeaders);
  64.             pRequest->SetResponseHeaders(pResHeaders);
  65.             HX_RELEASE(pUnknown);
  66.         }
  67.         IHXBuffer* pNoCache = NULL;
  68.         pCCF->CreateInstance(CLSID_IHXBuffer,
  69.             (void**)&pNoCache);
  70.         pNoCache->Set((UCHAR*)"no-cache", 9);
  71.         pResHeaders->SetPropertyCString("Pragma", pNoCache);
  72.         HX_RELEASE(pNoCache);
  73.         HX_RELEASE(pResHeaders);
  74. HX_RELEASE(pCCF);
  75.     }
  76. }