Skip to content

Commit b79ce36

Browse files
tore-hammervollkhellang
authored andcommitted
Make HttpMessage.SetHeader replace any existing header value
Ensure the "Signature" value is not added multiple times when a retry happens
1 parent e375fca commit b79ce36

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/IdentityStream.HttpMessageSigning/Extensions/HttpRequestMessageExtensions.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,15 @@ public HttpMessage(HttpRequestMessage request) {
2929

3030
private HttpRequestMessage Request { get; }
3131

32-
public void SetHeader(string name, string value) =>
32+
public void SetHeader(string name, string value)
33+
{
34+
if (Request.Headers.Contains(name))
35+
{
36+
Request.Headers.Remove(name);
37+
}
38+
3339
Request.Headers.TryAddWithoutValidation(name, value);
40+
}
3441

3542
public bool TryGetHeaderValues(string name, [NotNullWhen(true)] out IEnumerable<string>? values) =>
3643
Request.Headers.TryGetValues(name, out values);

0 commit comments

Comments
 (0)