Skip to content

Commit

Permalink
keep using AddHeader for .NET (Core) as it ensures a safe configuration.
Browse files Browse the repository at this point in the history
It sets the header if !response.HasStarted.
  • Loading branch information
claudiamurialdo committed Jul 6, 2023
1 parent 9511570 commit ac327a0
Showing 1 changed file with 36 additions and 30 deletions.
66 changes: 36 additions & 30 deletions dotnet/src/dotnetframework/GxClasses/Core/GXApplication.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ namespace GeneXus.Application
using System.Threading;
using System.Security.Claims;
using System.Security;

public interface IGxContext
{
void disableOutput();
Expand Down Expand Up @@ -2429,37 +2429,39 @@ public byte SetHeader(string name, string value)

private void SetCustomHttpHeader(string name, string value)
{
#if !NETCORE
switch (name.ToUpper())
try
{
case "CACHE-CONTROL":
var Cache = _HttpContext.Response.Cache;
string[] values = value.Split(',');
foreach (string v in values)
{
switch (v.Trim().ToUpper())
#if !NETCORE
switch (name.ToUpper())
{
case "CACHE-CONTROL":
var Cache = _HttpContext.Response.Cache;
string[] values = value.Split(',');
foreach (string v in values)
{
case "PUBLIC":
Cache.SetCacheability(HttpCacheability.Public);
break;
case "PRIVATE":
Cache.SetCacheability(HttpCacheability.Private);
break;
case "NO-CACHE":
Cache.SetCacheability(HttpCacheability.NoCache);
break;
case "NO-STORE":
Cache.AppendCacheExtension("no-store, must-revalidate");
break;
default:
break;
switch (v.Trim().ToUpper())
{
case "PUBLIC":
Cache.SetCacheability(HttpCacheability.Public);
break;
case "PRIVATE":
Cache.SetCacheability(HttpCacheability.Private);
break;
case "NO-CACHE":
Cache.SetCacheability(HttpCacheability.NoCache);
break;
case "NO-STORE":
Cache.AppendCacheExtension("no-store, must-revalidate");
break;
default:
break;
}
}
}
break;
default:
_HttpContext.Response.Headers[name]=value;
break;
}
break;
default:
_HttpContext.Response.Headers[name] = value;
break;
}
#else
switch (name.ToUpper())
{
Expand All @@ -2478,10 +2480,14 @@ private void SetCustomHttpHeader(string name, string value)
}
break;
default:
_HttpContext.Response.Headers[name] = value;
_HttpContext.Response.AddHeader(name, value);
break;
}
#endif
}catch (Exception ex)
{
GXLogging.Error(log, ex, "Error adding header ", name, value);
}
}

public string GetHeader(string name)
Expand Down

0 comments on commit ac327a0

Please sign in to comment.