示例#1
0
        public MethodOverrideHandler(HttpConfiguration httpConfiguration)
        {
            //request 顺序: 客户端发起请求 -> HttpServer -> DelegatingHandler -> HttpRoutingDispatcher
            // -> HttpControllerDispatcher -> Controller

            InnerHandler = new HttpControllerDispatcher(httpConfiguration);
        }
        public AuthenticationHandler(AuthenticationConfiguration configuration, HttpConfiguration httpConfiguration = null)
        {
            _authN = new HttpAuthentication(configuration);

            if (httpConfiguration != null)
            {
                InnerHandler = new HttpControllerDispatcher(httpConfiguration);
            }
        }
示例#3
0
        public AuthenticationHandler(AuthenticationConfiguration configuration, HttpConfiguration httpConfiguration = null)
        {
            log.Info("Creando AuthenticationHandler...");
            _authN = new HttpAuthentication(configuration);

            if (httpConfiguration != null)
            {
                InnerHandler = new HttpControllerDispatcher(httpConfiguration);
            }
        }
        public RateLimiterHandler(HttpConfiguration httpConfiguration, RateLimiter rateLimiter) : base()
        {
            if (rateLimiter == null)
            {
                throw new ArgumentNullException("RateLimiter");
            }

            InnerHandler = new HttpControllerDispatcher(httpConfiguration);

            m_rateLimiter = rateLimiter;
        }
示例#5
0
        private HttpServer GetTestCitiesServer(HttpConfiguration config)
        {
            HttpControllerDispatcher dispatcher = new HttpControllerDispatcher(config);

            HttpRoute route = new HttpRoute("{controller}/{action}", new HttpRouteValueDictionary("Cities"));

            config.Routes.Add("cities", route);

            HttpServer server = new HttpServer(config, dispatcher);

            return(server);
        }
示例#6
0
 public JsonForIEDelegateHandler(HttpConfiguration config, string contentTypeNewValue = "text/html; charset=utf-8")
 {
     if (config == null)
     {
         throw new ArgumentNullException("config");
     }
     if (string.IsNullOrEmpty(contentTypeNewValue))
     {
         throw new ArgumentNullException("contentTypeNewValue");
     }
     _contentTypeNewValue = contentTypeNewValue;
     InnerHandler         = new HttpControllerDispatcher(config);
 }
        public void MapODataServiceRoute_MapsHandlerWhenAHandlerIsProvided()
        {
            // Arrange
            HttpRouteCollection routes  = new HttpRouteCollection();
            HttpConfiguration   config  = new HttpConfiguration(routes);
            IEdmModel           model   = new EdmModel();
            HttpMessageHandler  handler = new HttpControllerDispatcher(new HttpConfiguration());

            // Act
            ODataRoute route = config.MapODataServiceRoute("odata", "odata", model, handler);

            // Assert
            Assert.NotNull(route);
            Assert.Same(handler, route.Handler);
        }
示例#8
0
        private HttpResponseMessage ExecuteSelfHostRequest(string url, string controller, object data, string mediaType)
        {
            HttpConfiguration config = new HttpConfiguration();
            IHttpRoute        routeData;

            if (!config.Routes.TryGetValue(controller, out routeData))
            {
                HttpRoute route = new HttpRoute("{controller}/{action}", new HttpRouteValueDictionary(controller));
                config.Routes.Add(controller, route);
            }

            HttpControllerDispatcher dispatcher = new HttpControllerDispatcher(config);
            HttpServer         server           = new HttpServer(config, dispatcher);
            HttpMessageInvoker invoker          = new HttpMessageInvoker(server);

            string serializedChangeSet = String.Empty;

            if (mediaType == "application/json")
            {
                JsonSerializer serializer = new JsonSerializer()
                {
                    PreserveReferencesHandling = PreserveReferencesHandling.Objects, TypeNameHandling = TypeNameHandling.All
                };
                MemoryStream ms     = new MemoryStream();
                JsonWriter   writer = new JsonTextWriter(new StreamWriter(ms));
                serializer.Serialize(writer, data);
                writer.Flush();
                ms.Seek(0, 0);
                serializedChangeSet = Encoding.UTF8.GetString(ms.GetBuffer()).TrimEnd('\0');
            }
            else
            {
                DataContractSerializer ser = new DataContractSerializer(data.GetType(), GetTestKnownTypes());
                MemoryStream           ms  = new MemoryStream();
                ser.WriteObject(ms, data);
                ms.Flush();
                ms.Seek(0, 0);
                serializedChangeSet = Encoding.UTF8.GetString(ms.GetBuffer()).TrimEnd('\0');
            }

            HttpRequestMessage request = TestHelpers.CreateTestMessage(url, HttpMethod.Post, config);

            request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(mediaType));
            request.Content = new StringContent(serializedChangeSet, Encoding.UTF8, mediaType);

            return(invoker.SendAsync(request, CancellationToken.None).Result);
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="AccessTokenHandler"/> class.
 /// </summary>
 /// <param name="httpConfiguration">The HTTP configuration.</param>
 public AccessTokenHandler(HttpConfiguration httpConfiguration)
 {
     InnerHandler = new HttpControllerDispatcher(httpConfiguration);
 }
