public static IConnectionBuilder UseHttpServer(this IConnectionBuilder builder, IHttpApplication application)
 {
     return(builder.Run(connection =>
     {
         var httpConnection = HttpServerProtocol.CreateFromConnection(connection);
         return application.ProcessRequests(httpConnection.ReadAllRequestsAsync());
     }));
 }
Exemple #2
0
 protected bool ReflectUrlParameters()
 {
     if (!HttpServerProtocol.AreUrlParametersSupported(Method))
     {
         return(false);
     }
     ReflectStringParametersMessage();
     OperationBinding.Input.Extensions.Add(new HttpUrlEncodedBinding());
     return(true);
 }
Exemple #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")
                });
            }
        }