Skip to content

Commit 1804ef6

Browse files
Make GXHttpHandler a GXBaseObject in order to move common code to base class GXBaseObject as in .NET (core).
1 parent 0b3ae01 commit 1804ef6

File tree

1 file changed

+3
-194
lines changed
  • dotnet/src/dotnetframework/GxClasses/Middleware

1 file changed

+3
-194
lines changed

dotnet/src/dotnetframework/GxClasses/Middleware/GXHttp.cs

Lines changed: 3 additions & 194 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,7 @@ namespace GeneXus.Http
4545
using Web.Security;
4646
using System.Web.SessionState;
4747
#endif
48-
#if NETCORE
4948
public abstract class GXHttpHandler : GXBaseObject, IHttpHandler
50-
#else
51-
public abstract class GXHttpHandler : IHttpHandler
52-
#endif
5349
{
5450
static readonly ILog log = log4net.LogManager.GetLogger(typeof(GeneXus.Http.GXHttpHandler));
5551
internal const string GX_AJAX_REQUEST_HEADER = "GxAjaxRequest";
@@ -68,30 +64,11 @@ public abstract class GXHttpHandler : IHttpHandler
6864
private Exception workerException;
6965
private bool firstParConsumed = false;
7066
private StringDictionary customCSSContent = new StringDictionary();
71-
#if !NETCORE
72-
[System.Diagnostics.CodeAnalysis.SuppressMessage("GxFxCopRules", "CR1000:EnforceThreadSafeType")]
73-
private Dictionary<string, string> callTargetsByObject = new Dictionary<string, string>();
74-
#endif
7567
public GXHttpHandler()
7668
{
7769
initpars();
7870
}
7971

80-
#if !NETCORE
81-
protected virtual void ExecutePrivate()
82-
{
83-
84-
}
85-
protected virtual void ExecuteImpl()
86-
{
87-
ExecutePrivate();
88-
}
89-
protected virtual string[] GetParameters()
90-
{
91-
return null;
92-
}
93-
94-
#endif
9572
public virtual void SetPrefix(string s)
9673
{
9774
}
@@ -227,10 +204,6 @@ private static bool IsNumericType(Type t)
227204
}
228205
}
229206

230-
#if !NETCORE
231-
protected IGxContext _Context;
232-
bool _isMain;
233-
#endif
234207
bool _isStatic;
235208
string staticContentBase;
236209

