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.

120 lines
2.9 KiB

  1. /*++
  2. Copyright (c) 2001 Microsoft Corporation
  3. Module Name :
  4. options_handler.cxx
  5. Abstract:
  6. Handle OPTIONS requests
  7. Author:
  8. Anil Ruia (AnilR) 4-Apr-2001
  9. Environment:
  10. Win32 - User Mode
  11. Project:
  12. ULW3.DLL
  13. --*/
  14. #include "precomp.hxx"
  15. #include "options_handler.hxx"
  16. CONTEXT_STATUS
  17. W3_OPTIONS_HANDLER::DoWork()
  18. /*++
  19. Routine Description:
  20. Do the OPTIONS thing if DAV is disabled
  21. Return Value:
  22. CONTEXT_STATUS_PENDING if async pending, else CONTEXT_STATUS_CONTINUE
  23. --*/
  24. {
  25. HRESULT hr;
  26. W3_CONTEXT *pW3Context = QueryW3Context();
  27. DBG_ASSERT(pW3Context != NULL);
  28. W3_RESPONSE *pW3Response = pW3Context->QueryResponse();
  29. W3_REQUEST *pW3Request = pW3Context->QueryRequest();
  30. STACK_STRU (strUrl, MAX_PATH);
  31. if (FAILED(hr = pW3Response->SetHeader(HEADER("Public"),
  32. HEADER("OPTIONS, TRACE, GET, HEAD, POST"))))
  33. {
  34. goto Failed;
  35. }
  36. if (FAILED(hr = pW3Request->GetUrl(&strUrl)))
  37. {
  38. goto Failed;
  39. }
  40. if (wcscmp(strUrl.QueryStr(), L"*") != 0 &&
  41. wcscmp(strUrl.QueryStr(), L"/*") != 0)
  42. {
  43. //
  44. // Add Allow header
  45. //
  46. if (FAILED(hr = pW3Context->SetupAllowHeader()))
  47. {
  48. goto Failed;
  49. }
  50. //
  51. // Also figure out whether Frontpage is enabled and send
  52. // MS-Author-Via header if so
  53. // Cannot store it with the metadata since we do not want to pick
  54. // up the inherited value, can store with url-info but deferred
  55. // for later (BUGBUG)
  56. //
  57. MB mb( g_pW3Server->QueryMDObject() );
  58. BOOL fIsFrontPageWeb;
  59. if (!mb.Open(pW3Context->QuerySite()->QueryMBRoot()->QueryStr()))
  60. {
  61. hr = HRESULT_FROM_WIN32(GetLastError());
  62. goto Failed;
  63. }
  64. if (mb.GetDword(strUrl.QueryStr(),
  65. MD_FRONTPAGE_WEB,
  66. IIS_MD_UT_SERVER,
  67. (DWORD *)&fIsFrontPageWeb,
  68. METADATA_NO_ATTRIBUTES) &&
  69. fIsFrontPageWeb)
  70. {
  71. if (FAILED(hr = pW3Response->SetHeader(HEADER("MS-Author-Via"),
  72. HEADER("MS-FP/4.0"))))
  73. {
  74. goto Failed;
  75. }
  76. }
  77. DBG_REQUIRE( mb.Close() );
  78. }
  79. else
  80. {
  81. pW3Response->SetHeaderByReference(HttpHeaderAllow,
  82. HEADER("OPTIONS, TRACE, GET, HEAD, POST"));
  83. }
  84. if (FAILED(hr = pW3Context->SendResponse(W3_FLAG_ASYNC)))
  85. {
  86. goto Failed;
  87. }
  88. return CONTEXT_STATUS_PENDING;
  89. Failed:
  90. pW3Context->SetErrorStatus(hr);
  91. pW3Response->SetStatus(HttpStatusServerError);
  92. pW3Context->SendResponse(W3_FLAG_SYNC);
  93. return CONTEXT_STATUS_CONTINUE;
  94. }