Skip to content

Commit 7436527

Browse files
committed
Implement message payload compression.
Implemented message payload compression.
1 parent a51acff commit 7436527

14 files changed

Lines changed: 38 additions & 13 deletions

File tree

Code/Sif3Framework/Sif.Framework/Model/Settings/ConfigFileBasedFrameworkSettings.cs

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2015 Systemic Pty Ltd
2+
* Copyright 2016 Systemic Pty Ltd
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -14,14 +14,9 @@
1414
* limitations under the License.
1515
*/
1616

17-
using log4net;
1817
using Sif.Framework.Model.Infrastructure;
19-
using Sif.Framework.Utils;
2018
using System;
21-
using System.Collections.Generic;
2219
using System.Configuration;
23-
using System.Linq;
24-
using System.Reflection;
2520

2621
namespace Sif.Framework.Model.Settings
2722
{
@@ -31,7 +26,6 @@ namespace Sif.Framework.Model.Settings
3126
/// </summary>
3227
abstract class ConfigFileBasedFrameworkSettings : IFrameworkSettings
3328
{
34-
private static readonly ILog log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
3529
private Configuration configuration;
3630

3731
/// <summary>
@@ -171,6 +165,19 @@ public string AuthenticationMethod
171165

172166
}
173167

168+
/// <summary>
169+
/// <see cref="Sif.Framework.Model.Settings.IFrameworkSettings.CompressPayload"/>
170+
/// </summary>
171+
public bool CompressPayload
172+
{
173+
174+
get
175+
{
176+
return GetBooleanSetting(SettingsPrefix + ".payload.compress", false);
177+
}
178+
179+
}
180+
174181
/// <summary>
175182
/// <see cref="Sif.Framework.Model.Settings.IFrameworkSettings.ConsumerName"/>
176183
/// </summary>

Code/Sif3Framework/Sif.Framework/Model/Settings/IFrameworkSettings.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2015 Systemic Pty Ltd
2+
* Copyright 2016 Systemic Pty Ltd
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -35,6 +35,11 @@ public interface IFrameworkSettings
3535
/// </summary>
3636
string AuthenticationMethod { get; }
3737

38+
/// <summary>
39+
/// Compress payload flag if it exists; false otherwise.
40+
/// </summary>
41+
bool CompressPayload { get; }
42+
3843
/// <summary>
3944
/// Consumer name if it exists; null otherwise.
4045
/// </summary>

Code/Sif3Framework/Sif.Framework/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("3.0.0.0")]
36-
[assembly: AssemblyFileVersion("3.0.0.0")]
35+
[assembly: AssemblyVersion("3.1.0.0")]
36+
[assembly: AssemblyFileVersion("3.1.0.0")]
3737

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

Code/Sif3Framework/Sif.Framework/SifFramework.config

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
<add key="consumer.environment.template.dataModelNamespace" value="http://www.sifassociation.org/uk/datamodel/2.0"/>
1616
<add key="consumer.environment.template.supportedInfrastructureVersion" value="3.2"/>
1717
<add key="consumer.paging.navigationPageSize" value="20"/>
18+
<add key="consumer.payload.compress" value="false"/>
1819
</appSettings>
1920
<sifFramework>
2021
<consumer>

Code/Sif3Framework/Sif.Framework/Utils/HttpUtils.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,12 @@ private static HttpWebRequest CreateHttpWebRequest(RequestMethod requestMethod,
7070
request.Accept = "application/xml";
7171
request.Headers.Add("Authorization", authorisationToken);
7272

73+
if (SettingsManager.ConsumerSettings.CompressPayload)
74+
{
75+
request.AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate;
76+
request.Headers.Add(HttpRequestHeader.AcceptEncoding, "gzip,deflate");
77+
}
78+
7379
if (navigationPage.HasValue)
7480
{
7581
request.Headers.Add("navigationPage", navigationPage.Value.ToString());

Code/Sif3FrameworkDemo/Sif.Framework.Demo.Au.Consumer/SifFramework.config

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
<add key="consumer.environment.template.solutionId" value="Sif3Framework"/>
1818
<add key="consumer.environment.template.supportedInfrastructureVersion" value="3.2"/>
1919
<add key="consumer.paging.navigationPageSize" value="5"/>
20+
<add key="consumer.payload.compress" value="false"/>
2021
</appSettings>
2122
<sifFramework>
2223
<consumer>

Code/Sif3FrameworkDemo/Sif.Framework.Demo.Hits.Consumer/SifFramework.config

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
<add key="consumer.environment.template.supportedInfrastructureVersion" value="3.1"/>
1919
<add key="consumer.environment.template.userToken" value="6dd11373-95fd-44d0-84b5-f6a238d78a6a"/>
2020
<add key="consumer.paging.navigationPageSize" value="5"/>
21+
<add key="consumer.payload.compress" value="false"/>
2122
</appSettings>
2223
<sifFramework>
2324
<consumer>

Code/Sif3FrameworkDemo/Sif.Framework.Demo.Uk.Consumer/SifFramework.config

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
</sectionGroup>
77
</configSections>
88
<appSettings>
9-
109
<!-- Settings used to register this Consumer with the Sif3Framework EnvironmentProvider. -->
1110
<add key="consumer.environmentType" value="DIRECT"/>
1211
<add key="consumer.environment.deleteOnUnregister" value="true"/>
@@ -16,9 +15,10 @@
1615
<add key="consumer.environment.template.authenticationMethod" value="Basic"/>
1716
<add key="consumer.environment.template.consumerName" value="Sif3DemoApp"/>
1817
<add key="consumer.environment.template.dataModelNamespace" value="http://www.sifassociation.org/uk/datamodel/2.0"/>
18+
<add key="consumer.environment.template.solutionId" value="Sif3Framework"/>
1919
<add key="consumer.environment.template.supportedInfrastructureVersion" value="3.2"/>
2020
<add key="consumer.paging.navigationPageSize" value="5"/>
21-
21+
<add key="consumer.payload.compress" value="false"/>
2222
<add key="consumer.events.supported" value="true"/>
2323
</appSettings>
2424
<sifFramework>

Code/Sif3FrameworkDemo/Sif.Framework.Demo.Us.Consumer/SifFramework.config

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,18 @@
66
</sectionGroup>
77
</configSections>
88
<appSettings>
9+
<!-- Settings used to register this Consumer with the Sif3Framework EnvironmentProvider. -->
910
<add key="consumer.environment.deleteOnUnregister" value="true"/>
1011
<add key="consumer.environment.sharedSecret" value="SecretDem0"/>
1112
<add key="consumer.environment.url" value="http://localhost:62921/api/environments/environment"/>
1213
<add key="consumer.environment.template.applicationKey" value="Sif3UsDemoApp"/>
1314
<add key="consumer.environment.template.authenticationMethod" value="Basic"/>
1415
<add key="consumer.environment.template.consumerName" value="Sif3UsDemoK12StudentConsumer"/>
1516
<add key="consumer.environment.template.dataModelNamespace" value="http://www.sifassociation.org/datamodel/na/3.2"/>
16-
<add key="consumer.environment.template.supportedInfrastructureVersion" value="3.0.1"/>
17+
<add key="consumer.environment.template.solutionId" value="Sif3Framework"/>
18+
<add key="consumer.environment.template.supportedInfrastructureVersion" value="3.2"/>
1719
<add key="consumer.paging.navigationPageSize" value="5"/>
20+
<add key="consumer.payload.compress" value="false"/>
1821
</appSettings>
1922
<sifFramework>
2023
<consumer>
0 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)