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.

148 lines
2.7 KiB

  1. /*++
  2. Copyright (c) 1996 Microsoft Corporation
  3. Module Name :
  4. linkload.h
  5. Abstract:
  6. Link loader class definitions. It uses wininet API
  7. to load the web page from the internet.
  8. Author:
  9. Michael Cheuk (mcheuk) 22-Nov-1996
  10. Project:
  11. Link Checker
  12. Revision History:
  13. --*/
  14. #ifndef _LINKLOAD_H_
  15. #define _LINKLOAD_H_
  16. #include "inetapi.h"
  17. //------------------------------------------------------------------
  18. // Forward declaration
  19. //
  20. class CLink;
  21. //------------------------------------------------------------------
  22. // This is a wrapper class for HINTERNET. It takes care of internet
  23. // handle cleaning up.
  24. //
  25. class CAutoInternetHandle
  26. {
  27. // Public interfaces
  28. public:
  29. // Constructor
  30. CAutoInternetHandle(
  31. HINTERNET hHandle = NULL
  32. )
  33. {
  34. m_hHandle = hHandle;
  35. }
  36. // Destructor
  37. ~CAutoInternetHandle()
  38. {
  39. if(m_hHandle)
  40. {
  41. ASSERT(CWininet::IsLoaded());
  42. VERIFY(CWininet::InternetCloseHandle(m_hHandle));
  43. }
  44. }
  45. // Operator overloads. These functions make
  46. // CAutoInternetHandle instance behaves like a HINTERNET
  47. operator HINTERNET() const
  48. {
  49. return m_hHandle;
  50. }
  51. const HINTERNET& operator=(
  52. const HINTERNET& hHandle
  53. )
  54. {
  55. m_hHandle = hHandle;
  56. return m_hHandle;
  57. }
  58. // Protected member
  59. protected:
  60. HINTERNET m_hHandle; // Actual HINTERNET
  61. }; // class CAutoInternetHandle
  62. //------------------------------------------------------------------
  63. // Link loader class. It uses wininet API to load the web
  64. // page from the internet.
  65. //
  66. class CLinkLoader
  67. {
  68. // Public interfaces
  69. public:
  70. // One time link loader create funtion
  71. BOOL Create(
  72. const CString& strUserAgent, // HTTP user agent name
  73. const CString& strAdditionalHeaders // addtional HTTP headers
  74. );
  75. // Load a web link
  76. BOOL Load(
  77. CLink& link,
  78. BOOL fLocalLink
  79. );
  80. // Change the loader properties
  81. BOOL ChangeProperties(
  82. const CString& strUserAgent,
  83. const CString& strAdditionalHeaders
  84. );
  85. // Protected interfaces
  86. protected:
  87. // Load a HTTP link
  88. BOOL LoadHTTP(
  89. CLink& link,
  90. BOOL fReadFile,
  91. LPCTSTR szHostName,
  92. LPCTSTR szUrlPath,
  93. int iRedirectCount = 0
  94. );
  95. // Load a URL (non-HTTP) link
  96. BOOL LoadURL(
  97. CLink& link
  98. );
  99. // Wininet failed clean up subroutine
  100. BOOL WininetFailed(
  101. CLink& link
  102. );
  103. // Protected interfaces
  104. protected:
  105. // Handle for internet session (one per instance)
  106. CAutoInternetHandle m_hInternetSession;
  107. // Additional http header string
  108. CString m_strAdditionalHeaders;
  109. }; // class CLinkLoader
  110. #endif // _LINKLOAD_H_