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.

1094 lines
25 KiB

  1. /*++
  2. Copyright (c) 1994 Microsoft Corporation
  3. Module Name:
  4. connect.hxx
  5. Abstract:
  6. Contains the client-side connect handle class
  7. Author:
  8. Richard L Firth (rfirth) 03-Jan-1996
  9. Revision History:
  10. 03-Jan-1996 rfirth
  11. Created
  12. --*/
  13. extern LONG GlobalExistingConnectHandles;
  14. //
  15. // forward references
  16. //
  17. class CServerInfo;
  18. //
  19. // classes
  20. //
  21. /*++
  22. Class Description:
  23. This class defines the INTERNET_FILE_HANDLE_OBJECT. Which wraps the simple
  24. Win32 File handle.
  25. Private Member functions:
  26. None.
  27. Public Member functions:
  28. GetHandle : Virtual function that gets the service handle value from
  29. the generic object handle.
  30. --*/
  31. class INTERNET_FILE_HANDLE_OBJECT : public INTERNET_HANDLE_OBJECT {
  32. private:
  33. //
  34. // _hFileHandle - File Handle for access to R/W Win32 File I/O
  35. //
  36. HANDLE _hFileHandle;
  37. //
  38. // _Flags - the creation flags passed in to InternetConnect()
  39. //
  40. //
  41. // BUGBUG - combine with INTERNET_HANDLE_OBJECT::Flags
  42. //
  43. BOOL _Flags;
  44. //
  45. // _lpszFileName - the file name we care about.
  46. //
  47. LPSTR _lpszFileName;
  48. public:
  49. INTERNET_FILE_HANDLE_OBJECT(
  50. INTERNET_HANDLE_OBJECT * INetObj,
  51. LPSTR lpszFileName,
  52. HANDLE hFileHandle,
  53. DWORD dwFlags,
  54. DWORD_PTR dwContext
  55. ) : INTERNET_HANDLE_OBJECT(INetObj)
  56. {
  57. _Context = dwContext;
  58. _Flags = dwFlags;
  59. _hFileHandle = hFileHandle;
  60. _lpszFileName = (lpszFileName ? NewString(lpszFileName) : NULL );
  61. }
  62. HANDLE GetFileHandle() {
  63. return _hFileHandle;
  64. }
  65. PSTR GetDataFileName() {
  66. return _lpszFileName;
  67. }
  68. virtual ~INTERNET_FILE_HANDLE_OBJECT(VOID) {
  69. if ( _hFileHandle )
  70. {
  71. CloseHandle(_hFileHandle);
  72. _hFileHandle = NULL;
  73. }
  74. if ( _lpszFileName ) {
  75. _lpszFileName = (LPSTR) FREE_MEMORY(_lpszFileName);
  76. }
  77. }
  78. virtual HINTERNET_HANDLE_TYPE GetHandleType(VOID) {
  79. return TypeFileRequestHandle;
  80. }
  81. };
  82. /*++
  83. Class Description:
  84. This class defines the INTERNET_CONNECT_HANDLE_OBJECT.
  85. Private Member functions:
  86. None.
  87. Public Member functions:
  88. GetHandle : Virtual function that gets the service handle value from
  89. the generic object handle.
  90. --*/
  91. class INTERNET_CONNECT_HANDLE_OBJECT : public INTERNET_HANDLE_OBJECT {
  92. private:
  93. //
  94. // _InternetConnectHandle
  95. //
  96. //
  97. // BUGBUG - from the days of RPC catapult proxy. No longer required
  98. //
  99. HINTERNET _InternetConnectHandle;
  100. //
  101. // _wCloseFunction - function which handles closing underlying connection
  102. // at protocol level
  103. //
  104. CONNECT_CLOSE_HANDLE_FUNC _wCloseFunction;
  105. //
  106. // _IsCopy - TRUE if this handle is part of a file/find/object handle
  107. //
  108. BOOL _IsCopy;
  109. //
  110. // _ServiceType - type of service
  111. //
  112. //
  113. // BUGBUG - superceded by INTERNET_SCHEME_TYPE
  114. //
  115. DWORD _ServiceType;
  116. //
  117. // _HandleType - type of handle
  118. //
  119. //
  120. // BUGBUG - superceded by HANDLE_OBJECT::ObjectType
  121. //
  122. HINTERNET_HANDLE_TYPE _HandleType;
  123. //
  124. // _Flags - the creation flags passed in to InternetConnect()
  125. //
  126. //
  127. // BUGBUG - combine with INTERNET_HANDLE_OBJECT::Flags
  128. //
  129. BOOL _Flags;
  130. //
  131. // _InUse - used when object created with INTERNET_FLAG_EXISTING_CONNECT.
  132. // If TRUE the handle is already in use by another request, else it is
  133. // available
  134. //
  135. BOOL _InUse;
  136. protected:
  137. // cache related items
  138. BOOL _fDeleteDataFile;
  139. LPSTR _CacheCWD; //Current working directory
  140. LPSTR _CacheUrlName;
  141. XSTRING _xsPrimaryCacheKey;
  142. XSTRING _xsSecondaryCacheKey;
  143. LPSTR _CacheFileName;
  144. //LPBYTE _CacheHeaderInfo;
  145. DWORD _CacheHeaderLength;
  146. BOOL _CacheReadInProgress; // BUGBUG should they be in flags field
  147. BOOL _CacheWriteInProgress;
  148. HANDLE _CacheFileHandle;
  149. HANDLE _CacheFileHandleRead;
  150. DWORD _RealCacheFileSize;
  151. DWORD _VirtualCacheFileSize;
  152. #ifdef LAZY_WRITE
  153. LPBYTE _CacheScratchBuf;
  154. DWORD _CacheScratchBufLen;
  155. DWORD _CacheScratchUsedLen;
  156. #endif
  157. DWORD _dwCacheFlags; // RELOAD, NO_CACHE, MAKE_PERSISTENT
  158. DWORD _dwStreamRefCount;
  159. HANDLE _hCacheStream;
  160. DWORD _dwCurrentStreamPosition;
  161. BOOL _fFromCache;
  162. BOOL _fCacheWriteDisabled;
  163. BOOL _fIsHtmlFind;
  164. BOOL _CacheCopy;
  165. BOOL _CachePerUserItem;
  166. BOOL _fForcedExpiry;
  167. BOOL _fLazyUpdate;
  168. HANDLE _hLockRequestInfo;
  169. LPSTR _OriginalUrl;
  170. VOID InitCacheVariables() {
  171. // Initialize the Cache Variables
  172. _fDeleteDataFile = FALSE;
  173. _CacheCWD = NULL;
  174. _CacheUrlName = NULL;
  175. _CacheFileName = NULL;
  176. //_CacheHeaderInfo = NULL;
  177. _CacheHeaderLength = 0;
  178. _CacheReadInProgress = FALSE;
  179. _CacheWriteInProgress = FALSE;
  180. _CacheFileHandle = INVALID_HANDLE_VALUE;
  181. _CacheFileHandleRead = INVALID_HANDLE_VALUE;
  182. _RealCacheFileSize = 0;
  183. _VirtualCacheFileSize = 0;
  184. _CacheCopy = FALSE;
  185. #ifdef LAZY_WRITE
  186. _CacheScratchBuf = NULL;
  187. _CacheScratchBufLen = 0;
  188. _CacheScratchUsedLen = 0;
  189. #endif // LAZY_WRITE
  190. _dwCacheFlags = 0;
  191. _hCacheStream = NULL; // ACHTUNG, this is a memory handle
  192. _dwStreamRefCount = 0;
  193. _dwCurrentStreamPosition = 0;
  194. _fFromCache = FALSE;
  195. _fCacheWriteDisabled = FALSE;
  196. _fIsHtmlFind = FALSE;
  197. _CachePerUserItem = 0;
  198. _fForcedExpiry = FALSE;
  199. _fLazyUpdate = FALSE;
  200. _hLockRequestInfo = NULL;
  201. _OriginalUrl = NULL;
  202. }
  203. protected:
  204. //
  205. // an app can set/query the internal buffer sizes for e.g. FtpGetFile()
  206. //
  207. DWORD _ReadBufferSize;
  208. DWORD _WriteBufferSize;
  209. //
  210. // the following 3 pointers are for the string parameters passed to
  211. // InternetConnect()
  212. //
  213. ICSTRING _HostName;
  214. PWC * _pwcServerCreds;
  215. PWC * _pwcProxyCreds;
  216. BOOL _fHasCredsTimestamp;
  217. SYSTEMTIME _TimeCredsEntered;
  218. INTERNET_PORT _HostPort;
  219. //
  220. // _SchemeType - the actual scheme type we are using for this object (may be
  221. // different from original type if going via (CERN) proxy, e.g. HTTP => FTP)
  222. //
  223. INTERNET_SCHEME _SchemeType;
  224. //
  225. // _LastResponseInfo - in the case of an FTP URL handle object, we associate
  226. // the last response info so that we can pull out the server welcome message
  227. //
  228. LPSTR _LastResponseInfo;
  229. //
  230. // _LastResponseInfoLength - number of bytes in _LastResponseInfo. Only
  231. // meaningful if _LastResponseInfo not NULL
  232. //
  233. DWORD _LastResponseInfoLength;
  234. //
  235. // _bViaProxy - TRUE if the request was made via a proxy
  236. //
  237. BOOL _bViaProxy;
  238. //
  239. // _bNoHeaders - TRUE if we made the request via HTTP and no headers were
  240. // returned in the response, or the request was made via a protocol that
  241. // doesn't return headers
  242. //
  243. BOOL _bNoHeaders;
  244. //
  245. // _bNetFailed - TRUE if the net operation failed (used when we are returning
  246. // data from cache on net timeout)
  247. //
  248. BOOL _bNetFailed;
  249. //
  250. // Bits indicating whether or not the proxy or server username + password
  251. // on the request handle are valid; Any time a username/password is transferred
  252. // to the password cache it is invalidated for all internal calls to avoid mistaken
  253. // re-usage on redirect. Calls to InternetQueryInfo will return any username/password
  254. // found on the handle to support applications expecting this information to remain
  255. // valid.
  256. //
  257. struct FlagsStruct
  258. {
  259. BYTE fProxyUserPassValid;
  260. BYTE fServerUserPassValid;
  261. BYTE fReserved1;
  262. BYTE fReserved2;
  263. } _HandleFlags;
  264. //
  265. // _dwErrorMask - Indicates which special errors are allowed to be returned
  266. // via HttpSendRequest - currently ERROR_INTERNET_INSERT_CDROM can be returned
  267. // if first bit is set in this mask.
  268. //
  269. DWORD _dwErrorMask;
  270. //
  271. // _ServerInfo - pointer to global server information context
  272. //
  273. CServerInfo * _ServerInfo;
  274. //
  275. // _OriginServer - pointer to origin server information context
  276. //
  277. CServerInfo * _OriginServer;
  278. public:
  279. INTERNET_CONNECT_HANDLE_OBJECT(
  280. INTERNET_HANDLE_OBJECT * INetObj,
  281. LPTSTR lpszServerName,
  282. INTERNET_PORT nServerPort,
  283. LPTSTR lpszUsername OPTIONAL,
  284. LPTSTR lpszPassword OPTIONAL,
  285. DWORD dwService,
  286. DWORD dwFlags,
  287. DWORD_PTR dwContext
  288. );
  289. INTERNET_CONNECT_HANDLE_OBJECT(
  290. INTERNET_CONNECT_HANDLE_OBJECT * InternetConnectObj
  291. );
  292. INTERNET_CONNECT_HANDLE_OBJECT(
  293. INTERNET_HANDLE_OBJECT * Parent,
  294. HINTERNET Child,
  295. CONNECT_CLOSE_HANDLE_FUNC wCloseFunc,
  296. LPTSTR lpszServerName,
  297. INTERNET_PORT nServerPort,
  298. LPTSTR lpszUsername OPTIONAL,
  299. LPTSTR lpszPassword OPTIONAL,
  300. DWORD ServiceType,
  301. DWORD dwFlags,
  302. DWORD_PTR dwContext
  303. );
  304. virtual ~INTERNET_CONNECT_HANDLE_OBJECT(VOID);
  305. virtual HINTERNET GetHandle(VOID);
  306. virtual HINTERNET_HANDLE_TYPE GetHandleType(VOID) {
  307. return _HandleType;
  308. }
  309. DWORD GetServiceType(VOID) {
  310. return _ServiceType;
  311. }
  312. VOID SetHandleType(DWORD dwServiceType) {
  313. switch (dwServiceType) {
  314. case INTERNET_SERVICE_FTP:
  315. _HandleType = TypeFtpConnectHandle;
  316. break;
  317. case INTERNET_SERVICE_GOPHER:
  318. _HandleType = TypeGopherConnectHandle;
  319. break;
  320. case INTERNET_SERVICE_HTTP:
  321. _HandleType = TypeHttpConnectHandle;
  322. break;
  323. }
  324. }
  325. DWORD GetBufferSize(IN DWORD SizeIndex) {
  326. switch (SizeIndex) {
  327. case INTERNET_OPTION_READ_BUFFER_SIZE:
  328. return _ReadBufferSize;
  329. case INTERNET_OPTION_WRITE_BUFFER_SIZE:
  330. return _WriteBufferSize;
  331. default:
  332. //
  333. // BUGBUG - global default
  334. //
  335. return (4 K);
  336. }
  337. }
  338. VOID SetBufferSize(IN DWORD SizeIndex, IN DWORD Size) {
  339. switch (SizeIndex) {
  340. case INTERNET_OPTION_READ_BUFFER_SIZE:
  341. _ReadBufferSize = Size;
  342. break;
  343. case INTERNET_OPTION_WRITE_BUFFER_SIZE:
  344. _WriteBufferSize = Size;
  345. break;
  346. }
  347. }
  348. DWORD GetFlags() {
  349. return _Flags;
  350. }
  351. void SetDeleteDataFile (void) {
  352. _fDeleteDataFile = TRUE;
  353. }
  354. BOOL IsInUse(VOID) const {
  355. //
  356. // by definition, a connect handle object created without
  357. // INTERNET_FLAG_EXISTING_CONNECT is in use
  358. //
  359. return (_Flags & INTERNET_FLAG_EXISTING_CONNECT) ? _InUse : TRUE;
  360. }
  361. VOID SetInUse(VOID) {
  362. //dprintf("SetInUse() %#x\n", GetPseudoHandle());
  363. INET_ASSERT(_Flags & INTERNET_FLAG_EXISTING_CONNECT);
  364. INET_ASSERT(!_InUse);
  365. //
  366. // only handle type that should be coming through here
  367. //
  368. INET_ASSERT(GetHandleType() == TypeFtpConnectHandle);
  369. _InUse = TRUE;
  370. //
  371. // one less handle that can be flushed right now
  372. //
  373. if (InterlockedDecrement(&GlobalExistingConnectHandles) < 0) {
  374. INET_ASSERT(FALSE);
  375. GlobalExistingConnectHandles = 0;
  376. }
  377. //dprintf("SetInUse: GlobalExistingConnectHandles = %d\n", GlobalExistingConnectHandles);
  378. }
  379. BOOL SetUnused(VOID) {
  380. //dprintf("SetUnused() %#x\n", GetPseudoHandle());
  381. //INET_ASSERT(_Flags & INTERNET_FLAG_EXISTING_CONNECT);
  382. //
  383. // only handle type that should be coming through here
  384. //
  385. //INET_ASSERT(GetHandleType() == TypeFtpConnectHandle);
  386. if ((_Flags & INTERNET_FLAG_EXISTING_CONNECT) && _InUse) {
  387. _InUse = FALSE;
  388. //
  389. // this handle can be flushed if required
  390. //
  391. InterlockedIncrement(&GlobalExistingConnectHandles);
  392. //dprintf("SetUnused: GlobalExistingConnectHandles = %d\n", GlobalExistingConnectHandles);
  393. return TRUE;
  394. } else {
  395. return FALSE;
  396. }
  397. }
  398. //
  399. // cache functions.
  400. //
  401. // creates a protocl specific URL based on targethost, CWD, objectname and an extension
  402. DWORD
  403. SetObjectName(
  404. IN LPSTR lpszObjectName,
  405. IN LPSTR lpszExtension,
  406. IN URLGEN_FUNC * procProtocolUrl
  407. );
  408. //
  409. // CWD, applies only to FTP
  410. //
  411. DWORD
  412. SetCurrentWorkingDirectory(
  413. IN LPSTR lpszCWD
  414. );
  415. //
  416. // CWD, applies only to FTP
  417. //
  418. DWORD
  419. GetCurrentWorkingDirectory(
  420. OUT LPSTR lpszCWD,
  421. OUT LPDWORD lpdwSize
  422. );
  423. VOID SetCacheFlags(DWORD dwFlags) {
  424. _dwCacheFlags = dwFlags;
  425. }
  426. DWORD GetCacheFlags() {
  427. return _dwCacheFlags;
  428. }
  429. VOID SetCacheWriteDisabled() {
  430. _fCacheWriteDisabled = TRUE;
  431. }
  432. BOOL IsCacheWriteDisabled() {
  433. return _fCacheWriteDisabled;
  434. }
  435. VOID SetFromCache() {
  436. _fFromCache = TRUE;
  437. }
  438. BOOL IsFromCache() {
  439. return _fFromCache;
  440. }
  441. //
  442. // returns info about the entry that is being reteived in a LocalAlloced
  443. // buffer. Caller is supposed to free the buffer whenever convenient
  444. //
  445. DWORD BeginCacheRetrieval( LPCACHE_ENTRY_INFO*);
  446. DWORD RecordCacheRetrieval (LPCACHE_ENTRY_INFO);
  447. DWORD
  448. ReadCache(
  449. OUT LPBYTE Buffer,
  450. IN DWORD BufferLen,
  451. OUT LPDWORD BytesRead
  452. );
  453. DWORD
  454. EndCacheRetrieval(
  455. VOID
  456. );
  457. DWORD
  458. GetCacheStream(
  459. LPBYTE lpBuffer,
  460. DWORD dwLen
  461. );
  462. DWORD
  463. ReleaseCacheStream(
  464. HANDLE hCacheStream
  465. );
  466. DWORD BeginCacheWrite(DWORD dwExpectedLength, LPCSTR lpszExtension, LPCSTR lpszFileName = NULL);
  467. DWORD
  468. WriteCache(
  469. IN LPBYTE Buffer,
  470. IN DWORD BufferLen
  471. );
  472. DWORD
  473. WriteToDisk(
  474. IN LPBYTE Buffer,
  475. IN DWORD BufferLen,
  476. OUT LPDWORD lpdwBytesWritten
  477. );
  478. DWORD EndCacheWrite(
  479. FILETIME* lpftExpireTime,
  480. FILETIME *lpftLastModifiedTime,
  481. FILETIME* lpftPostCheckTime,
  482. DWORD dwEntryType,
  483. DWORD dwHeaderLen,
  484. LPSTR lpHeaderInfo,
  485. LPSTR lpszFileExtension,
  486. BOOL fImage = FALSE
  487. );
  488. DWORD LazyUpdate(VOID);
  489. DWORD
  490. CacheGetUrlInfo(
  491. LPCACHE_ENTRY_INFO UrlInfo,
  492. LPDWORD lpdwBuffSize
  493. ) {
  494. return GetUrlCacheEntryInfo(_CacheUrlName, UrlInfo, lpdwBuffSize);
  495. }
  496. DWORD
  497. CacheSetUrlInfo(
  498. LPCACHE_ENTRY_INFO UrlInfo,
  499. DWORD dwFieldControl
  500. ) {
  501. return SetUrlCacheEntryInfo(_CacheUrlName, UrlInfo, dwFieldControl);
  502. }
  503. DWORD
  504. ExpireUrl(VOID){
  505. CACHE_ENTRY_INFO sCEI;
  506. GetCurrentGmtTime(&sCEI.ExpireTime);
  507. *(LONGLONG UNALIGNED *)&(sCEI.ExpireTime) -= ONE_HOUR_DELTA;
  508. return SetUrlCacheEntryInfo(_CacheUrlName, &sCEI, CACHE_ENTRY_EXPTIME_FC);
  509. }
  510. DWORD
  511. ExpireUrl(LPSTR lpszUrl){
  512. CACHE_ENTRY_INFO sCEI;
  513. GetCurrentGmtTime(&sCEI.ExpireTime);
  514. *(LONGLONG UNALIGNED *)&(sCEI.ExpireTime) -= ONE_HOUR_DELTA;
  515. return SetUrlCacheEntryInfo(lpszUrl, &sCEI, CACHE_ENTRY_EXPTIME_FC);
  516. }
  517. BOOL IsCacheReadInProgress(VOID) {
  518. return _CacheReadInProgress;
  519. }
  520. BOOL IsCacheWriteInProgress(VOID) {
  521. return _CacheWriteInProgress;
  522. }
  523. #ifdef LAZY_WRITE
  524. LPBYTE GetCacheScratchBuf(LPDWORD Length, LPDWORD lpdwUsed);
  525. VOID FreeCacheScratchBuf( ) {
  526. if (_CacheScratchBuf) {
  527. FREE_MEMORY(_CacheScratchBuf);
  528. _CacheScratchBuf = NULL;
  529. _CacheScratchBufLen = _CacheScratchUsedLen = 0;
  530. }
  531. }
  532. VOID ResetScratchUseSize() {
  533. _CacheScratchUsedLen = 0;
  534. }
  535. BOOL CopyToScratch(LPBYTE lpBuff, DWORD dwSize) {
  536. if (_CacheScratchBuf && (dwSize <= (_CacheScratchBufLen -_CacheScratchUsedLen))) {
  537. memcpy((_CacheScratchBuf+_CacheScratchUsedLen), lpBuff, dwSize);
  538. _CacheScratchUsedLen += dwSize;
  539. return (TRUE);
  540. }
  541. return (FALSE);
  542. }
  543. #endif // LAZY_WRITE
  544. VOID SetHostName(LPSTR HostName) {
  545. _HostName = HostName;
  546. }
  547. LPSTR GetHostName(VOID) {
  548. return _HostName.StringAddress();
  549. }
  550. LPSTR GetHostName(LPDWORD lpdwStringLength) {
  551. *lpdwStringLength = _HostName.StringLength();
  552. return _HostName.StringAddress();
  553. }
  554. void CopyHostName(LPSTR OutputString) {
  555. _HostName.CopyTo(OutputString);
  556. }
  557. BOOL GetUserAndPass (BOOL fProxy, LPSTR *pszUser, LPSTR *pszPass);
  558. LPSTR GetUserOrPass (BOOL fUser, BOOL fProxy) {
  559. PWC * pwc = fProxy ? _pwcProxyCreds : _pwcServerCreds;
  560. // If the user/password is NULL and this is an HttpRequest object,
  561. // then delegate the call to the parent Connect object
  562. if (((NULL == pwc) || (NULL == (fUser ? pwc->lpszUser : pwc->lpszPass)))
  563. && GetHandleType() == TypeHttpRequestHandle)
  564. {
  565. INTERNET_CONNECT_HANDLE_OBJECT * pConnect =
  566. (INTERNET_CONNECT_HANDLE_OBJECT *) GetParent();
  567. return pConnect->GetUserOrPass (fUser, fProxy);
  568. }
  569. else if (pwc != NULL)
  570. {
  571. return (fUser) ? pwc->GetUser() : pwc->GetPass();
  572. }
  573. else
  574. return NULL;
  575. }
  576. void SetUserOrPass (LPSTR lpszIn, BOOL fUser, BOOL fProxy ) {
  577. PWC * pwc;
  578. if (fProxy)
  579. {
  580. if (NULL == _pwcProxyCreds)
  581. {
  582. _pwcProxyCreds = PWC_Create(NULL, 0, NULL, NULL, NULL);
  583. }
  584. pwc = _pwcProxyCreds;
  585. }
  586. else
  587. {
  588. if (NULL == _pwcServerCreds)
  589. {
  590. _pwcServerCreds = PWC_Create(NULL, 0, NULL, NULL, NULL);
  591. }
  592. pwc = _pwcServerCreds;
  593. }
  594. if (pwc)
  595. {
  596. AuthLock();
  597. if (fUser)
  598. {
  599. pwc->SetUser(lpszIn);
  600. }
  601. else
  602. {
  603. pwc->SetPass(lpszIn);
  604. }
  605. if (fProxy)
  606. _HandleFlags.fProxyUserPassValid = TRUE;
  607. else
  608. _HandleFlags.fServerUserPassValid = TRUE;
  609. AuthUnlock();
  610. }
  611. }
  612. void TimeStampCreds(void) {
  613. ::GetSystemTime(&_TimeCredsEntered); // time-stamp the creds
  614. _fHasCredsTimestamp = TRUE;
  615. }
  616. PSYSTEMTIME GetCredTimeStamp (void) {
  617. if (_fHasCredsTimestamp)
  618. {
  619. return &_TimeCredsEntered;
  620. }
  621. if (GetHandleType() == TypeHttpRequestHandle) {
  622. INTERNET_CONNECT_HANDLE_OBJECT * pConnect =
  623. (INTERNET_CONNECT_HANDLE_OBJECT *) GetParent();
  624. return pConnect->GetCredTimeStamp();
  625. } else {
  626. return NULL;
  627. }
  628. }
  629. LPSTR GetServerName(VOID) {
  630. return _HostName.StringAddress();;
  631. }
  632. VOID FreeURL(VOID) {
  633. if (_CacheUrlName != NULL) {
  634. _CacheUrlName = (LPSTR)FREE_MEMORY(_CacheUrlName);
  635. INET_ASSERT(_CacheUrlName == NULL);
  636. }
  637. }
  638. LPSTR GetURL(VOID) {
  639. return _xsSecondaryCacheKey.GetPtr()?
  640. _xsPrimaryCacheKey.GetPtr() : _CacheUrlName;
  641. }
  642. BOOL SetURL(LPSTR lpszUrl);
  643. BOOL SetURLPtr(LPSTR* ppszUrl);
  644. BOOL SetSecondaryCacheKey (LPSTR lpszKey);
  645. LPSTR GetSecondaryCacheKey (void) {
  646. return _xsSecondaryCacheKey.GetPtr();
  647. }
  648. void FreeSecondaryCacheKey (void);
  649. LPSTR GetCacheKey (void) {
  650. return _CacheUrlName;
  651. }
  652. VOID SetHostPort(INTERNET_PORT Port) {
  653. _HostPort = Port;
  654. }
  655. INTERNET_PORT GetHostPort(VOID) {
  656. return _HostPort;
  657. }
  658. INTERNET_SCHEME GetSchemeType(VOID) const {
  659. return (_SchemeType == INTERNET_SCHEME_DEFAULT)
  660. ? INTERNET_SCHEME_HTTP
  661. : _SchemeType;
  662. }
  663. VOID SetSchemeType(INTERNET_SCHEME SchemeType) {
  664. _SchemeType = SchemeType;
  665. }
  666. VOID SetSchemeType(LPSTR SchemeName, DWORD SchemeLength) {
  667. _SchemeType = MapUrlSchemeName(SchemeName, SchemeLength);
  668. }
  669. VOID SetConnectHandle(HINTERNET hInternet) {
  670. _InternetConnectHandle = hInternet;
  671. }
  672. PSTR GetDataFileName (void) const {
  673. return _CacheFileName;
  674. }
  675. VOID FreeCacheFileName(VOID) {
  676. if (_CacheFileName != NULL) {
  677. (void)FREE_MEMORY((HLOCAL)_CacheFileName);
  678. _CacheFileName = NULL;
  679. }
  680. }
  681. BOOL IsPerUserItem() {
  682. return (_CachePerUserItem != 0);
  683. }
  684. VOID SetPerUserItem(BOOL fFlag) {
  685. _CachePerUserItem = fFlag;
  686. }
  687. BOOL IsHtmlFind() {
  688. return (_fIsHtmlFind != 0);
  689. }
  690. VOID SetHtmlFind(BOOL fFlag) {
  691. _fIsHtmlFind = fFlag;
  692. }
  693. VOID SetForcedExpiry(BOOL fFlag) {
  694. _fForcedExpiry = fFlag;
  695. }
  696. BOOL IsForcedExpirySet() {
  697. return(_fForcedExpiry);
  698. }
  699. BOOL ExpireDependents();
  700. VOID AttachLastResponseInfo(VOID);
  701. VOID SetLastResponseInfo(LPSTR Buffer, DWORD Length) {
  702. INET_ASSERT(_LastResponseInfo == NULL);
  703. _LastResponseInfo = Buffer;
  704. _LastResponseInfoLength = Length;
  705. }
  706. LPSTR GetLastResponseInfo(LPDWORD lpdwLength) const {
  707. *lpdwLength = _LastResponseInfoLength;
  708. return _LastResponseInfo;
  709. }
  710. VOID FreeLastResponseInfo(VOID) {
  711. if (_LastResponseInfo != NULL) {
  712. _LastResponseInfo = (LPSTR)FREE_MEMORY((HLOCAL)_LastResponseInfo);
  713. INET_ASSERT(_LastResponseInfo == NULL);
  714. }
  715. }
  716. VOID SetViaProxy(BOOL bValue) {
  717. _bViaProxy = bValue;
  718. }
  719. BOOL IsViaProxy(VOID) const {
  720. return _bViaProxy;
  721. }
  722. VOID SetNoHeaders(BOOL bValue) {
  723. _bNoHeaders = bValue;
  724. }
  725. BOOL IsNoHeaders(VOID) const {
  726. return _bNoHeaders;
  727. }
  728. VOID SetNetFailed(VOID) {
  729. _bNetFailed = TRUE;
  730. }
  731. BOOL IsNetFailed(VOID) const {
  732. return _bNetFailed;
  733. }
  734. VOID SetLockRequestHandle(HANDLE hLockRequestInfo) {
  735. INET_ASSERT(_hLockRequestInfo==NULL);
  736. _hLockRequestInfo = hLockRequestInfo;
  737. }
  738. HANDLE GetLockRequestHandle() {
  739. return (_hLockRequestInfo);
  740. }
  741. CServerInfo * GetServerInfo(VOID) const {
  742. return _ServerInfo;
  743. }
  744. CServerInfo * GetOriginServer(VOID) const {
  745. return (_OriginServer != NULL) ? _OriginServer : _ServerInfo;
  746. }
  747. VOID
  748. SetOriginServer(
  749. IN CServerInfo * pServerInfo,
  750. BOOL fForceUpdate = FALSE
  751. );
  752. VOID SetOriginServer(BOOL fForceUpdate = FALSE) {
  753. SetOriginServer(_ServerInfo, fForceUpdate);
  754. }
  755. DWORD
  756. SetServerInfo(
  757. CServerInfo * pReferencedServerInfo
  758. )
  759. {
  760. if (_ServerInfo != NULL) {
  761. ::ReleaseServerInfo(_ServerInfo);
  762. }
  763. //
  764. // WARNING:: THIS ASSUMES a pre-referenced
  765. // ServerInfo
  766. //
  767. _ServerInfo = pReferencedServerInfo;
  768. return ERROR_SUCCESS;
  769. }
  770. DWORD
  771. SetServerInfo(
  772. IN LPSTR lpszServerName,
  773. IN DWORD dwServerNameLength
  774. );
  775. DWORD
  776. SetServerInfo(
  777. IN BOOL bDoResolution,
  778. IN OPTIONAL BOOL fNtlm = FALSE
  779. ) {
  780. return SetServerInfo(GetSchemeType(), bDoResolution, fNtlm);
  781. }
  782. DWORD
  783. SetServerInfo(
  784. IN INTERNET_SCHEME tScheme,
  785. IN BOOL bDoResolution,
  786. IN OPTIONAL BOOL fNtlm = FALSE
  787. );
  788. VOID SetOriginalUrl(LPSTR lpszUrl) {
  789. if (_OriginalUrl != NULL) {
  790. _OriginalUrl = (LPSTR)FREE_MEMORY(_OriginalUrl);
  791. INET_ASSERT(_OriginalUrl == NULL);
  792. }
  793. if (lpszUrl != NULL) {
  794. _OriginalUrl = NewString(lpszUrl);
  795. INET_ASSERT(_OriginalUrl != NULL);
  796. }
  797. }
  798. LPSTR GetOriginalUrl(VOID) const {
  799. return _OriginalUrl;
  800. }
  801. VOID SetErrorMask(DWORD dwErrorMask) {
  802. _dwErrorMask = dwErrorMask;
  803. }
  804. DWORD GetErrorMask(VOID) {
  805. return _dwErrorMask;
  806. }
  807. };