Extensions.cs 825 B

12345678910111213141516171819202122232425262728
  1. using MediaBrowser.Model.Logging;
  2. using SocketHttpListener.Net;
  3. using System;
  4. namespace MediaBrowser.Server.Implementations.HttpServer.SocketSharp
  5. {
  6. public static class Extensions
  7. {
  8. public static string GetOperationName(this HttpListenerRequest request)
  9. {
  10. return request.Url.Segments[request.Url.Segments.Length - 1];
  11. }
  12. public static void CloseOutputStream(this HttpListenerResponse response, ILogger logger)
  13. {
  14. try
  15. {
  16. response.OutputStream.Flush();
  17. response.OutputStream.Close();
  18. response.Close();
  19. }
  20. catch (Exception ex)
  21. {
  22. logger.ErrorException("Error in HttpListenerResponseWrapper: " + ex.Message, ex);
  23. }
  24. }
  25. }
  26. }