예제 #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);
 }