using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Net.Http;

namespace MarketDataServer.Handlers
{
  public class CustomHeaderHandler : DelegatingHandler
  {
      protected override Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, System.Threading.CancellationToken cancellationToken)
      {
      return base.SendAsync(request, cancellationToken)
          .ContinueWith((task) =>
          {
              HttpResponseMessage response = task.Result;
              response.Headers.Add("Access-Control-Allow-Origin", "*");
              //response.Headers.Add("Access-Control-Allow-Credentials", "true");
              //response.Headers.Add("Access-Control-Allow-Methods", "OPTIONS, GET, POST");
              //response.Headers.Add("Access-Control-Allow-Headers", "Content-Type, Depth, User-Agent, X-File-Size, X-Requested-With, If-Modified-Since, X-File-Name, Cache-Control");
              return response;
          });
      }
  }
}
