public static IConnectionBuilder UseHttpServer(this IConnectionBuilder builder, IHttpApplication application)
 {
     return(builder.Run(connection =>
     {
         var httpConnection = HttpServerProtocol.CreateFromConnection(connection);
         return application.ProcessRequests(httpConnection.ReadAllRequestsAsync());
     }));
 }
Exemplo n.º 2
0
 protected bool ReflectUrlParameters()
 {
     if (!HttpServerProtocol.AreUrlParametersSupported(Method))
     {
         return(false);
     }
     ReflectStringParametersMessage();
     OperationBinding.Input.Extensions.Add(new HttpUrlEncodedBinding());
     return(true);
 }
Exemplo n.º 3
0
        public override async Task OnConnectedAsync(ConnectionContext connection)
        {
            var httpConnection = new HttpServerProtocol(connection);

            while (true)
            {
                var request = await httpConnection.ReadRequestAsync();

                Console.WriteLine(request);

                // Consume the request body
                await request.Content.CopyToAsync(Stream.Null);

                await httpConnection.WriteResponseAsync(new HttpResponseMessage(HttpStatusCode.OK)
                {
                    Content = new StringContent("Hello World")
                });
            }
        }