Skip to content

Commit bb89980

Browse files
committed
6.1.11 RTM
- [BUG FIX] static now returns 304 if not modified - [BUG FIX] restful cookie bug
1 parent 908eab1 commit bb89980

File tree

8 files changed

+41
-60
lines changed

8 files changed

+41
-60
lines changed

rls/log4net.config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
<!-- Email's subject -->
2929
<subject type="log4net.Util.PatternString" value="ApplicationsDivision error" />
3030
<!-- SMTP IP address -->
31-
<smtpHost value="3.1.2.22" />
31+
<smtpHost value="" />
3232
<!-- SMTP IP port -->
3333
<port value="25" />
3434
<authentication value="None" />

rls/packages/API.Library.6.1.11.nupkg

69.6 KB
Binary file not shown.

src/API.Library/API.Library.csproj

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,13 @@
1212
<PackageId>API.Library</PackageId>
1313
<Product>API Library</Product>
1414
<Copyright>Central Statistics Office, Ireland</Copyright>
15-
<Version>6.1.10</Version>
15+
<Version>6.1.11</Version>
1616
<Authors>Central Statistics Office, Ireland</Authors>
1717
<SignAssembly>False</SignAssembly>
1818
<RepositoryUrl>https://github.com/CSOIreland/Server-API-Library</RepositoryUrl>
1919
<PackageReleaseNotes>
20-
- [ENHANCEMENT] adding new ExecuteCustomReaderProcedureSetup ado function which returns an SLQ command object
21-
- [BUG FIX] no longer serializing responses for static, restful and head requests
22-
- [BUG FIX] memcache cas flush
23-
- [ENHANCEMENT] updated firebaseadmin
24-
- [ENHANCEMENT] updated Microsoft.Extensions.Logging.Log4Net.AspNetCore
25-
- [ENHANCEMENT] added ConsoleConfiguration as a way to setup console apps easily
26-
- [ENHANCEMENT] html sanitizer updated package as had vulnerability
27-
- [ENHANCEMENT] html sanitizer keys removed from appsettings and added to apiconfig
20+
- [BUG FIX] static now returns 304 if not modified
21+
- [BUG FIX] restful cookie bug
2822
</PackageReleaseNotes>
2923
<RestorePackagesWithLockFile>true</RestorePackagesWithLockFile>
3024
<RestoreLockedMode>true</RestoreLockedMode>

src/API.Library/Entities/API.Common.cs

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,6 @@ public class Common
3535
/// </summary>
3636
internal const string AUTHENTICATION_TYPE_ANY = "ANY";
3737

38-
/// <summary>
39-
/// Success response (case sensitive)
40-
/// </summary>
41-
// public static string success = ApiServicesHelper.ApiConfiguration.Settings["API_SUCCESS"];
42-
4338
/// <summary>
4439
/// Active Directory User Principal
4540
/// </summary>
@@ -435,7 +430,31 @@ internal async Task returnResponseAsync(HttpContext context, string message, Can
435430
}
436431
}
437432

438-
}
433+
/// <summary>
434+
/// Determines if cookie is not empty and adds name and value
435+
/// </summary>
436+
/// <param name="httpContext"></param>
437+
internal Cookie CheckCookie(string SessionCookieName, HttpContext httpContext)
438+
{
439+
//add a cookie for testing
440+
//httpContext.Request.Headers.Add("Cookie", "session=\"84c2f0b319460ee991924908198d46795049c83f1ebdfcaf90bd899c8d9d0bd2\";");
441+
442+
Cookie sessionCookie = new Cookie();
443+
444+
if (!string.IsNullOrEmpty(SessionCookieName))
445+
{
446+
//need to create a cookie using the value and the SessionCookieName
447+
string testSessionCookieValue = httpContext.Request.Cookies[SessionCookieName];
448+
449+
if (!string.IsNullOrEmpty(testSessionCookieValue))
450+
{
451+
sessionCookie.Name = SessionCookieName;
452+
sessionCookie.Value = testSessionCookieValue;
453+
}
454+
}
455+
return sessionCookie;
456+
}
457+
}
439458

440459
/// <summary>
441460
/// Clone the UserPrincipal object structure for serialisation & deserialisation

src/API.Library/Entities/API.JSONRPC.cs

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -77,25 +77,11 @@ public async Task ProcessRequest(HttpContext httpContext, CancellationTokenSourc
7777
JSONRPC_Error error = new JSONRPC_Error { code = -32001, data = "The system is currently under maintenance." };
7878
await ParseError(httpContext, JSONRPC_Request.id, error, apiCancellationToken);
7979
}
80-
80+
8181
string SessionCookieName = ApiServicesHelper.ApiConfiguration.Settings["API_SESSION_COOKIE"];
82-
83-
//add a cookie for testing
84-
//httpContext.Request.Headers.Add("Cookie", "session=\"84c2f0b319460ee991924908198d46795049c83f1ebdfcaf90bd899c8d9d0bd2\";");
85-
82+
8683
// Get Session Cookie
87-
Cookie sessionCookie = new Cookie();
88-
if (!string.IsNullOrEmpty(SessionCookieName))
89-
{
90-
//need to create a cookie using the value and the SessionCookieName
91-
string testSessionCookieValue = httpContext.Request.Cookies[SessionCookieName];
92-
93-
if (!string.IsNullOrEmpty(testSessionCookieValue))
94-
{
95-
sessionCookie.Name = SessionCookieName;
96-
sessionCookie.Value = testSessionCookieValue;
97-
}
98-
}
84+
Cookie sessionCookie = CheckCookie(SessionCookieName,httpContext);
9985

