From fa549aded57234c5b8a281e75a979e127d3bbc31 Mon Sep 17 00:00:00 2001 From: Miguel Martinez Trivino Date: Tue, 5 Sep 2023 23:04:09 +0200 Subject: [PATCH 1/2] fix: show downloading message during redirect Signed-off-by: Miguel Martinez Trivino --- app/controlplane/internal/service/casredirect.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/app/controlplane/internal/service/casredirect.go b/app/controlplane/internal/service/casredirect.go index 9b4a02b37..667c1a1f5 100644 --- a/app/controlplane/internal/service/casredirect.go +++ b/app/controlplane/internal/service/casredirect.go @@ -153,7 +153,14 @@ func (s *CASRedirectService) HTTPDownload(ctx khttp.Context) error { } // perform redirect - http.Redirect(ctx.Response(), ctx.Request(), urlResponse.Result.Url, http.StatusTemporaryRedirect) + // In order ton show a redirect message in the page before the redirection, + // we need to use a Refresh Header instead of a vanilla redirect (via location change) + // We want to show a message because in some cases the download will be shown as downloadable and hence + // the UX for the user is like the browser got stuck + ctx.Response().Header().Set("Refresh", "1;url="+urlResponse.Result.Url) + ctx.Response().WriteHeader(http.StatusFound) + fmt.Fprintln(ctx.Response(), "Downloading...") + return nil } From f7a93ba4558641bc8e15d65823afcfa8d0eaf461 Mon Sep 17 00:00:00 2001 From: Miguel Martinez Trivino Date: Tue, 5 Sep 2023 23:06:17 +0200 Subject: [PATCH 2/2] fix: show downloading message during redirect Signed-off-by: Miguel Martinez Trivino --- app/controlplane/internal/service/casredirect.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controlplane/internal/service/casredirect.go b/app/controlplane/internal/service/casredirect.go index 667c1a1f5..9c1cc1494 100644 --- a/app/controlplane/internal/service/casredirect.go +++ b/app/controlplane/internal/service/casredirect.go @@ -159,7 +159,7 @@ func (s *CASRedirectService) HTTPDownload(ctx khttp.Context) error { // the UX for the user is like the browser got stuck ctx.Response().Header().Set("Refresh", "1;url="+urlResponse.Result.Url) ctx.Response().WriteHeader(http.StatusFound) - fmt.Fprintln(ctx.Response(), "Downloading...") + fmt.Fprintln(ctx.Response(), "Your download will begin shortly...") return nil }