예제 #1
0
        public HandlebarsMediaTypeFormatter(HttpConfiguration config,
                                            IHandlebarsTemplate template,
                                            IRequestFormatter formatter)
            : base()
        {
            this._template = template;
            this.SupportedMediaTypes.Add(new MediaTypeHeaderValue("text/html"));
            this._formatter = formatter;

            config.Formatters.Insert(0, this);
            _config = config;
            _server = new HttpServer(config);
            _client = new HttpMessageInvoker(_server);
        }
 public HandlebarsMediaTypeFormatter(HttpConfiguration config,
                                     IHandlebarsTemplate template,
                                     IRequestFormatter formatter)
     : base()
 {            
     this._template = template;
     this.SupportedMediaTypes.Add(new MediaTypeHeaderValue("text/html"));
     this._formatter = formatter;
                 
     config.Formatters.Insert(0, this);
     _config = config;
     _server = new HttpServer(config);
     _client = new HttpMessageInvoker(_server);
 }
예제 #3
0
        public HandlebarsMediaTypeFormatter(HttpConfiguration config,
                                            IHandlebarsTemplate template,
                                            IRequestFormatter formatter,
                                            HttpServer server,
                                            HttpMessageInvoker client,
                                            string view,
                                            HttpRequestMessage request)
        {
            this._formatter = formatter;
            this._template  = template;
            this._request   = request;
            this._server    = server;
            this._config    = config;
            this._client    = client;
            this._view      = view;

            this.SupportedMediaTypes.Add(new MediaTypeHeaderValue("text/html"));
        }
        public HandlebarsMediaTypeFormatter(HttpConfiguration config,
                                            IHandlebarsTemplate template,
                                            IRequestFormatter formatter,
                                            HttpServer server, 
                                            HttpMessageInvoker client, 
                                            string view,
                                            HttpRequestMessage request)
        {

            this._formatter = formatter;
            this._template = template;
            this._request = request;
            this._server = server;
            this._config = config;
            this._client = client;
            this._view = view;

            this.SupportedMediaTypes.Add(new MediaTypeHeaderValue("text/html"));            
        }
        public ProxyStartup(IHandlebarsEngine engine, IHandlebarsTemplate template)
        {
            _handlebars = engine;
            _template = template;

            HandlebarsConfiguration.Instance.TemplatePath = HandlebarsProxyConfiguration.Instance.Directory + "\\template";
            WebRequestHandler webRequestHandler = new WebRequestHandler();

            // we don't do this, as we miss the authentication headers
            // we just pass redirects onto the browser and handle it like that
            webRequestHandler.AllowAutoRedirect = false;
            webRequestHandler.UseCookies = false;
            webRequestHandler.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback((sender, certificate, chain, policyErrors) => { return true; });

            _store = MemoryCache.Default;
            _client = new HttpClient(webRequestHandler, false)
            {
                BaseAddress = new Uri(HandlebarsProxyConfiguration.Instance.Scheme +
                                      "://" +
                                      HandlebarsProxyConfiguration.Instance.Domain +
                                      ":" +
                                      HandlebarsProxyConfiguration.Instance.DomainPort),                                      

            };

            

            // 
            if (!string.IsNullOrEmpty(HandlebarsProxyConfiguration.Instance.Username) &&
                !string.IsNullOrEmpty(HandlebarsProxyConfiguration.Instance.Password))
            {
                _authHeader = new AuthenticationHeaderValue("Basic", Convert.ToBase64String(
                                     Encoding.ASCII.GetBytes(string.Format("{0}:{1}", 
                                                                           HandlebarsProxyConfiguration.Instance.Username,
                                                                           HandlebarsProxyConfiguration.Instance.Password)))
                );

                _client.DefaultRequestHeaders.Authorization = _authHeader;                
            }
            
        }
예제 #6
0
        public ProxyStartup(IHandlebarsEngine engine, IHandlebarsTemplate template)
        {
            _handlebars = engine;
            _template   = template;

            HandlebarsConfiguration.Instance.TemplatePath = HandlebarsProxyConfiguration.Instance.Directory + "\\template";
            WebRequestHandler webRequestHandler = new WebRequestHandler();

            // we don't do this, as we miss the authentication headers
            // we just pass redirects onto the browser and handle it like that
            webRequestHandler.AllowAutoRedirect = false;
            webRequestHandler.UseCookies        = false;
            webRequestHandler.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback((sender, certificate, chain, policyErrors) => { return(true); });

            _store  = MemoryCache.Default;
            _client = new HttpClient(webRequestHandler, false)
            {
                BaseAddress = new Uri(HandlebarsProxyConfiguration.Instance.Scheme +
                                      "://" +
                                      HandlebarsProxyConfiguration.Instance.Domain +
                                      ":" +
                                      HandlebarsProxyConfiguration.Instance.DomainPort),
            };



            //
            if (!string.IsNullOrEmpty(HandlebarsProxyConfiguration.Instance.Username) &&
                !string.IsNullOrEmpty(HandlebarsProxyConfiguration.Instance.Password))
            {
                _authHeader = new AuthenticationHeaderValue("Basic", Convert.ToBase64String(
                                                                Encoding.ASCII.GetBytes(string.Format("{0}:{1}",
                                                                                                      HandlebarsProxyConfiguration.Instance.Username,
                                                                                                      HandlebarsProxyConfiguration.Instance.Password)))
                                                            );

                _client.DefaultRequestHeaders.Authorization = _authHeader;
            }
        }
 public HandlebarsMediaTypeFormatter(HttpRouteCollection routes,
                                     IHandlebarsTemplate template,
                                     IRequestFormatter formatter) : this(new HttpConfiguration(routes), template, formatter)
 {
 }
예제 #8
0
 public HandlebarsMediaTypeFormatter(HttpRouteCollection routes,
                                     IHandlebarsTemplate template,
                                     IRequestFormatter formatter) : this(new HttpConfiguration(routes), template, formatter)
 {
 }