diff --git a/src/AspNetCoreModuleV2/AspNetCore/Inc/applicationinfo.h b/src/AspNetCoreModuleV2/AspNetCore/Inc/applicationinfo.h index ecb85b0355..b21764d691 100644 --- a/src/AspNetCoreModuleV2/AspNetCore/Inc/applicationinfo.h +++ b/src/AspNetCoreModuleV2/AspNetCore/Inc/applicationinfo.h @@ -20,10 +20,9 @@ typedef HRESULT (WINAPI * PFN_ASPNETCORE_CREATE_APPLICATION)( - _In_ IHttpServer *pServer, - _In_ IHttpContext *pHttpContext, - _In_ PCWSTR pwzExeLocation, // TODO remove both pwzExeLocation and pHttpContext from this api - _Out_ IAPPLICATION **pApplication + _In_ IHttpServer *pServer, + _In_ IHttpApplication *pHttpApplication, + _Out_ IAPPLICATION **pApplication ); extern BOOL g_fRecycleProcessCalled; diff --git a/src/AspNetCoreModuleV2/AspNetCore/src/applicationinfo.cpp b/src/AspNetCoreModuleV2/AspNetCore/src/applicationinfo.cpp index 5fa4ca4db1..5cc5ea2f90 100644 --- a/src/AspNetCoreModuleV2/AspNetCore/src/applicationinfo.cpp +++ b/src/AspNetCoreModuleV2/AspNetCore/src/applicationinfo.cpp @@ -231,7 +231,8 @@ APPLICATION_INFO::EnsureApplicationCreated( RETURN_IF_FAILED(HRESULT_FROM_WIN32(ERROR_INVALID_FUNCTION)); } - RETURN_IF_FAILED(m_pfnAspNetCoreCreateApplication(m_pServer, pHttpContext, struExeLocation.QueryStr(), &pApplication)); + RETURN_IF_FAILED(m_pfnAspNetCoreCreateApplication(m_pServer, pHttpContext->GetApplication(), &pApplication)); + pApplication->SetParameter(L"InProcessExeLocation", struExeLocation.QueryStr()); m_pApplication = pApplication; } } diff --git a/src/AspNetCoreModuleV2/CommonLib/application.h b/src/AspNetCoreModuleV2/CommonLib/application.h index 0c0752f0c4..6025fdd0fb 100644 --- a/src/AspNetCoreModuleV2/CommonLib/application.h +++ b/src/AspNetCoreModuleV2/CommonLib/application.h @@ -40,6 +40,16 @@ public: } } + VOID + SetParameter( + _In_ LPCWSTR pzName, + _In_ LPCWSTR pzValue) + override + { + UNREFERENCED_PARAMETER(pzName); + UNREFERENCED_PARAMETER(pzValue); + } + protected: volatile APPLICATION_STATUS m_status = APPLICATION_STATUS::UNKNOWN; diff --git a/src/AspNetCoreModuleV2/CommonLib/iapplication.h b/src/AspNetCoreModuleV2/CommonLib/iapplication.h index f8c67a6309..f74ebc021c 100644 --- a/src/AspNetCoreModuleV2/CommonLib/iapplication.h +++ b/src/AspNetCoreModuleV2/CommonLib/iapplication.h @@ -46,4 +46,10 @@ public: CreateHandler( _In_ IHttpContext *pHttpContext, _Out_ IREQUEST_HANDLER **pRequestHandler) = 0; + + virtual + VOID + SetParameter( + _In_ LPCWSTR pzName, + _In_ LPCWSTR pzValue) = 0; }; diff --git a/src/AspNetCoreModuleV2/InProcessRequestHandler/dllmain.cxx b/src/AspNetCoreModuleV2/InProcessRequestHandler/dllmain.cxx index 2fba26d406..33dad24f03 100644 --- a/src/AspNetCoreModuleV2/InProcessRequestHandler/dllmain.cxx +++ b/src/AspNetCoreModuleV2/InProcessRequestHandler/dllmain.cxx @@ -82,13 +82,11 @@ BOOL APIENTRY DllMain(HMODULE hModule, return TRUE; } -// TODO remove pHttpContext from the CreateApplication call. HRESULT __stdcall CreateApplication( _In_ IHttpServer *pServer, - _In_ IHttpContext *pHttpContext, - _In_ PCWSTR pwzExeLocation, + _In_ IHttpApplication *pHttpApplication, _Out_ IAPPLICATION **ppApplication ) { @@ -101,7 +99,7 @@ CreateApplication( try { - hr = REQUESTHANDLER_CONFIG::CreateRequestHandlerConfig(pServer, pHttpContext->GetApplication(), &pConfig); + hr = REQUESTHANDLER_CONFIG::CreateRequestHandlerConfig(pServer, pHttpApplication, &pConfig); if (FAILED(hr)) { goto Finished; @@ -111,12 +109,6 @@ CreateApplication( pConfig = NULL; - hr = pApplication->Initialize(pwzExeLocation); - if (FAILED(hr)) - { - goto Finished; - } - *ppApplication = pApplication; } catch (std::bad_alloc&) diff --git a/src/AspNetCoreModuleV2/InProcessRequestHandler/inprocessapplication.cpp b/src/AspNetCoreModuleV2/InProcessRequestHandler/inprocessapplication.cpp index 70c535f0b3..4b214457e7 100644 --- a/src/AspNetCoreModuleV2/InProcessRequestHandler/inprocessapplication.cpp +++ b/src/AspNetCoreModuleV2/InProcessRequestHandler/inprocessapplication.cpp @@ -37,14 +37,6 @@ IN_PROCESS_APPLICATION::IN_PROCESS_APPLICATION( m_status = APPLICATION_STATUS::STARTING; } -HRESULT -IN_PROCESS_APPLICATION::Initialize( - PCWSTR pDotnetExeLocation -) -{ - return m_struExeLocation.Copy(pDotnetExeLocation); -} - IN_PROCESS_APPLICATION::~IN_PROCESS_APPLICATION() { diff --git a/src/AspNetCoreModuleV2/InProcessRequestHandler/inprocessapplication.h b/src/AspNetCoreModuleV2/InProcessRequestHandler/inprocessapplication.h index 0bd0ecf4d7..0713ff5016 100644 --- a/src/AspNetCoreModuleV2/InProcessRequestHandler/inprocessapplication.h +++ b/src/AspNetCoreModuleV2/InProcessRequestHandler/inprocessapplication.h @@ -23,11 +23,6 @@ public: ~IN_PROCESS_APPLICATION(); - HRESULT - Initialize( - PCWSTR pDotnetExeLocation - ); - __override VOID ShutDown(); @@ -54,6 +49,19 @@ public: _Out_ IREQUEST_HANDLER **pRequestHandler) override; + VOID + SetParameter( + _In_ LPCWSTR pzName, + _In_ LPCWSTR pzValue) + override + { + const auto exeLocationParameterName = L"InProcessExeLocation"; + if (_wcsicmp(pzName, exeLocationParameterName) == 0) + { + m_struExeLocation.Copy(pzValue); + } + } + // Executes the .NET Core process HRESULT ExecuteApplication( @@ -170,11 +178,6 @@ private: // used in testing static hostfxr_main_fn s_fMainCallback; - VOID - SetStdOut( - VOID - ); - static VOID ExecuteAspNetCoreProcess( diff --git a/src/AspNetCoreModuleV2/OutOfProcessRequestHandler/dllmain.cxx b/src/AspNetCoreModuleV2/OutOfProcessRequestHandler/dllmain.cxx index 625e884767..611e8d7e3f 100644 --- a/src/AspNetCoreModuleV2/OutOfProcessRequestHandler/dllmain.cxx +++ b/src/AspNetCoreModuleV2/OutOfProcessRequestHandler/dllmain.cxx @@ -260,25 +260,22 @@ BOOL APIENTRY DllMain(HMODULE hModule, return TRUE; } -// TODO remove pHttpContext from the CreateApplication call. HRESULT __stdcall CreateApplication( _In_ IHttpServer *pServer, - _In_ IHttpContext *pHttpContext, - _In_ PCWSTR pwzExeLocation, + _In_ IHttpApplication *pHttpApplication, _Out_ IAPPLICATION **ppApplication ) { HRESULT hr = S_OK; IAPPLICATION *pApplication = NULL; REQUESTHANDLER_CONFIG *pConfig = NULL; - UNREFERENCED_PARAMETER(pwzExeLocation); // Initialze some global variables here InitializeGlobalConfiguration(pServer); - hr = REQUESTHANDLER_CONFIG::CreateRequestHandlerConfig(pServer, pHttpContext->GetApplication(), &pConfig); + hr = REQUESTHANDLER_CONFIG::CreateRequestHandlerConfig(pServer, pHttpApplication, &pConfig); if (FAILED(hr)) { return hr; diff --git a/test/CommonLibTests/inprocess_application_tests.cpp b/test/CommonLibTests/inprocess_application_tests.cpp index 0467f33c4f..98326312f1 100644 --- a/test/CommonLibTests/inprocess_application_tests.cpp +++ b/test/CommonLibTests/inprocess_application_tests.cpp @@ -2,6 +2,7 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. #include "stdafx.h" + #include "inprocessapplication.h" #include "fakeclasses.h" @@ -18,7 +19,7 @@ namespace InprocessTests IN_PROCESS_APPLICATION *app = new IN_PROCESS_APPLICATION(server, requestHandlerConfig); { std::wstring exePath(L"hello"); - app->Initialize(exePath.c_str()); + app->SetParameter(L"InProcessExeLocation", exePath.c_str()); } ASSERT_STREQ(app->QueryExeLocation(), L"hello"); }