aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Server.Implementations/HttpServer/SocketSharp/Extensions.cs
blob: 154313fb9043ad9fc846dad664e02821ddcd8e26 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
using MediaBrowser.Model.Logging;
using SocketHttpListener.Net;
using System;

namespace MediaBrowser.Server.Implementations.HttpServer.SocketSharp
{
    public static class Extensions
    {
        public static string GetOperationName(this HttpListenerRequest request)
        {
            return request.Url.Segments[request.Url.Segments.Length - 1];
        }

        public static void CloseOutputStream(this HttpListenerResponse response, ILogger logger)
        {
            try
            {
                response.OutputStream.Flush();
                response.OutputStream.Close();
                response.Close();
            }
            catch (Exception ex)
            {
                logger.ErrorException("Error in HttpListenerResponseWrapper: " + ex.Message, ex);
            }
        }
    }
}