Source code of Windows XP (NT5)
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.

163 lines
4.1 KiB

  1. /*++
  2. Copyright (c) 2000 Microsoft Corporation
  3. Module Name :
  4. headerhash.cxx
  5. Abstract:
  6. Header hash goo
  7. Author:
  8. Bilal Alam (balam) 20-Feb-2000
  9. Environment:
  10. Win32 - User Mode
  11. Project:
  12. ULW3.DLL
  13. --*/
  14. #include "precomp.hxx"
  15. RESPONSE_HEADER_HASH *RESPONSE_HEADER_HASH::sm_pResponseHash;
  16. HEADER_RECORD RESPONSE_HEADER_HASH::sm_rgHeaders[] =
  17. {
  18. //
  19. // The only consumer of this data is W3_REQUEST::GetHeader
  20. // GetServerVariable is handled by SERVER_VARIABLE_HASH, so we do
  21. // not need to store the HTTP_'ed and capitalized names here
  22. //
  23. { HttpHeaderCacheControl , HEADER("Cache-Control") },
  24. { HttpHeaderConnection , HEADER("Connection") },
  25. { HttpHeaderDate , HEADER("Date") },
  26. { HttpHeaderKeepAlive , HEADER("Keep-Alive") },
  27. { HttpHeaderPragma , HEADER("Pragma") },
  28. { HttpHeaderTrailer , HEADER("Trailer") },
  29. { HttpHeaderTransferEncoding , HEADER("Transfer-Encoding") },
  30. { HttpHeaderUpgrade , HEADER("Upgrade") },
  31. { HttpHeaderVia , HEADER("Via") },
  32. { HttpHeaderWarning , HEADER("Warning") },
  33. { HttpHeaderAllow , HEADER("Allow") },
  34. { HttpHeaderContentLength , HEADER("Content-Length") },
  35. { HttpHeaderContentType , HEADER("Content-Type") },
  36. { HttpHeaderContentEncoding , HEADER("Content-Encoding") },
  37. { HttpHeaderContentLanguage , HEADER("Content-Language") },
  38. { HttpHeaderContentLocation , HEADER("Content-Location") },
  39. { HttpHeaderContentMd5 , HEADER("Content-Md5") },
  40. { HttpHeaderContentRange , HEADER("Content-Range") },
  41. { HttpHeaderExpires , HEADER("Expires") },
  42. { HttpHeaderLastModified , HEADER("Last-Modified") },
  43. { HttpHeaderAcceptRanges , HEADER("Accept-Ranges") },
  44. { HttpHeaderAge , HEADER("Age") },
  45. { HttpHeaderEtag , HEADER("ETag") },
  46. { HttpHeaderLocation , HEADER("Location") },
  47. { HttpHeaderProxyAuthenticate , HEADER("Proxy-Authenticate") },
  48. { HttpHeaderRetryAfter , HEADER("Retry-After") },
  49. { HttpHeaderServer , HEADER("Server") },
  50. // Set it to something which cannot be a header name, in effect
  51. // making Set-Cookie an unknown header
  52. { HttpHeaderSetCookie , HEADER("a:b\r\n") },
  53. { HttpHeaderVary , HEADER("Vary") },
  54. // Set it to something which cannot be a header name, in effect
  55. // making WWW-Authenticate an unknown header
  56. { HttpHeaderWwwAuthenticate , HEADER("b:c\r\n") }
  57. };
  58. //static
  59. HRESULT
  60. RESPONSE_HEADER_HASH::Initialize(
  61. VOID
  62. )
  63. /*++
  64. Routine Description:
  65. Initialize global header hash table
  66. Arguments:
  67. None
  68. Return Value:
  69. HRESULT
  70. --*/
  71. {
  72. HEADER_RECORD * pRecord;
  73. LK_RETCODE lkrc = LK_SUCCESS;
  74. DWORD dwNumRecords;
  75. //
  76. // Add header index/name to hash table
  77. //
  78. sm_pResponseHash = new RESPONSE_HEADER_HASH();
  79. if ( sm_pResponseHash == NULL )
  80. {
  81. return HRESULT_FROM_WIN32( ERROR_NOT_ENOUGH_MEMORY );
  82. }
  83. //
  84. // Add every string->routine mapping
  85. //
  86. dwNumRecords = sizeof( sm_rgHeaders ) / sizeof( HEADER_RECORD );
  87. for ( DWORD i = 0; i < dwNumRecords; i++ )
  88. {
  89. pRecord = &(sm_rgHeaders[ i ]);
  90. lkrc = sm_pResponseHash->InsertRecord( pRecord );
  91. if ( lkrc != LK_SUCCESS )
  92. {
  93. break;
  94. }
  95. }
  96. //
  97. // If any insert failed, then fail initialization
  98. //
  99. if ( lkrc != LK_SUCCESS )
  100. {
  101. delete sm_pResponseHash;
  102. sm_pResponseHash = NULL;
  103. return HRESULT_FROM_WIN32( lkrc ); // BUGBUG
  104. }
  105. else
  106. {
  107. return NO_ERROR;
  108. }
  109. }
  110. //static
  111. VOID
  112. RESPONSE_HEADER_HASH::Terminate(
  113. VOID
  114. )
  115. /*++
  116. Routine Description:
  117. Global cleanup of header hash table
  118. Arguments:
  119. None
  120. Return Value:
  121. None
  122. --*/
  123. {
  124. if ( sm_pResponseHash != NULL )
  125. {
  126. delete sm_pResponseHash;
  127. sm_pResponseHash = NULL;
  128. }
  129. }