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.

255 lines
6.4 KiB

  1. /*++
  2. Copyright (c) 2001 Microsoft Corporation
  3. Module Name:
  4. internalapi.cxx
  5. Abstract:
  6. Contains internal (unexposed) codes for getting/setting various properties of
  7. the HTTP_REQUEST_HANDLE_OBJECT object.
  8. Used mainly by the WinHTTP caching layer to obtain and set extended information
  9. not possible through the WinHTTP C++ API.
  10. The cache should not be made aware about the internal class structure of
  11. WinHTTP (to make a cleaner separation between the core WinHTTP layer and
  12. the caching layer), therefore the cache must call these internal functions to
  13. access internal WinHTTP functionalities.
  14. Environment:
  15. Win32 user-mode DLL
  16. Revision History:
  17. --*/
  18. #include <wininetp.h>
  19. #include "internalapi.hxx"
  20. BOOL InternalQueryOptionA(
  21. IN HINTERNET hInternet,
  22. IN DWORD dwOption,
  23. IN OUT LPDWORD lpdwResult
  24. )
  25. {
  26. DEBUG_ENTER((DBG_CACHE,
  27. Bool,
  28. "InternalQueryOptionA",
  29. "%#x, %d, %d",
  30. hInternet,
  31. dwOption,
  32. *lpdwResult));
  33. BOOL fSuccess;
  34. DWORD dwError;
  35. HINTERNET_HANDLE_TYPE handleType;
  36. HINTERNET hObjectMapped = NULL;
  37. HTTP_REQUEST_HANDLE_OBJECT* pReq;
  38. // map the handle
  39. dwError = MapHandleToAddress(hInternet, (LPVOID *)&hObjectMapped, FALSE);
  40. if (dwError == ERROR_SUCCESS) {
  41. hInternet = hObjectMapped;
  42. dwError = RGetHandleType(hInternet, &handleType);
  43. }
  44. if (dwError != ERROR_SUCCESS) {
  45. goto quit;
  46. }
  47. dwError = ERROR_INVALID_OPERATION;
  48. if (handleType == TypeHttpRequestHandle)
  49. pReq = (HTTP_REQUEST_HANDLE_OBJECT *) hInternet;
  50. else
  51. goto quit;
  52. if (pReq == NULL)
  53. goto quit;
  54. switch (dwOption)
  55. {
  56. case WINHTTP_OPTION_REQUEST_FLAGS:
  57. *lpdwResult = pReq->GetOpenFlags();
  58. break;
  59. case WINHTTP_OPTION_CACHE_FLAGS:
  60. *lpdwResult = pReq->GetInternetOpenFlags();
  61. break;
  62. default:
  63. break;
  64. }
  65. dwError = ERROR_SUCCESS;
  66. quit:
  67. if (hObjectMapped != NULL) {
  68. DereferenceObject((LPVOID)hObjectMapped);
  69. }
  70. if (dwError = ERROR_SUCCESS)
  71. fSuccess = TRUE;
  72. else
  73. fSuccess = FALSE;
  74. DEBUG_LEAVE(fSuccess);
  75. return fSuccess;
  76. }
  77. DWORD InternalReplaceResponseHeader(
  78. IN HINTERNET hRequest,
  79. IN DWORD dwQueryIndex,
  80. IN LPSTR lpszHeaderValue,
  81. IN DWORD dwHeaderValueLength,
  82. IN DWORD dwIndex,
  83. IN DWORD dwFlags
  84. )
  85. {
  86. DEBUG_ENTER((DBG_CACHE,
  87. Dword,
  88. "InternalReplaceResponseHeaders",
  89. "%#x, %d",
  90. hRequest,
  91. dwQueryIndex));
  92. // should include type checking. Right now this API is relying on the user
  93. // passing a Request handle
  94. DWORD fResult;
  95. HTTP_REQUEST_HANDLE_OBJECT * pRequest = (HTTP_REQUEST_HANDLE_OBJECT *)hRequest;
  96. fResult = pRequest->ReplaceResponseHeader(
  97. dwQueryIndex,
  98. lpszHeaderValue,
  99. dwHeaderValueLength,
  100. dwIndex,
  101. dwFlags);
  102. DEBUG_LEAVE(fResult);
  103. return fResult;
  104. }
  105. DWORD InternalAddResponseHeader(
  106. IN HINTERNET hRequest,
  107. IN DWORD dwHeaderIndex,
  108. IN LPSTR lpszHeader,
  109. IN DWORD dwHeaderLength
  110. )
  111. {
  112. DEBUG_ENTER((DBG_CACHE,
  113. Dword,
  114. "InternalAddResponseHeaders",
  115. "%#x",
  116. hRequest));
  117. // should include type checking. Right now this API is relying on the user
  118. // passing a Request handle
  119. DWORD fResult;
  120. HTTP_REQUEST_HANDLE_OBJECT * pRequest = (HTTP_REQUEST_HANDLE_OBJECT *)hRequest;
  121. fResult = pRequest->AddInternalResponseHeader(
  122. dwHeaderIndex,
  123. lpszHeader,
  124. dwHeaderLength
  125. );
  126. DEBUG_LEAVE(fResult);
  127. return fResult;
  128. }
  129. DWORD InternalCreateResponseHeaders(
  130. IN HINTERNET hRequest,
  131. IN OUT LPSTR* ppszBuffer,
  132. IN DWORD dwBufferLength
  133. )
  134. {
  135. DEBUG_ENTER((DBG_CACHE,
  136. Dword,
  137. "InternalCreateResponseHeaders",
  138. "%#x",
  139. hRequest));
  140. // should include type checking. Right now this API is relying on the user
  141. // passing a Request handle
  142. DWORD fResult;
  143. HTTP_REQUEST_HANDLE_OBJECT * pRequest = (HTTP_REQUEST_HANDLE_OBJECT *)hRequest;
  144. fResult = pRequest->CreateResponseHeaders(
  145. ppszBuffer,
  146. dwBufferLength);
  147. DEBUG_LEAVE(fResult);
  148. return fResult;
  149. }
  150. BOOL InternalIsResponseHeaderPresent(
  151. IN HINTERNET hRequest,
  152. IN DWORD dwQueryIndex
  153. )
  154. {
  155. DEBUG_ENTER((DBG_CACHE,
  156. Bool,
  157. "InternalIsResponseHeadersPresent",
  158. "%#x, %d",
  159. hRequest,
  160. dwQueryIndex));
  161. // should include type checking. Right now this API is relying on the user
  162. // passing a Request handle
  163. BOOL fResult;
  164. HTTP_REQUEST_HANDLE_OBJECT * pRequest = (HTTP_REQUEST_HANDLE_OBJECT *)hRequest;
  165. fResult = pRequest->IsResponseHeaderPresent(dwQueryIndex);
  166. DEBUG_LEAVE(fResult);
  167. return fResult;
  168. }
  169. BOOL InternalIsResponseHttp1_1(
  170. IN HINTERNET hRequest
  171. )
  172. {
  173. DEBUG_ENTER((DBG_CACHE,
  174. Bool,
  175. "InternalIsResponseHttp1_1",
  176. "%#x",
  177. hRequest));
  178. // should include type checking. Right now this API is relying on the user
  179. // passing a Request handle
  180. BOOL fResult;
  181. fResult = ((HTTP_REQUEST_HANDLE_OBJECT *)hRequest)->IsResponseHttp1_1();
  182. DEBUG_LEAVE(fResult);
  183. return fResult;
  184. }
  185. VOID InternalReuseHTTP_Request_Handle_Object(
  186. IN HINTERNET hRequest
  187. )
  188. {
  189. DEBUG_ENTER((DBG_CACHE,
  190. None,
  191. "InternalReuseHTTP_Request_Handle_Object",
  192. "%#x",
  193. hRequest));
  194. // should include type checking. Right now this API is relying on the user
  195. // passing a Request handle
  196. ((HTTP_REQUEST_HANDLE_OBJECT *)hRequest)->ReuseObject();
  197. DEBUG_LEAVE(0);
  198. }