コード例 #1
0
        public async Task Invoke(HttpContext context)
        {
            if (context.Request.Method == "POST" &&
                context.Request.Path.StartsWithSegments(_urlEndpoint) &&
                context.Request != null &&
                context.Request.ContentType.ToLower().Contains("text/xml"))
            {
                var rdr = new StreamReader(context.Request.Body);
                var xml = rdr.ReadToEnd();
                _logger.LogInformation($"Request XMLRPC: {xml}");
                var result = _service.Invoke(xml);
                _logger.LogInformation($"Result XMLRPC: {result}");
                context.Response.ContentType   = "text/xml";
                context.Response.ContentLength = Encoding.UTF8.GetBytes(result).Length;
                await context.Response.WriteAsync(result, Encoding.UTF8);

                // This is only a workaround for the System.IOException issue
                // occurred in the Windows Live Writer client.
                await Task.Delay(500);
            }
            else
            {
                // Continue On
                await _next.Invoke(context);
            }
        }
コード例 #2
0
        public async Task Invoke(HttpContext context)
        {
            if (context.Request.Method == "POST" &&
                context.Request.Path.StartsWithSegments(_urlEndpoint) &&
                context.Request != null &&
                context.Request.ContentType.ToLower().Contains("text/xml"))
            {
                var rdr = new StreamReader(context.Request.Body);
                var xml = rdr.ReadToEnd();
                _logger.LogInformation($"Request XMLRPC: {xml}");
                var result = _service.Invoke(xml);
                _logger.LogInformation($"Result XMLRPC: {result}");
                await context.Response.WriteAsync(result, Encoding.UTF8);

                context.Response.ContentType = "text/xml";
            }

            // Continue On
            await _next.Invoke(context);
        }