Skip to content

Commit 74fd1cb

Browse files
committed
New public method Utility.HttpGet() implemented to retrieve the HTTP(s) request for the GET verb
New public method Utility.HttpPOST() implemented to retrieve the HTTP(s) request for the POST verb
1 parent aa10d76 commit 74fd1cb

File tree

14 files changed

+55
-32
lines changed

14 files changed

+55
-32
lines changed

rls/API.Library.dll

0 Bytes
Binary file not shown.

rls/API.Library.pdb

2 KB
Binary file not shown.

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,6 @@ public class Common
8484
/// </summary>
8585
internal string NetworkUsername = null;
8686

87-
8887
/// <summary>
8988
/// Authenticate the user in the context
9089
/// </summary>

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

Lines changed: 12 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
using System;
33
using System.Collections.Generic;
44
using System.Configuration;
5-
using System.IO;
65
using System.Linq;
76
using System.Reflection;
87
using System.Text.RegularExpressions;
@@ -25,7 +24,7 @@ public class JSONRPC : Common, IHttpHandler, IRequiresSessionState
2524
/// <summary>
2625
/// GET request parameter
2726
/// </summary>
28-
internal const string JSONRPC_Container = "data";
27+
internal const string JSONRPC_GETparam = "data";
2928

3029
/// <summary>
3130
/// JSON-stat mimetype
@@ -175,43 +174,32 @@ private JSONRPC_Request ParseRequest(ref HttpContext context)
175174
{
176175
// Initialise requests
177176
string request = null;
178-
string requestGET = null;
179-
string requestPOST = null;
177+
string DATArequest = null;
178+
string POSTrequest = null;
180179

181-
try
182-
{
183-
// Read the request from GET
184-
requestGET = context.Request.QueryString[JSONRPC_Container];
185-
186-
// Read the request from POST
187-
StreamReader HttpReader = new StreamReader(context.Request.InputStream);
188-
requestPOST = HttpReader.ReadToEnd();
189-
}
190-
catch (Exception e)
191-
{
192-
Log.Instance.Fatal(e);
180+
// Read the request from GET
181+
DATArequest = Utility.HttpGET()[JSONRPC_GETparam];
193182

194-
JSONRPC_Error error = new JSONRPC_Error { code = -32700 };
195-
ParseError(ref context, null, error);
196-
}
183+
// Read the request from POST
184+
POSTrequest = Utility.HttpPOST();
197185

198186
// Check the query input exists
199-
if (string.IsNullOrWhiteSpace(requestGET)
200-
&& string.IsNullOrWhiteSpace(requestPOST))
187+
if (string.IsNullOrWhiteSpace(DATArequest)
188+
&& string.IsNullOrWhiteSpace(POSTrequest))
201189
{
202190
JSONRPC_Error error = new JSONRPC_Error { code = -32700 };
203191
ParseError(ref context, null, error);
204192
}
205193

206194
// POST request overrides GET one
207-
if (!string.IsNullOrWhiteSpace(requestPOST))
195+
if (!string.IsNullOrWhiteSpace(POSTrequest))
208196
{
209-
request = requestPOST;
197+
request = POSTrequest;
210198
Log.Instance.Info("Request type: POST");
211199
}
212200
else
213201
{
214-
request = requestGET;
202+
request = DATArequest;
215203
Log.Instance.Info("Request type: GET");
216204
}
217205

src/API.Library/Entities/Utility.cs

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -431,6 +431,42 @@ public static string GetUserAcceptLanguage()
431431
return null;
432432
}
433433
}
434+
435+
/// <summary>
436+
/// Get the HTTP request for the GET method
437+
/// </summary>
438+
/// <returns></returns>
439+
public static NameValueCollection HttpGET()
440+
{
441+
try
442+
{
443+
// Read the request from GET
444+
return HttpContext.Current.Request.QueryString;
445+
}
446+
catch (Exception e)
447+
{
448+
Log.Instance.Info(e);
449+
return null;
450+
}
451+
}
452+
453+
/// <summary>
454+
/// Get the HTTP request for the POST method
455+
/// </summary>
456+
/// <returns></returns>
457+
public static string HttpPOST()
458+
{
459+
try
460+
{
461+
// Read the request from POST
462+
return new StreamReader(HttpContext.Current.Request.InputStream).ReadToEnd();
463+
}
464+
catch (Exception e)
465+
{
466+
Log.Instance.Info(e);
467+
return null;
468+
}
469+
}
434470
#endregion
435471
}
436472
}

src/API.Library/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@
3232
// You can specify all the values or you can default the Build and Revision Numbers
3333
// by using the '*' as shown below:
3434
// [assembly: AssemblyVersion("1.0.*")]
35-
[assembly: AssemblyVersion("4.1.0")]
36-
[assembly: AssemblyFileVersion("4.1.0")]
35+
[assembly: AssemblyVersion("4.1.1")]
36+
[assembly: AssemblyFileVersion("4.1.1")]
3737

3838
// Configure log4net using the Web.config file by default
3939
[assembly: log4net.Config.XmlConfigurator(Watch = true)]

test/API.Test/API.Test.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,9 @@
7272
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
7373
</PropertyGroup>
7474
<ItemGroup>
75-
<Reference Include="API.Library, Version=4.1.0, Culture=neutral, processorArchitecture=MSIL">
75+
<Reference Include="API.Library, Version=4.1.1, Culture=neutral, processorArchitecture=MSIL">
7676
<SpecificVersion>False</SpecificVersion>
77-
<HintPath>..\packages\API.Library.4.1.0\API.Library.dll</HintPath>
77+
<HintPath>..\packages\API.Library.4.1.1\API.Library.dll</HintPath>
7878
</Reference>
7979
<Reference Include="Enyim.Caching, Version=2.16.0.0, Culture=neutral, PublicKeyToken=cec98615db04012e, processorArchitecture=MSIL">
8080
<HintPath>..\packages\EnyimMemcached.2.16.0\lib\net35\Enyim.Caching.dll</HintPath>

test/API.Test/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,5 @@
3131
//
3232
// You can specify all the values or you can default the Revision and Build Numbers
3333
// by using the '*' as shown below:
34-
[assembly: AssemblyVersion("4.0.1")]
35-
[assembly: AssemblyFileVersion("4.0.1")]
34+
[assembly: AssemblyVersion("4.1.1")]
35+
[assembly: AssemblyFileVersion("4.1.1")]

test/API.Test/Web.config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@
199199
**********************************************************************
200200
-->
201201
<!-- MemCacheD - Switch on [TRUE] or off [FALSE] the MemCacheD -->
202-
<add key="API_MEMCACHED_ENABLED" value="TRUE" />
202+
<add key="API_MEMCACHED_ENABLED" value="FALSE" />
203203
<!-- MemCacheD - Maximum validity in number of seconds that MemCacheD can handle (30 days = 2592000) -->
204204
<add key="API_MEMCACHED_MAX_VALIDITY" value="2592000" />
205205
<!-- MemCacheD - Salsa code to isolate the cache records form other applications or environments -->
Binary file not shown.

0 commit comments

Comments
 (0)