10086
JSONRPC_Output result = null;
10187

src/API.Library/Entities/API.RESTful.cs

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -67,19 +67,7 @@ public async Task ProcessRequest(HttpContext httpContext, CancellationTokenSourc
6767

6868
string SessionCookieName = ApiServicesHelper.ApiConfiguration.Settings["API_SESSION_COOKIE"];
6969
// Get Session Cookie
70-
Cookie sessionCookie = new Cookie();
71-
sessionCookie = null;
72-
73-
if (!string.IsNullOrEmpty(SessionCookieName))
74-
{
75-
//need to create a cookie using the value and the SessionCookieName
76-
var testSessionCookieValue = httpContext.Request.Cookies[SessionCookieName];
77-
if (!string.IsNullOrEmpty(testSessionCookieValue))
78-
{
79-
sessionCookie.Name = SessionCookieName;
80-
sessionCookie.Value = testSessionCookieValue;
81-
}
82-
}
70+
Cookie sessionCookie = CheckCookie(SessionCookieName, httpContext);
8371

8472
IResponseOutput result = null;
8573

@@ -211,7 +199,7 @@ private async Task ParseError(HttpContext context, HttpStatusCode statusCode, Ca
211199
Log.Instance.Info("IP: " + ApiServicesHelper.WebUtility.GetIP() + ", Status Code: " + statusCode.ToString() + ", Status Description: " + statusDescription);
212200

213201
if (!string.IsNullOrEmpty(statusDescription))
214-
await returnResponseAsync(context, Utility.JsonSerialize_IgnoreLoopingReference(statusDescription), sourceToken, statusCode);
202+
await returnResponseAsync(context, statusDescription, sourceToken, statusCode);
215203
}
216204

217205
/// <summary>

src/API.Library/Entities/API.Static.cs

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
1-
using Azure;
2-
using Microsoft.AspNetCore.Http;
3-
using Microsoft.AspNetCore.Mvc;
1+
using Microsoft.AspNetCore.Http;
42
using System.Collections.Specialized;
5-
using System.Diagnostics;
63
using System.Dynamic;
74
using System.Net;
8-
using System.Net.Http;
95
using System.Net.Mime;
106
using System.Reflection;
117
using System.Text.RegularExpressions;
@@ -55,8 +51,9 @@ public async Task ProcessRequest(HttpContext httpContext, CancellationTokenSourc
5551
if (!string.IsNullOrEmpty(rawIfModifiedSince))
5652
{
5753
httpContext.Response.StatusCode = StatusCodes.Status304NotModified;
54+
5855
// Do not process the request at all, stop here.
59-
return;
56+
await returnResponseAsync(httpContext, "", apiCancellationToken,HttpStatusCode.NotModified , false);
6057
}
6158

6259
try
@@ -92,14 +89,11 @@ public async Task ProcessRequest(HttpContext httpContext, CancellationTokenSourc
9289
}
9390
else if (result.statusCode == HttpStatusCode.OK)
9491
{
95-
//
92+
9693
httpContext.Response.ContentType = result.mimeType;
9794
httpContext.Response.Headers.Add("Expires", DateTime.Now.AddYears(1).ToString());
9895
httpContext.Response.Headers.Add("Last-Modified", DateTime.Now.ToString());
9996

100-
//httpContext.Response.Cache.SetLastModified(DateTime.Now);
101-
//httpContext.Response.Cache.SetExpires(DateTime.Now.AddYears(1));
102-
10397
if (!string.IsNullOrEmpty(result.fileName))
10498
{
10599
httpContext.Response.Headers.Add("Content-Disposition", new ContentDisposition { Inline = true, FileName = result.fileName }.ToString());
@@ -114,7 +108,7 @@ public async Task ProcessRequest(HttpContext httpContext, CancellationTokenSourc
114108
await returnResponseAsync(httpContext, fullFileName, apiCancellationToken, HttpStatusCode.OK,true);
115109
}
116110
else
117-
{
111+
{
118112
await returnResponseAsync(httpContext, result.response, apiCancellationToken, HttpStatusCode.OK);
119113
}
120114
}
@@ -150,7 +144,7 @@ private async Task ParseError(HttpContext context, HttpStatusCode statusCode,Can
150144
Log.Instance.Info("IP: " + ApiServicesHelper.WebUtility.GetIP() + ", Status Code: " + statusCode.ToString() + ", Status Description: " + statusDescription);
151145

152146
if (!string.IsNullOrEmpty(statusDescription))
153-
await returnResponseAsync(context, Utility.JsonSerialize_IgnoreLoopingReference(statusDescription), sourceToken, statusCode);
147+
await returnResponseAsync(context, statusDescription, sourceToken, statusCode);
154148

155149

156150
}

src/publishPackage.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@ Set-Location $curDir\API.Library\bin\$ReleaseType
1414
$curDir1 = Get-Location
1515

1616

17-
dotnet nuget push $PackageName --api-key $apiKey --source "https://nuget.pkg.github.com/CSOIreland/index.json"
17+
dotnet nuget push $PackageName --api-key $apiKey --source $PackageRepoLoc
1818

1919
pause

0 commit comments

Comments
 (0)