Skip to content

Commit

Permalink
Fix Content-Disposition header for HTTP reports with non-ASCII output…
Browse files Browse the repository at this point in the history
… file names.
  • Loading branch information
claudiamurialdo committed Feb 22, 2024
1 parent 8e4727e commit a5e76db
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions dotnet/src/dotnetframework/GxClasses/Model/GXWebProcedure.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ namespace GeneXus.Procedure
using System.Globalization;
using GeneXus.Http;
using GeneXus.Mime;
using System.Net.Mime;
#if NETCORE
using Microsoft.AspNetCore.Http;
#else
Expand All @@ -14,6 +15,7 @@ namespace GeneXus.Procedure

public class GXWebProcedure : GXHttpHandler
{
static readonly IGXLogger log = GXLoggerFactory.GetLogger<GXWebProcedure>();
protected int handle;

protected GXReportMetadata reportMetadata;
Expand Down Expand Up @@ -137,8 +139,19 @@ private void setOuputFileName()
{
fileType = outputType.ToLower();
}

context.HttpContext.Response.AddHeader(HttpHeader.CONTENT_DISPOSITION, $"inline; filename={fileName}.{fileType}");
try
{
ContentDisposition contentDisposition = new ContentDisposition
{
Inline = true,
FileName = $"{fileName}.{fileType}"
};
context.HttpContext.Response.AddHeader(HttpHeader.CONTENT_DISPOSITION, contentDisposition.ToString());
}
catch (Exception ex)
{
GXLogging.Warn(log, $"{HttpHeader.CONTENT_DISPOSITION} couldn't be set for {fileName}.{fileType}", ex);
}
}
}

Expand All @@ -152,9 +165,9 @@ protected bool initPrinter(String output, int gxXPage, int gxYPage, String iniFi
if (!Config.GetValueOf("LANGUAGE", out idiom))
idiom = "eng";
fileContentInline = true;
#if NETCORE

setOuputFileName();
#endif

getPrinter().GxRVSetLanguage(idiom);
int xPage = gxXPage;
int yPage = gxYPage;
Expand Down

0 comments on commit a5e76db

Please sign in to comment.