Skip to content

Commit d3714b3

Browse files
committed
Fixed "Misused header name"
1 parent 6595330 commit d3714b3

File tree

2 files changed

+1
-16
lines changed

2 files changed

+1
-16
lines changed

Mastercard.Developer.ClientEncryption.RestSharp/Interceptors/RestSharpFieldLevelEncryptionInterceptor.cs

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,6 @@ public void InterceptResponse(IRestResponse response)
115115
// Update body and content length
116116
var contentTypeInfo = response.GetType().GetTypeInfo().GetDeclaredField("_content");
117117
contentTypeInfo.SetValue(response, new Lazy<string>(() => decryptedPayload));
118-
UpdateResponseHeader(response, "Content-Length", decryptedPayload.Length.ToString());
119118
}
120119
catch (EncryptionException)
121120
{
@@ -138,18 +137,6 @@ private static void UpdateRequestHeader(IRestRequest request, string name, objec
138137
request.AddOrUpdateHeader(name, value);
139138
}
140139

141-
private static void UpdateResponseHeader(IRestResponse response, string name, string value)
142-
{
143-
if (string.IsNullOrEmpty(name))
144-
{
145-
// Do nothing
146-
return;
147-
}
148-
149-
response.Headers.Remove(name);
150-
response.Headers.Add(name, value);
151-
}
152-
153140
private static string ReadAndRemoveHeader(IRestResponse response, string name)
154141
{
155142
if (string.IsNullOrEmpty(name) || !response.Headers.Contains(name))

Mastercard.Developer.ClientEncryption.Tests/Interceptors/RestSharpFieldLevelEncryptionInterceptorTest.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ public void TestInterceptRequest_ShouldThrowEncryptionException_WhenEncryptionFa
100100
}
101101

102102
[TestMethod]
103-
public void TestInterceptResponse_ShouldDecryptResponsePayloadAndUpdateContentLengthHeader()
103+
public void TestInterceptResponse_ShouldDecryptResponsePayload()
104104
{
105105
// GIVEN
106106
const string encryptedPayload = "{" +
@@ -127,7 +127,6 @@ public void TestInterceptResponse_ShouldDecryptResponsePayloadAndUpdateContentLe
127127
// THEN
128128
var payload = response.Content;
129129
TestUtils.AssertPayloadEquals("{\"data\":\"string\"}", payload);
130-
Assert.AreEqual(payload.Length.ToString(), response.Headers.GetValue("Content-Length"));
131130
}
132131

133132
[TestMethod]
@@ -258,7 +257,6 @@ public void TestInterceptRequest_ShouldDecryptResponsePayloadAndRemoveEncryption
258257
// THEN
259258
var payload = response.Content;
260259
TestUtils.AssertPayloadEquals("{\"data\":\"string\"}", payload);
261-
Assert.AreEqual(payload.Length.ToString(), response.Headers.GetValue("Content-Length"));
262260
Assert.IsNull(response.Headers.GetValue("x-iv"));
263261
Assert.IsNull(response.Headers.GetValue("x-encrypted-key"));
264262
Assert.IsNull(response.Headers.GetValue("x-oaep-padding-digest-algorithm"));

0 commit comments

Comments
 (0)