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.

170 lines
4.5 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. REQUEST_HEADER_HASH *REQUEST_HEADER_HASH::sm_pRequestHash;
  16. HEADER_RECORD REQUEST_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. { HttpHeaderAccept , HEADER("Accept") },
  44. { HttpHeaderAcceptCharset , HEADER("Accept-Charset") },
  45. { HttpHeaderAcceptEncoding , HEADER("Accept-Encoding") },
  46. { HttpHeaderAcceptLanguage , HEADER("Accept-Language") },
  47. { HttpHeaderAuthorization , HEADER("Authorization") },
  48. { HttpHeaderCookie , HEADER("Cookie") },
  49. { HttpHeaderExpect , HEADER("Expect") },
  50. { HttpHeaderFrom , HEADER("From") },
  51. { HttpHeaderHost , HEADER("Host") },
  52. { HttpHeaderIfMatch , HEADER("If-Match") },
  53. { HttpHeaderIfModifiedSince , HEADER("If-Modified-Since") },
  54. { HttpHeaderIfNoneMatch , HEADER("If-None-Match") },
  55. { HttpHeaderIfRange , HEADER("If-Range") },
  56. { HttpHeaderIfUnmodifiedSince , HEADER("If-Unmodified-Since") },
  57. { HttpHeaderMaxForwards , HEADER("Max-Forwards") },
  58. { HttpHeaderProxyAuthorization , HEADER("Proxy-Authorization") },
  59. { HttpHeaderReferer , HEADER("Referer") },
  60. { HttpHeaderRange , HEADER("Range") },
  61. { HttpHeaderTe , HEADER("TE") },
  62. { HttpHeaderTranslate , HEADER("Translate") },
  63. { HttpHeaderUserAgent , HEADER("User-Agent") }
  64. };
  65. //static
  66. HRESULT
  67. REQUEST_HEADER_HASH::Initialize(
  68. VOID
  69. )
  70. /*++
  71. Routine Description:
  72. Initialize global header hash table
  73. Arguments:
  74. None
  75. Return Value:
  76. HRESULT
  77. --*/
  78. {
  79. HEADER_RECORD * pRecord;
  80. LK_RETCODE lkrc = LK_SUCCESS;
  81. DWORD dwNumRecords;
  82. //
  83. // Add header index/name to hash table
  84. //
  85. sm_pRequestHash = new REQUEST_HEADER_HASH();
  86. if ( sm_pRequestHash == NULL )
  87. {
  88. return HRESULT_FROM_WIN32( ERROR_NOT_ENOUGH_MEMORY );
  89. }
  90. //
  91. // Add every string->routine mapping
  92. //
  93. dwNumRecords = sizeof( sm_rgHeaders ) / sizeof( HEADER_RECORD );
  94. for ( DWORD i = 0; i < dwNumRecords; i++ )
  95. {
  96. pRecord = &(sm_rgHeaders[ i ]);
  97. lkrc = sm_pRequestHash->InsertRecord( pRecord );
  98. if ( lkrc != LK_SUCCESS )
  99. {
  100. break;
  101. }
  102. }
  103. //
  104. // If any insert failed, then fail initialization
  105. //
  106. if ( lkrc != LK_SUCCESS )
  107. {
  108. delete sm_pRequestHash;
  109. sm_pRequestHash = NULL;
  110. return HRESULT_FROM_WIN32( lkrc ); // BUGBUG
  111. }
  112. else
  113. {
  114. return NO_ERROR;
  115. }
  116. }
  117. //static
  118. VOID
  119. REQUEST_HEADER_HASH::Terminate(
  120. VOID
  121. )
  122. /*++
  123. Routine Description:
  124. Global cleanup of header hash table
  125. Arguments:
  126. None
  127. Return Value:
  128. None
  129. --*/
  130. {
  131. if ( sm_pRequestHash != NULL )
  132. {
  133. delete sm_pRequestHash;
  134. sm_pRequestHash = NULL;
  135. }
  136. }