From e0e61672c5e367addf77f552ee6dd7e57b9150c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Standa=20Luke=C5=A1?= Date: Fri, 20 Dec 2024 23:32:46 +0100 Subject: [PATCH] v5 cleanup: Move HTTP requests to resources, file upload/return under /_dotvvm/ --- .../Hosting/DotvvmRequestContextExtensions.cs | 2 +- src/Framework/Framework/Hosting/HostingConstants.cs | 8 ++------ .../Middlewares/DotvvmReturnedFileMiddleware.cs | 2 +- .../Hosting/Middlewares/DotvvmRoutingMiddleware.cs | 1 + .../Redirect/RedirectPostbackConcurrencyViewModel.cs | 2 +- ...ServerSideStyleTests.AddResourceWithMasterPage.html | 6 +++--- .../testoutputs/SimpleControlTests.FileUpload.html | 2 +- .../ViewModulesServerSideTests.IncludeViewModule.html | 8 ++++---- ...ulesServerSideTests.IncludeViewModuleInControl.html | 10 +++++----- .../ApplicationInsights/RequestTelemetryFilter.cs | 2 +- .../MiniProfilerBuilderExtensions.cs | 2 +- .../MiniProfiler.Owin/MiniProfilerBuilderExtensions.cs | 2 +- 12 files changed, 22 insertions(+), 25 deletions(-) diff --git a/src/Framework/Framework/Hosting/DotvvmRequestContextExtensions.cs b/src/Framework/Framework/Hosting/DotvvmRequestContextExtensions.cs index 480aec52d4..a95c12a39f 100644 --- a/src/Framework/Framework/Hosting/DotvvmRequestContextExtensions.cs +++ b/src/Framework/Framework/Hosting/DotvvmRequestContextExtensions.cs @@ -262,7 +262,7 @@ public static async Task ReturnFileAsync(this IDotvvmRequestContext context, Str var downloadAttribute = attachmentDispositionType == "inline" ? null : fileName; var generatedFileId = await returnedFileStorage.StoreFileAsync(stream, metadata).ConfigureAwait(false); - context.SetRedirectResponse(context.TranslateVirtualPath("~/dotvvmReturnedFile?id=" + generatedFileId), downloadName: downloadAttribute); + context.SetRedirectResponse(context.TranslateVirtualPath("~/_dotvvm/returnedFile?id=" + generatedFileId), downloadName: downloadAttribute); throw new DotvvmInterruptRequestExecutionException(InterruptReason.ReturnFile, fileName); } diff --git a/src/Framework/Framework/Hosting/HostingConstants.cs b/src/Framework/Framework/Hosting/HostingConstants.cs index c30a77f526..80dd683f59 100644 --- a/src/Framework/Framework/Hosting/HostingConstants.cs +++ b/src/Framework/Framework/Hosting/HostingConstants.cs @@ -7,13 +7,9 @@ public class HostingConstants public const string DotvvmRequestContextKey = "dotvvm.requestContext"; public const string DotvvmIsErrorHandlingKey = "dotvvm.isErrorHandling"; - public const string GlobalizeCultureUrlPath = "dotvvmGlobalizeCulture"; public const string GlobalizeCultureUrlIdParameter = "id"; - public const string ResourceRouteName = "dotvvmResource"; - public const string ResourceHandlerUrl = "~/dotvvmEmbeddedResource?name={0}&assembly={1}"; - public const string ResourceHandlerMatchUrl = "dotvvmEmbeddedResource"; - - public const string FileUploadHandlerMatchUrl = "dotvvmFileUpload"; + public const string ResourceRouteName = "_dotvvm/resource"; + public const string FileUploadHandlerMatchUrl = "_dotvvm/fileUpload"; public const string CsrfTokenMatchUrl = "___dotvvm-create-csrf-token___"; public const string SpaContentPlaceHolderHeaderName = "X-DotVVM-SpaContentPlaceHolder"; diff --git a/src/Framework/Framework/Hosting/Middlewares/DotvvmReturnedFileMiddleware.cs b/src/Framework/Framework/Hosting/Middlewares/DotvvmReturnedFileMiddleware.cs index 743351ddf9..c7c60333a6 100644 --- a/src/Framework/Framework/Hosting/Middlewares/DotvvmReturnedFileMiddleware.cs +++ b/src/Framework/Framework/Hosting/Middlewares/DotvvmReturnedFileMiddleware.cs @@ -19,7 +19,7 @@ public async Task Handle(IDotvvmRequestContext request) { var url = DotvvmMiddlewareBase.GetCleanRequestUrl(request.HttpContext); - if (url.StartsWith("dotvvmReturnedFile", StringComparison.Ordinal)) + if (url.StartsWith("_dotvvm/returnedFile", StringComparison.Ordinal)) { await ValidateSecFetch(request); await RenderReturnedFile(request.HttpContext, request.Services.GetRequiredService()); diff --git a/src/Framework/Framework/Hosting/Middlewares/DotvvmRoutingMiddleware.cs b/src/Framework/Framework/Hosting/Middlewares/DotvvmRoutingMiddleware.cs index 70f94a12d5..691e6a1cff 100644 --- a/src/Framework/Framework/Hosting/Middlewares/DotvvmRoutingMiddleware.cs +++ b/src/Framework/Framework/Hosting/Middlewares/DotvvmRoutingMiddleware.cs @@ -28,6 +28,7 @@ public class DotvvmRoutingMiddleware : IMiddleware /// private static bool TryParseGooglebotHashbangEscapedFragment(string queryString, [System.Diagnostics.CodeAnalysis.MaybeNullWhen(false)] out string url) { + // TODO: remove, does not work if (queryString?.StartsWith(GooglebotHashbangEscapedFragment, StringComparison.Ordinal) == true) { url = queryString.Substring(GooglebotHashbangEscapedFragment.Length); diff --git a/src/Samples/Common/ViewModels/FeatureSamples/Redirect/RedirectPostbackConcurrencyViewModel.cs b/src/Samples/Common/ViewModels/FeatureSamples/Redirect/RedirectPostbackConcurrencyViewModel.cs index 5eb95c352b..1bda699557 100644 --- a/src/Samples/Common/ViewModels/FeatureSamples/Redirect/RedirectPostbackConcurrencyViewModel.cs +++ b/src/Samples/Common/ViewModels/FeatureSamples/Redirect/RedirectPostbackConcurrencyViewModel.cs @@ -58,7 +58,7 @@ public async Task GetFileCustom() var stream = new MemoryStream("test custom file"u8.ToArray()); var generatedFileId = await returnedFileStorage.StoreFileAsync(stream, metadata).ConfigureAwait(false); - var url = Context.TranslateVirtualPath("~/dotvvmReturnedFile?id=" + generatedFileId); + var url = Context.TranslateVirtualPath("~/_dotvvm/returnedFile?id=" + generatedFileId); Context.RedirectToUrl(url); } } diff --git a/src/Tests/ControlTests/testoutputs/ServerSideStyleTests.AddResourceWithMasterPage.html b/src/Tests/ControlTests/testoutputs/ServerSideStyleTests.AddResourceWithMasterPage.html index a9d7aab229..ecd9ae645d 100644 --- a/src/Tests/ControlTests/testoutputs/ServerSideStyleTests.AddResourceWithMasterPage.html +++ b/src/Tests/ControlTests/testoutputs/ServerSideStyleTests.AddResourceWithMasterPage.html @@ -5,13 +5,13 @@ - + - + - + diff --git a/src/Tests/ControlTests/testoutputs/SimpleControlTests.FileUpload.html b/src/Tests/ControlTests/testoutputs/SimpleControlTests.FileUpload.html index 04a1e16a15..313e2074ec 100644 --- a/src/Tests/ControlTests/testoutputs/SimpleControlTests.FileUpload.html +++ b/src/Tests/ControlTests/testoutputs/SimpleControlTests.FileUpload.html @@ -7,7 +7,7 @@ Upload - + diff --git a/src/Tests/ControlTests/testoutputs/ViewModulesServerSideTests.IncludeViewModule.html b/src/Tests/ControlTests/testoutputs/ViewModulesServerSideTests.IncludeViewModule.html index abb0be5986..36527a7a69 100644 --- a/src/Tests/ControlTests/testoutputs/ViewModulesServerSideTests.IncludeViewModule.html +++ b/src/Tests/ControlTests/testoutputs/ViewModulesServerSideTests.IncludeViewModule.html @@ -2,17 +2,17 @@ - + - + - + - + + - + - + - + - +