@@ -287,14 +260,8 @@ private bool IsFullAjaxRequest(HttpContext httpContext)
287260
public virtual void initialize_properties() { throw new Exception("The method or operation is not implemented."); }
288261
public virtual void webExecute() { throw new Exception("The method or operation is not implemented."); }
289262
public virtual void initialize() { throw new Exception("The method or operation is not implemented."); }
290-
#if !NETCORE
291-
public virtual void cleanup() { }
292-
#endif
293263
public virtual bool SupportAjaxEvent() { return false; }
294264
public virtual String AjaxOnSessionTimeout() { return "Ignore"; }
295-
#if !NETCORE
296-
virtual public bool UploadEnabled() { return false; }
297-
#endif
298265
#if NETCORE
299266
public void DoAjaxLoad(int SId, GXWebRow row)
300267
{
@@ -1043,15 +1010,6 @@ private bool redirect(IGxContext context)
10431010
protected virtual void createObjects() { throw new Exception("The method or operation is not implemented."); }
10441011
public virtual String GetPgmname() { throw new Exception("The method or operation is not implemented."); }
10451012
public virtual String GetPgmdesc() { throw new Exception("The method or operation is not implemented."); }
1046-
#if !NETCORE
1047-
protected virtual bool IntegratedSecurityEnabled { get { return false; } }
1048-
protected virtual GAMSecurityLevel IntegratedSecurityLevel { get { return 0; } }
1049-
[Obsolete("IntegratedSecurityPermissionName is deprecated, it is here for compatibility. Use ExecutePermissionPrefix instead.", false)]
1050-
protected virtual string IntegratedSecurityPermissionName { get { return string.Empty; } }
1051-
protected virtual string ExecutePermissionPrefix { get { return string.Empty; } }
1052-
public bool IntegratedSecurityEnabled2 { get { return IntegratedSecurityEnabled; } }
1053-
public GAMSecurityLevel IntegratedSecurityLevel2 { get { return IntegratedSecurityLevel; } }
1054-
#endif
10551013
private bool disconnectUserAtCleanup;
10561014
private bool validEncryptedParm;
10571015

@@ -1318,11 +1276,7 @@ public bool DisconnectAtCleanup
13181276
get { return disconnectUserAtCleanup; }
13191277
set { disconnectUserAtCleanup = value; }
13201278
}
1321-
#if NETCORE
13221279
public override IGxContext context
1323-
#else
1324-
public IGxContext context
1325-
#endif
13261280
{
13271281
set
13281282
{
@@ -1456,60 +1410,6 @@ protected virtual void ValidateSpaRequest()
14561410
sendSpaHeaders();
14571411
}
14581412
}
1459-
#if !NETCORE
1460-
1461-
protected string GetEncryptedHash(string value, string key)
1462-
{
1463-
return Encrypt64(GXUtil.GetHash(WebSecurityHelper.StripInvalidChars(value), Cryptography.Constants.SecurityHashAlgorithm), key);
1464-
}
1465-
1466-
protected string Encrypt64(string value, string key)
1467-
{
1468-
return Encrypt64(value, key, false);
1469-
}
1470-
private string Encrypt64(string value, string key, bool safeEncoding)
1471-
{
1472-
string sRet = string.Empty;
1473-
try
1474-
{
1475-
sRet = Crypto.Encrypt64(value, key, safeEncoding);
1476-
}
1477-
catch (InvalidKeyException)
1478-
{
1479-
context.SetCookie("GX_SESSION_ID", string.Empty, string.Empty, DateTime.MinValue, string.Empty, context.GetHttpSecure());
1480-
GXLogging.Error(log, "440 Invalid encryption key");
1481-
SendResponseStatus(440, "Session timeout");
1482-
}
1483-
return sRet;
1484-
}
1485-
protected string UriEncrypt64(string value, string key)
1486-
{
1487-
return Encrypt64(value, key, true);
1488-
}
1489-
protected string Decrypt64(string value, string key)
1490-
{
1491-
return Decrypt64(value, key, false);
1492-
}
1493-
private string Decrypt64(string value, string key, bool safeEncoding)
1494-
{
1495-
String sRet = string.Empty;
1496-
try
1497-
{
1498-
sRet = Crypto.Decrypt64(value, key, safeEncoding);
1499-
}
1500-
catch (InvalidKeyException)
1501-
{
1502-
context.SetCookie("GX_SESSION_ID", string.Empty, string.Empty, DateTime.MinValue, string.Empty, context.GetHttpSecure());
1503-
GXLogging.Error(log, "440 Invalid encryption key");
1504-
SendResponseStatus(440, "Session timeout");
1505-
}
1506-
return sRet;
1507-
}
1508-
protected string UriDecrypt64(string value, string key)
1509-
{
1510-
return Decrypt64(value, key, true);
1511-
}
1512-
#endif
15131413
protected string DecryptAjaxCall(string encrypted)
15141414
{
15151415
this.validEncryptedParm = false;
@@ -1561,24 +1461,16 @@ protected void SendResponseStatus(HttpStatusCode statusCode)
15611461
SendResponseStatus((int)statusCode, string.Empty);
15621462
}
15631463

