using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;
using System.IO;

namespace Rest.Net
{
    public static class HttpListenerRequestExtensions
    {
        public static string ReadAsString(this HttpListenerRequest request)
        {
            try
            {
                using (var input = request.InputStream)
                using (var stream = new StreamReader(input))
                    return stream.ReadToEnd();
            }
            catch
            {
                return "";
            }
        }
    }
}
