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.

169 lines
3.9 KiB

  1. #ifndef __SSI_VECTOR_SEND_HXX__
  2. #define __SSI_VECTOR_SEND_HXX__
  3. /*++
  4. Copyright (c) 2001 Microsoft Corporation
  5. Module Name:
  6. ssi_vector_send.hxx
  7. Abstract:
  8. wrapper for VectorSend related buffer manipulation
  9. Segments of final response of stm file processing
  10. are buffered in the SSI_VECTOR_BUFFER to optimize the
  11. "send response" path
  12. Author:
  13. Jaroslad Apr-2001
  14. --*/
  15. class SSI_VECTOR_BUFFER : public CHUNK_BUFFER
  16. {
  17. public:
  18. SSI_VECTOR_BUFFER(
  19. EXTENSION_CONTROL_BLOCK * pECB
  20. )
  21. :
  22. _straFinalHeaders( _abFinalHeaders, sizeof(_abFinalHeaders) ),
  23. _buffVectorElementArray( (BYTE *)_VectorElementArray, sizeof(_VectorElementArray) ),
  24. _pECB( pECB )
  25. {
  26. if ( _stricmp( pECB->lpszMethod, "HEAD" ) == 0 )
  27. {
  28. _fHeadRequest = TRUE;
  29. }
  30. else
  31. {
  32. _fHeadRequest = FALSE;
  33. }
  34. }
  35. HRESULT
  36. Init(
  37. VOID
  38. )
  39. /*++
  40. Routine Description:
  41. initialization before manipulating Vector data or
  42. cleanup after VectorSend completion
  43. Arguments:
  44. None
  45. Return Value:
  46. HRESULT
  47. --*/
  48. {
  49. _fHeadersSent = FALSE;
  50. _fVectorHeadersIncludeContentLength = FALSE;
  51. return Reset();
  52. }
  53. HRESULT
  54. Reset(
  55. VOID
  56. )
  57. {
  58. _cbTotalBytesInVector = 0;
  59. _RespVector.nElementCount = 0;
  60. _RespVector.pszStatus = NULL;
  61. _RespVector.pszHeaders = NULL;
  62. _RespVector.lpElementArray = (HSE_VECTOR_ELEMENT *)_buffVectorElementArray.QueryPtr();
  63. _RespVector.dwFlags = HSE_IO_ASYNC |
  64. HSE_IO_DISCONNECT_AFTER_SEND;
  65. return S_OK;
  66. }
  67. HRESULT
  68. AddVectorHeaders(
  69. IN CHAR * pszHeaders,
  70. IN BOOL fIncludesContentLength = FALSE,
  71. IN CHAR * pszStatus = ""
  72. );
  73. HRESULT
  74. AddToVector(
  75. IN PCHAR pbData,
  76. IN DWORD cbData
  77. );
  78. HRESULT
  79. AddFileChunkToVector(
  80. IN DWORD cbOffset,
  81. IN DWORD cbData,
  82. IN HANDLE hFile
  83. );
  84. HRESULT
  85. CopyToVector(
  86. IN PCHAR pszData,
  87. IN DWORD cchData
  88. );
  89. HRESULT
  90. CopyToVector(
  91. IN STRA& straSource
  92. );
  93. HRESULT
  94. CopyToVector(
  95. IN STRU& struSource
  96. );
  97. HRESULT
  98. VectorSend(
  99. OUT BOOL * pfAsyncPending,
  100. IN BOOL fFinalSend = FALSE
  101. );
  102. DWORD
  103. QueryCurrentNumberOfElements(
  104. VOID
  105. )
  106. {
  107. return _RespVector.nElementCount;
  108. }
  109. private:
  110. // used to generate Content-Length
  111. DWORD _cbTotalBytesInVector;
  112. // VectorHeaders are to be sent only once
  113. BOOL _fHeadersSent;
  114. // AddVectorHeaders will inform if Content-Length was already added
  115. BOOL _fVectorHeadersIncludeContentLength;
  116. // headers string used to add Content-Length:
  117. STRA _straFinalHeaders;
  118. CHAR _abFinalHeaders[ SSI_DEFAULT_RESPONSE_HEADERS_SIZE + 1 ];
  119. // structure for HSE_VECTOR_SEND
  120. HSE_RESPONSE_VECTOR _RespVector;
  121. // part of HSE_RESPONSE_VECTOR
  122. BUFFER _buffVectorElementArray;
  123. HSE_VECTOR_ELEMENT _VectorElementArray[ SSI_DEFAULT_NUM_VECTOR_ELEMENTS ];
  124. // _pECB is needed to be able to perform SSF - VectorSend
  125. EXTENSION_CONTROL_BLOCK * _pECB;
  126. // flag indicating if we are processing HEAD request (then no response body is sent)
  127. BOOL _fHeadRequest;
  128. };
  129. #endif