1564-
1565-
#if !NETCORE
1566-
protected void SendResponseStatus(int statusCode, string statusDescription)
1464+
protected override void SendResponseStatus(int statusCode, string statusDescription)
15671465
{
15681466
context.HttpContext.Response.StatusCode = statusCode;
1467+
#if !NETCORE
15691468
if (!string.IsNullOrEmpty(statusDescription))
15701469
context.HttpContext.Response.StatusDescription = statusDescription;
1470+
#endif
15711471
this.setAjaxCallMode();
15721472
this.disableOutput();
15731473
}
1574-
#else
1575-
protected override void SendResponseStatus(int statusCode, string statusDescription)
1576-
{
1577-
context.HttpContext.Response.StatusCode = statusCode;
1578-
this.setAjaxCallMode();
1579-
this.disableOutput();
1580-
}
1581-
#endif
15821474
private void SendReferer()
15831475
{
15841476
context.httpAjaxContext.ajax_rsp_assign_hidden("sCallerURL", context.GetReferer());
@@ -1860,11 +1752,6 @@ public virtual bool UseBigStack()
18601752

18611753
#if !NETCORE
18621754
private const int STACKSIZE = 1024 * 1024 * 2;
1863-
public bool IsMain
1864-
{
1865-
set { _isMain = value; }
1866-
get { return _isMain; }
1867-
}
18681755
#endif
18691756

18701757

@@ -2453,12 +2340,6 @@ public void DeletePostValuePrefix(string sPrefix)
24532340
FormVars.Remove(key);
24542341
}
24552342
}
2456-
#if !NETCORE
2457-
public virtual string UrlEncode(string s)
2458-
{
2459-
return GXUtil.UrlEncode(s);
2460-
}
2461-
#endif
24622343
public void gxhtml_str()
24632344
{
24642345
_Write("<TR>");
@@ -2471,20 +2352,6 @@ public void flushBuffer()
24712352
{
24722353

24732354
}
2474-
#if !NETCORE
2475-
public string formatLink(string jumpURL)
2476-
{
2477-
return formatLink(jumpURL, Array.Empty<object>(), Array.Empty<string>());
2478-
}
2479-
protected string formatLink(string jumpURL, string[] parms, string[] parmsName)
2480-
{
2481-
return URLRouter.GetURLRoute(jumpURL, parms, parmsName, context.GetScriptPath());
2482-
}
2483-
protected string formatLink(string jumpURL, object[] parms, string[] parmsName)
2484-
{
2485-
return URLRouter.GetURLRoute(jumpURL, parms, parmsName, context.GetScriptPath());
2486-
}
2487-
#endif
24882355
public void Msg(string s)
24892356
{
24902357
GX_msglist.addItem(s);
@@ -2656,58 +2523,6 @@ public void getMultimediaValue(string InternalName, ref string BlobVar, ref stri
26562523
}
26572524
}
26582525

2659-
#if !NETCORE
2660-
public void SetCallTarget(string objClass, string target)
2661-
{
2662-
callTargetsByObject[objClass.ToLower().Replace("\\", ".")] = target.ToLower();
2663-
}
2664-
private string GetCallTargetFromUrl(string url)
2665-
{
2666-
Uri parsedUri;
2667-
if (Uri.TryCreate(url, UriKind.RelativeOrAbsolute, out parsedUri))
2668-
{
2669-
if (parsedUri.IsAbsoluteUri || (!parsedUri.IsAbsoluteUri && Uri.TryCreate(context.HttpContext.Request.Url, url, out parsedUri)))
2670-
{
2671-
string uriPath = parsedUri.GetComponents(UriComponents.Path, UriFormat.SafeUnescaped);
2672-
int slashPos = uriPath.LastIndexOf('/');
2673-
if (slashPos >= 0)
2674-
uriPath = uriPath.Substring(slashPos + 1);
2675-
string objClass = RemoveExtensionFromUrlPath(uriPath).ToLower();
2676-
string target;
2677-
if (callTargetsByObject.TryGetValue(objClass, out target) && ShouldLoadTarget(target))
2678-
return target;
2679-
}
2680-
}
2681-
return string.Empty;
2682-
}
2683-
2684-
public void CallWebObject(string url)
2685-
{
2686-
string target = GetCallTargetFromUrl(url);
2687-
if (String.IsNullOrEmpty(target))
2688-
{
2689-
context.wjLoc = url;
2690-
}
2691-
else
2692-
{
2693-
JObject cmdParms = new JObject();
2694-
cmdParms.Put("url", url);
2695-
cmdParms.Put("target", target);
2696-
context.httpAjaxContext.appendAjaxCommand("calltarget", cmdParms);
2697-
}
2698-
}
2699-
private string RemoveExtensionFromUrlPath(string urlPath)
2700-
{
2701-
if (urlPath.EndsWith(".aspx"))
2702-
return urlPath.Substring(0, urlPath.Length - 5);
2703-
return urlPath;
2704-
}
2705-
private bool ShouldLoadTarget(string target)
2706-
{
2707-
return (target == "top" || target == "right" || target == "bottom" || target == "left");
2708-
}
2709-
#endif
2710-
27112526
private XMLPrefixes currentNamespacePrefixes = new XMLPrefixes();
27122527

27132528
public void SetNamedPrefixesFromReader(GXXMLReader rdr)
@@ -2731,12 +2546,6 @@ public void PrepareForReuse()
27312546
{
27322547
((GxContext)this.context).ClearJavascriptSources();
27332548
}
2734-
#if !NETCORE
2735-
public virtual void handleException(String gxExceptionType, String gxExceptionDetails, String gxExceptionStack)
2736-
{
2737-
2738-
}
2739-
#endif
27402549

27412550
private Diagnostics.GXDebugInfo dbgInfo;
27422551
protected void initialize(int objClass, int objId, int dbgLines, long hash)

0 commit comments

Comments
 (0)