Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

194 lines
4.5 KiB

  1. #ifndef _STATICFILE_HXX_
  2. #define _STATICFILE_HXX_
  3. #include <stringau.hxx>
  4. class W3_STATIC_FILE_HANDLER : public W3_HANDLER
  5. {
  6. public:
  7. W3_STATIC_FILE_HANDLER( W3_CONTEXT * pW3Context )
  8. : W3_HANDLER( pW3Context ),
  9. m_pOpenFile( NULL ),
  10. m_pFooterDocument( NULL )
  11. {
  12. }
  13. ~W3_STATIC_FILE_HANDLER()
  14. {
  15. if ( m_pOpenFile != NULL )
  16. {
  17. m_pOpenFile->DereferenceCacheEntry();
  18. m_pOpenFile = NULL;
  19. }
  20. if ( m_pFooterDocument != NULL )
  21. {
  22. m_pFooterDocument->DereferenceCacheEntry();
  23. m_pFooterDocument = NULL;
  24. }
  25. }
  26. WCHAR *
  27. QueryName(
  28. VOID
  29. )
  30. {
  31. return L"StaticFileHandler";
  32. }
  33. CONTEXT_STATUS
  34. DoWork(
  35. VOID
  36. );
  37. static
  38. HRESULT
  39. Initialize(
  40. VOID
  41. );
  42. static
  43. VOID
  44. Terminate(
  45. VOID
  46. )
  47. {
  48. if ( sm_pstrRangeContentType != NULL )
  49. {
  50. delete sm_pstrRangeContentType;
  51. sm_pstrRangeContentType = NULL;
  52. }
  53. if ( sm_pstrRangeMidDelimiter != NULL )
  54. {
  55. delete sm_pstrRangeMidDelimiter;
  56. sm_pstrRangeMidDelimiter = NULL;
  57. }
  58. if ( sm_pstrRangeEndDelimiter != NULL )
  59. {
  60. delete sm_pstrRangeEndDelimiter;
  61. sm_pstrRangeEndDelimiter = NULL;
  62. }
  63. if ( sm_pachStaticFileHandlers != NULL )
  64. {
  65. delete sm_pachStaticFileHandlers;
  66. sm_pachStaticFileHandlers = NULL;
  67. }
  68. }
  69. BOOL
  70. QueryIsUlCacheable(
  71. VOID
  72. )
  73. {
  74. return TRUE;
  75. }
  76. HRESULT
  77. SetupUlCachedResponse(
  78. W3_CONTEXT * pW3Context,
  79. HTTP_CACHE_POLICY *pCachePolicy
  80. );
  81. VOID *
  82. operator new(
  83. size_t uiSize,
  84. VOID * pPlacement
  85. )
  86. {
  87. W3_CONTEXT * pContext;
  88. pContext = (W3_CONTEXT*) pPlacement;
  89. DBG_ASSERT( pContext != NULL );
  90. DBG_ASSERT( pContext->CheckSignature() );
  91. return pContext->ContextAlloc( (UINT)uiSize );
  92. }
  93. VOID
  94. operator delete(
  95. VOID * pStaticFileHandler
  96. )
  97. {
  98. }
  99. private:
  100. W3_FILE_INFO * m_pOpenFile;
  101. W3_FILE_INFO * m_pFooterDocument;
  102. STRA m_strFooterString;
  103. STRA m_strDirlistResponse;
  104. BUFFER_CHAIN m_RangeBufferChain;
  105. FILE_CACHE_ASYNC_CONTEXT m_AsyncContext;
  106. static STRA * sm_pstrRangeContentType;
  107. static STRA * sm_pstrRangeMidDelimiter;
  108. static STRA * sm_pstrRangeEndDelimiter;
  109. static ALLOC_CACHE_HANDLER* sm_pachStaticFileHandlers;
  110. static DWORD sm_dwMaxRangeAllowed;
  111. static
  112. VOID
  113. FileOpenCallback(PVOID pContext,
  114. HRESULT hr);
  115. CONTEXT_STATUS
  116. RealDoWork(W3_FILE_INFO *pFileInfo,
  117. HRESULT hr);
  118. HRESULT
  119. FileDoWork(
  120. W3_CONTEXT * pW3Context,
  121. W3_FILE_INFO * pFileInfo
  122. );
  123. HRESULT
  124. RangeDoWork(
  125. W3_CONTEXT * pW3Context,
  126. W3_FILE_INFO * pFileInfo,
  127. BOOL * pfHandled
  128. );
  129. HRESULT
  130. CacheValidationDoWork(
  131. W3_CONTEXT * pW3Context,
  132. W3_FILE_INFO * pFileInfo,
  133. BOOL * pfHandled
  134. );
  135. HRESULT
  136. DirectoryDoWork(
  137. W3_CONTEXT * pW3Context,
  138. BOOL * pfAsyncPending
  139. );
  140. HRESULT
  141. HandleDefaultLoad(
  142. W3_CONTEXT * pW3Context,
  143. BOOL * pfHandled,
  144. BOOL * pfAsyncPending
  145. );
  146. HRESULT
  147. HandleDirectoryListing(
  148. W3_CONTEXT * pW3Context,
  149. BOOL * pfHandled
  150. );
  151. HRESULT
  152. MapFileDoWork(
  153. W3_CONTEXT * pW3Context,
  154. W3_FILE_INFO * pFileInfo,
  155. BOOL * pfHandled
  156. );
  157. HRESULT SearchMapFile(LPCSTR pszFileContents,
  158. const DWORD cbFileSize,
  159. const int x,
  160. const int y,
  161. STRA *pstrTarget);
  162. };
  163. #endif