Skip to content

Commit 1f67e4b

Browse files
Fixes duplicating response headers in RateLimitingPlugin (#348)
1 parent 2fc0e29 commit 1f67e4b

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

m365-developer-proxy-plugins/Behavior/RateLimitingPlugin.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,15 @@ private void UpdateProxyResponse(ProxyHttpEventArgsBase e, HttpStatusCode errorS
119119
}
120120

121121
// add headers to the original API response
122-
e.Session.HttpClient.Response.Headers.AddHeaders(headers);
122+
headers.ForEach(h => {
123+
if (!response.Headers.HeaderExists(h.Name)) {
124+
e.Session.HttpClient.Response.Headers.AddHeader(h);
125+
}
126+
else {
127+
e.Session.HttpClient.Response.Headers.RemoveHeader(h.Name);
128+
e.Session.HttpClient.Response.Headers.AddHeader(h);
129+
}
130+
});
123131
}
124132
private static string BuildApiErrorMessage(Request r) => $"Some error was generated by the proxy. {(ProxyUtils.IsGraphRequest(r) ? ProxyUtils.IsSdkRequest(r) ? "" : String.Join(' ', MessageUtils.BuildUseSdkForErrorsMessage(r)) : "")}";
125133

0 commit comments

Comments
 (0)