You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

20 lines
596 B

namespace OAuthClient;
public class OriginHandler : DelegatingHandler {
private readonly string _origin;
public OriginHandler(string origin) {
_origin = origin;
InnerHandler = new HttpClientHandler();
}
protected override Task<HttpResponseMessage> SendAsync(HttpRequestMessage request,
CancellationToken cancellationToken) {
// Add the Origin header to the request
if (!request.Headers.Contains("Origin")) {
request.Headers.Add("Origin", _origin);
}
return base.SendAsync(request, cancellationToken);
}
}