示例#10
0
 public HttpServer(HttpControllerDispatcher dispatcher)
     : this(new HttpConfiguration(), dispatcher)
 {
 }
示例#11
0
 public CustomHandlerWithoutController(HttpConfiguration httpConfiguration)
 {
     // создать внутренний обработчик, т.к. выше он создается с помощью base.SendAsync, которого здесь нет
     InnerHandler = new HttpControllerDispatcher(httpConfiguration);
 }
示例#12
0
 public ResponseWrappingHandler(HttpConfiguration httpConfiguration)
 {
     InnerHandler = new HttpControllerDispatcher(httpConfiguration);
 }
示例#13
0
 public jqGridODataHandler(HttpConfiguration httpConfiguration)
 {
     InnerHandler = new HttpControllerDispatcher(httpConfiguration);
 }
示例#14
0
 public KDelegatingHandler(HttpConfiguration httpConfiguration)
 {
     InnerHandler = new HttpControllerDispatcher(httpConfiguration);
 }
示例#15
0
 public DataLoader(HttpConfiguration httpConfiguration, UserService userService, ToDoService toDoService)
 {
     InnerHandler     = new HttpControllerDispatcher(httpConfiguration);
     this.userService = userService;
     this.toDoService = toDoService;
 }
示例#16
0
 public GZipToJsonHandler(HttpConfiguration config)
 {
     InnerHandler = new HttpControllerDispatcher(config);
 }
 public NormalizeHandler(HttpConfiguration httpConfiguration)
 {
     InnerHandler = new HttpControllerDispatcher(httpConfiguration);
 }
 protected BasicAuthenticationMessageHandler(HttpConfiguration httpConfiguration)
 {
     InnerHandler = new HttpControllerDispatcher(httpConfiguration);
 }
 public ClaimsTransformationHandler(ClaimsAuthenticationManager transformer, HttpConfiguration configuration)
 {
     _transfomer  = transformer;
     InnerHandler = new HttpControllerDispatcher(configuration);
 }
示例#20
0
 /// <summary>
 /// 构造函数
 /// </summary>
 /// <param name="httpConfiguration">webapi配置</param>
 public AppKeyValidate(HttpConfiguration httpConfiguration)
 {
     InnerHandler = new HttpControllerDispatcher(httpConfiguration);
 }
示例#21
0
 public CustomEventHandler(HttpConfiguration httpConfiguration)
 {
     InnerHandler = new HttpControllerDispatcher(httpConfiguration);
 }
示例#22
0
 public PerRouteHandler(HttpConfiguration httpConfiguration)
 {
     InnerHandler = new HttpControllerDispatcher(httpConfiguration);
 }
示例#23
0
 public AuthenticationHandler(HttpConfiguration httpConfiguration)
 {
     InnerHandler = new HttpControllerDispatcher(httpConfiguration);
 }
示例#24
0
 public GZipToJsonHandler(HttpConfiguration config)
 {
     //Here we are retaining the standard handler pipeline, so that this can run after the custom handler has run
     InnerHandler = new HttpControllerDispatcher(config);
 }