From 235b838fbe262f3f41cd64c8506d067c9ef9253e Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Fri, 29 Nov 2013 11:58:24 -0500 Subject: support deleting and canceling live tv recordings and timers --- .../HttpClientManager/HttpClientManager.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'MediaBrowser.Common.Implementations/HttpClientManager/HttpClientManager.cs') diff --git a/MediaBrowser.Common.Implementations/HttpClientManager/HttpClientManager.cs b/MediaBrowser.Common.Implementations/HttpClientManager/HttpClientManager.cs index 0d6ba5c1d..181c83fd3 100644 --- a/MediaBrowser.Common.Implementations/HttpClientManager/HttpClientManager.cs +++ b/MediaBrowser.Common.Implementations/HttpClientManager/HttpClientManager.cs @@ -1,4 +1,5 @@ -using MediaBrowser.Common.Configuration; +using System.Reflection; +using MediaBrowser.Common.Configuration; using MediaBrowser.Common.IO; using MediaBrowser.Common.Net; using MediaBrowser.Model.Logging; -- cgit v1.2.3 From 0bdc8a49d5ea17417b3552d6db21239190bc4b6b Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sat, 30 Nov 2013 01:07:25 -0500 Subject: switch from httpclient to plain httpwebrequest --- .../BaseApplicationHost.cs | 5 +- .../HttpClientManager/HttpClientInfo.cs | 6 - .../HttpClientManager/HttpClientManager.cs | 443 ++++++++++++--------- MediaBrowser.Common/Net/IHttpClient.cs | 5 + MediaBrowser.ServerApplication/ApplicationHost.cs | 10 - .../MediaBrowser.ServerApplication.csproj | 1 - .../Native/HttpClientFactory.cs | 35 -- 7 files changed, 263 insertions(+), 242 deletions(-) delete mode 100644 MediaBrowser.ServerApplication/Native/HttpClientFactory.cs (limited to 'MediaBrowser.Common.Implementations/HttpClientManager/HttpClientManager.cs') diff --git a/MediaBrowser.Common.Implementations/BaseApplicationHost.cs b/MediaBrowser.Common.Implementations/BaseApplicationHost.cs index f1d8c94e5..becf649f4 100644 --- a/MediaBrowser.Common.Implementations/BaseApplicationHost.cs +++ b/MediaBrowser.Common.Implementations/BaseApplicationHost.cs @@ -22,7 +22,6 @@ using System.Collections.Generic; using System.IO; using System.Linq; using System.Net; -using System.Net.Http; using System.Reflection; using System.Threading; using System.Threading.Tasks; @@ -353,7 +352,7 @@ namespace MediaBrowser.Common.Implementations FileSystemManager = CreateFileSystemManager(); RegisterSingleInstance(FileSystemManager); - HttpClient = new HttpClientManager.HttpClientManager(ApplicationPaths, Logger, CreateHttpClient, FileSystemManager); + HttpClient = new HttpClientManager.HttpClientManager(ApplicationPaths, Logger, FileSystemManager); RegisterSingleInstance(HttpClient); NetworkManager = CreateNetworkManager(); @@ -378,8 +377,6 @@ namespace MediaBrowser.Common.Implementations return new CommonFileSystem(Logger, true); } - protected abstract HttpClient CreateHttpClient(bool enableHttpCompression); - /// /// Gets a list of types within an assembly /// This will handle situations that would normally throw an exception - such as a type within the assembly that depends on some other non-existant reference diff --git a/MediaBrowser.Common.Implementations/HttpClientManager/HttpClientInfo.cs b/MediaBrowser.Common.Implementations/HttpClientManager/HttpClientInfo.cs index 33f7079df..8af6ef6c6 100644 --- a/MediaBrowser.Common.Implementations/HttpClientManager/HttpClientInfo.cs +++ b/MediaBrowser.Common.Implementations/HttpClientManager/HttpClientInfo.cs @@ -1,5 +1,4 @@ using System; -using System.Net.Http; namespace MediaBrowser.Common.Implementations.HttpClientManager { @@ -8,11 +7,6 @@ namespace MediaBrowser.Common.Implementations.HttpClientManager /// public class HttpClientInfo { - /// - /// Gets or sets the HTTP client. - /// - /// The HTTP client. - public HttpClient HttpClient { get; set; } /// /// Gets or sets the last timeout. /// diff --git a/MediaBrowser.Common.Implementations/HttpClientManager/HttpClientManager.cs b/MediaBrowser.Common.Implementations/HttpClientManager/HttpClientManager.cs index 181c83fd3..ea1a5c726 100644 --- a/MediaBrowser.Common.Implementations/HttpClientManager/HttpClientManager.cs +++ b/MediaBrowser.Common.Implementations/HttpClientManager/HttpClientManager.cs @@ -1,5 +1,4 @@ -using System.Reflection; -using MediaBrowser.Common.Configuration; +using MediaBrowser.Common.Configuration; using MediaBrowser.Common.IO; using MediaBrowser.Common.Net; using MediaBrowser.Model.Logging; @@ -10,7 +9,10 @@ using System.Collections.Generic; using System.Globalization; using System.IO; using System.Linq; +using System.Net; +using System.Net.Cache; using System.Net.Http; +using System.Reflection; using System.Text; using System.Threading; using System.Threading.Tasks; @@ -32,9 +34,6 @@ namespace MediaBrowser.Common.Implementations.HttpClientManager /// private readonly IApplicationPaths _appPaths; - public delegate HttpClient GetHttpClientHandler(bool enableHttpCompression); - - private readonly GetHttpClientHandler _getHttpClientHandler; private readonly IFileSystem _fileSystem; /// @@ -48,7 +47,7 @@ namespace MediaBrowser.Common.Implementations.HttpClientManager /// or /// logger /// - public HttpClientManager(IApplicationPaths appPaths, ILogger logger, GetHttpClientHandler getHttpClientHandler, IFileSystem fileSystem) + public HttpClientManager(IApplicationPaths appPaths, ILogger logger, IFileSystem fileSystem) { if (appPaths == null) { @@ -60,7 +59,6 @@ namespace MediaBrowser.Common.Implementations.HttpClientManager } _logger = logger; - _getHttpClientHandler = getHttpClientHandler; _fileSystem = fileSystem; _appPaths = appPaths; } @@ -92,111 +90,59 @@ namespace MediaBrowser.Common.Implementations.HttpClientManager if (!_httpClients.TryGetValue(key, out client)) { - client = new HttpClientInfo - { + client = new HttpClientInfo(); - HttpClient = _getHttpClientHandler(enableHttpCompression) - }; _httpClients.TryAdd(key, client); } return client; } - public async Task GetResponse(HttpRequestOptions options) - { - ValidateParams(options.Url, options.CancellationToken); - - options.CancellationToken.ThrowIfCancellationRequested(); + private PropertyInfo _httpBehaviorPropertyInfo; - var client = GetHttpClient(GetHostFromUrl(options.Url), options.EnableHttpCompression); + private HttpWebRequest GetRequest(HttpRequestOptions options, string method, bool enableHttpCompression) + { + var request = HttpWebRequest.CreateHttp(options.Url); - if ((DateTime.UtcNow - client.LastTimeout).TotalSeconds < 30) + if (!string.IsNullOrEmpty(options.AcceptHeader)) { - throw new HttpException(string.Format("Cancelling connection to {0} due to a previous timeout.", options.Url)) { IsTimedOut = true }; + request.Accept = options.AcceptHeader; } - using (var message = GetHttpRequestMessage(options)) - { - if (options.ResourcePool != null) - { - await options.ResourcePool.WaitAsync(options.CancellationToken).ConfigureAwait(false); - } - - if ((DateTime.UtcNow - client.LastTimeout).TotalSeconds < 30) - { - if (options.ResourcePool != null) - { - options.ResourcePool.Release(); - } - - throw new HttpException(string.Format("Connection to {0} timed out", options.Url)) { IsTimedOut = true }; - } - - _logger.Info("HttpClientManager.Get url: {0}", options.Url); - - try - { - options.CancellationToken.ThrowIfCancellationRequested(); - - var response = await client.HttpClient.SendAsync(message, HttpCompletionOption.ResponseContentRead, options.CancellationToken).ConfigureAwait(false); - - EnsureSuccessStatusCode(response); + request.AutomaticDecompression = enableHttpCompression ? DecompressionMethods.Deflate : DecompressionMethods.None; + request.CachePolicy = new RequestCachePolicy(RequestCacheLevel.Revalidate); + request.ConnectionGroupName = GetHostFromUrl(options.Url); + request.KeepAlive = true; + request.Method = method; + request.Pipelined = true; + request.Timeout = 20000; - options.CancellationToken.ThrowIfCancellationRequested(); - - return new HttpResponseInfo - { - Content = await response.Content.ReadAsStreamAsync().ConfigureAwait(false), - - StatusCode = response.StatusCode, - - ContentType = response.Content.Headers.ContentType.MediaType - }; - } - catch (OperationCanceledException ex) - { - var exception = GetCancellationException(options.Url, options.CancellationToken, ex); - - var httpException = exception as HttpException; + if (!string.IsNullOrEmpty(options.UserAgent)) + { + request.UserAgent = options.UserAgent; + } - if (httpException != null && httpException.IsTimedOut) - { - client.LastTimeout = DateTime.UtcNow; - } + var sp = request.ServicePoint; - throw exception; - } - catch (HttpRequestException ex) - { - _logger.ErrorException("Error getting response from " + options.Url, ex); + if (_httpBehaviorPropertyInfo == null) + { + _httpBehaviorPropertyInfo = sp.GetType().GetProperty("HttpBehaviour", BindingFlags.Instance | BindingFlags.NonPublic); + } - throw new HttpException(ex.Message, ex); - } - catch (Exception ex) - { - _logger.ErrorException("Error getting response from " + options.Url, ex); + _httpBehaviorPropertyInfo.SetValue(sp, (byte)0, null); - throw; - } - finally - { - if (options.ResourcePool != null) - { - options.ResourcePool.Release(); - } - } - } + return request; } /// - /// Performs a GET request and returns the resulting stream + /// Gets the response internal. /// /// The options. - /// Task{Stream}. - /// - /// - public async Task Get(HttpRequestOptions options) + /// The HTTP method. + /// Task{HttpResponseInfo}. + /// + /// + public async Task GetResponse(HttpRequestOptions options) { ValidateParams(options.Url, options.CancellationToken); @@ -209,72 +155,110 @@ namespace MediaBrowser.Common.Implementations.HttpClientManager throw new HttpException(string.Format("Cancelling connection to {0} due to a previous timeout.", options.Url)) { IsTimedOut = true }; } - using (var message = GetHttpRequestMessage(options)) + var httpWebRequest = GetRequest(options, "GET", options.EnableHttpCompression); + + if (options.ResourcePool != null) + { + await options.ResourcePool.WaitAsync(options.CancellationToken).ConfigureAwait(false); + } + + if ((DateTime.UtcNow - client.LastTimeout).TotalSeconds < 30) { if (options.ResourcePool != null) { - await options.ResourcePool.WaitAsync(options.CancellationToken).ConfigureAwait(false); + options.ResourcePool.Release(); } - if ((DateTime.UtcNow - client.LastTimeout).TotalSeconds < 30) - { - if (options.ResourcePool != null) - { - options.ResourcePool.Release(); - } + throw new HttpException(string.Format("Connection to {0} timed out", options.Url)) { IsTimedOut = true }; + } - throw new HttpException(string.Format("Connection to {0} timed out", options.Url)) { IsTimedOut = true }; - } + _logger.Info("HttpClientManager.GET url: {0}", options.Url); - _logger.Info("HttpClientManager.Get url: {0}", options.Url); + try + { + options.CancellationToken.ThrowIfCancellationRequested(); - try + using (var response = await httpWebRequest.GetResponseAsync().ConfigureAwait(false)) { + var httpResponse = (HttpWebResponse)response; + + EnsureSuccessStatusCode(httpResponse); + options.CancellationToken.ThrowIfCancellationRequested(); - var response = await client.HttpClient.SendAsync(message, HttpCompletionOption.ResponseContentRead, options.CancellationToken).ConfigureAwait(false); + using (var stream = httpResponse.GetResponseStream()) + { + var memoryStream = new MemoryStream(); - EnsureSuccessStatusCode(response); + await stream.CopyToAsync(memoryStream).ConfigureAwait(false); - options.CancellationToken.ThrowIfCancellationRequested(); + memoryStream.Position = 0; - return await response.Content.ReadAsStreamAsync().ConfigureAwait(false); - } - catch (OperationCanceledException ex) - { - var exception = GetCancellationException(options.Url, options.CancellationToken, ex); + return new HttpResponseInfo + { + Content = memoryStream, - var httpException = exception as HttpException; + StatusCode = httpResponse.StatusCode, - if (httpException != null && httpException.IsTimedOut) - { - client.LastTimeout = DateTime.UtcNow; + ContentType = httpResponse.ContentType + }; } - - throw exception; } - catch (HttpRequestException ex) - { - _logger.ErrorException("Error getting response from " + options.Url, ex); + } + catch (OperationCanceledException ex) + { + var exception = GetCancellationException(options.Url, options.CancellationToken, ex); - throw new HttpException(ex.Message, ex); - } - catch (Exception ex) - { - _logger.ErrorException("Error getting response from " + options.Url, ex); + var httpException = exception as HttpException; - throw; + if (httpException != null && httpException.IsTimedOut) + { + client.LastTimeout = DateTime.UtcNow; } - finally + + throw exception; + } + catch (HttpRequestException ex) + { + _logger.ErrorException("Error getting response from " + options.Url, ex); + + throw new HttpException(ex.Message, ex); + } + catch (WebException ex) + { + _logger.ErrorException("Error getting response from " + options.Url, ex); + + throw new HttpException(ex.Message, ex); + } + catch (Exception ex) + { + _logger.ErrorException("Error getting response from " + options.Url, ex); + + throw; + } + finally + { + if (options.ResourcePool != null) { - if (options.ResourcePool != null) - { - options.ResourcePool.Release(); - } + options.ResourcePool.Release(); } } } + /// + /// Performs a GET request and returns the resulting stream + /// + /// The options. + /// Task{Stream}. + /// + /// + public async Task Get(HttpRequestOptions options) + { + var response = await GetResponse(options).ConfigureAwait(false); + + return response.Content; + } + /// /// Performs a GET request and returns the resulting stream /// @@ -306,64 +290,112 @@ namespace MediaBrowser.Common.Implementations.HttpClientManager /// /// Performs a POST request /// - /// The URL. + /// The options. /// Params to add to the POST data. - /// The resource pool. - /// The cancellation token. /// stream on success, null on failure + /// + /// /// postData /// - public async Task Post(string url, Dictionary postData, SemaphoreSlim resourcePool, CancellationToken cancellationToken) + public async Task Post(HttpRequestOptions options, Dictionary postData) { - ValidateParams(url, cancellationToken); + ValidateParams(options.Url, options.CancellationToken); - if (postData == null) - { - throw new ArgumentNullException("postData"); - } + options.CancellationToken.ThrowIfCancellationRequested(); - cancellationToken.ThrowIfCancellationRequested(); + var httpWebRequest = GetRequest(options, "POST", options.EnableHttpCompression); var strings = postData.Keys.Select(key => string.Format("{0}={1}", key, postData[key])); var postContent = string.Join("&", strings.ToArray()); - var content = new StringContent(postContent, Encoding.UTF8, "application/x-www-form-urlencoded"); + var bytes = Encoding.UTF8.GetBytes(postContent); + + httpWebRequest.ContentType = "application/x-www-form-urlencoded"; + httpWebRequest.ContentLength = bytes.Length; + httpWebRequest.GetRequestStream().Write(bytes, 0, bytes.Length); - if (resourcePool != null) + if (options.ResourcePool != null) { - await resourcePool.WaitAsync(cancellationToken).ConfigureAwait(false); + await options.ResourcePool.WaitAsync(options.CancellationToken).ConfigureAwait(false); } - _logger.Info("HttpClientManager.Post url: {0}", url); + _logger.Info("HttpClientManager.POST url: {0}", options.Url); try { - cancellationToken.ThrowIfCancellationRequested(); + options.CancellationToken.ThrowIfCancellationRequested(); + + using (var response = await httpWebRequest.GetResponseAsync().ConfigureAwait(false)) + { + var httpResponse = (HttpWebResponse)response; + + EnsureSuccessStatusCode(httpResponse); + + options.CancellationToken.ThrowIfCancellationRequested(); - var msg = await GetHttpClient(GetHostFromUrl(url), true).HttpClient.PostAsync(url, content, cancellationToken).ConfigureAwait(false); + using (var stream = httpResponse.GetResponseStream()) + { + var memoryStream = new MemoryStream(); + + await stream.CopyToAsync(memoryStream).ConfigureAwait(false); - EnsureSuccessStatusCode(msg); + memoryStream.Position = 0; - return await msg.Content.ReadAsStreamAsync().ConfigureAwait(false); + return memoryStream; + } + } } catch (OperationCanceledException ex) { - throw GetCancellationException(url, cancellationToken, ex); + var exception = GetCancellationException(options.Url, options.CancellationToken, ex); + + throw exception; } catch (HttpRequestException ex) { - _logger.ErrorException("Error getting response from " + url, ex); + _logger.ErrorException("Error getting response from " + options.Url, ex); + + throw new HttpException(ex.Message, ex); + } + catch (WebException ex) + { + _logger.ErrorException("Error getting response from " + options.Url, ex); throw new HttpException(ex.Message, ex); } + catch (Exception ex) + { + _logger.ErrorException("Error getting response from " + options.Url, ex); + + throw; + } finally { - if (resourcePool != null) + if (options.ResourcePool != null) { - resourcePool.Release(); + options.ResourcePool.Release(); } } } + /// + /// Performs a POST request + /// + /// The URL. + /// Params to add to the POST data. + /// The resource pool. + /// The cancellation token. + /// stream on success, null on failure + public Task Post(string url, Dictionary postData, SemaphoreSlim resourcePool, CancellationToken cancellationToken) + { + return Post(new HttpRequestOptions + { + Url = url, + ResourcePool = resourcePool, + CancellationToken = cancellationToken + + }, postData); + } + /// /// Downloads the contents of a given url into a temporary location /// @@ -392,6 +424,8 @@ namespace MediaBrowser.Common.Implementations.HttpClientManager options.CancellationToken.ThrowIfCancellationRequested(); + var httpWebRequest = GetRequest(options, "GET", options.EnableHttpCompression); + if (options.ResourcePool != null) { await options.ResourcePool.WaitAsync(options.CancellationToken).ConfigureAwait(false); @@ -399,60 +433,79 @@ namespace MediaBrowser.Common.Implementations.HttpClientManager options.Progress.Report(0); - _logger.Info("HttpClientManager.GetTempFile url: {0}, temp file: {1}", options.Url, tempFile); + _logger.Info("HttpClientManager.GetTempFileResponse url: {0}", options.Url); try { options.CancellationToken.ThrowIfCancellationRequested(); - using (var message = GetHttpRequestMessage(options)) + using (var response = await httpWebRequest.GetResponseAsync().ConfigureAwait(false)) { - using (var response = await GetHttpClient(GetHostFromUrl(options.Url), options.EnableHttpCompression).HttpClient.SendAsync(message, HttpCompletionOption.ResponseHeadersRead, options.CancellationToken).ConfigureAwait(false)) - { - EnsureSuccessStatusCode(response); + var httpResponse = (HttpWebResponse)response; - options.CancellationToken.ThrowIfCancellationRequested(); + EnsureSuccessStatusCode(httpResponse); - var contentLength = GetContentLength(response); + options.CancellationToken.ThrowIfCancellationRequested(); + + var contentLength = GetContentLength(httpResponse); - if (!contentLength.HasValue) + if (!contentLength.HasValue) + { + // We're not able to track progress + using (var stream = httpResponse.GetResponseStream()) { - // We're not able to track progress - using (var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false)) + using (var fs = _fileSystem.GetFileStream(tempFile, FileMode.Create, FileAccess.Write, FileShare.Read, true)) { - using (var fs = _fileSystem.GetFileStream(tempFile, FileMode.Create, FileAccess.Write, FileShare.Read, true)) - { - await stream.CopyToAsync(fs, StreamDefaults.DefaultCopyToBufferSize, options.CancellationToken).ConfigureAwait(false); - } + await stream.CopyToAsync(fs, StreamDefaults.DefaultCopyToBufferSize, options.CancellationToken).ConfigureAwait(false); } } - else + } + else + { + using (var stream = ProgressStream.CreateReadProgressStream(httpResponse.GetResponseStream(), options.Progress.Report, contentLength.Value)) { - using (var stream = ProgressStream.CreateReadProgressStream(await response.Content.ReadAsStreamAsync().ConfigureAwait(false), options.Progress.Report, contentLength.Value)) + using (var fs = _fileSystem.GetFileStream(tempFile, FileMode.Create, FileAccess.Write, FileShare.Read, true)) { - using (var fs = _fileSystem.GetFileStream(tempFile, FileMode.Create, FileAccess.Write, FileShare.Read, true)) - { - await stream.CopyToAsync(fs, StreamDefaults.DefaultCopyToBufferSize, options.CancellationToken).ConfigureAwait(false); - } + await stream.CopyToAsync(fs, StreamDefaults.DefaultCopyToBufferSize, options.CancellationToken).ConfigureAwait(false); } } + } - options.Progress.Report(100); + options.Progress.Report(100); - return new HttpResponseInfo - { - TempFilePath = tempFile, + return new HttpResponseInfo + { + TempFilePath = tempFile, - StatusCode = response.StatusCode, + StatusCode = httpResponse.StatusCode, - ContentType = response.Content.Headers.ContentType.MediaType - }; - } + ContentType = httpResponse.ContentType + }; } } + catch (OperationCanceledException ex) + { + var exception = GetCancellationException(options.Url, options.CancellationToken, ex); + + throw exception; + } + catch (HttpRequestException ex) + { + _logger.ErrorException("Error getting response from " + options.Url, ex); + + throw new HttpException(ex.Message, ex); + } + catch (WebException ex) + { + _logger.ErrorException("Error getting response from " + options.Url, ex); + + throw new HttpException(ex.Message, ex); + } catch (Exception ex) { - throw GetTempFileException(ex, options, tempFile); + _logger.ErrorException("Error getting response from " + options.Url, ex); + + throw; } finally { @@ -522,6 +575,18 @@ namespace MediaBrowser.Common.Implementations.HttpClientManager return long.Parse(string.Join(string.Empty, lengthValues.ToArray()), UsCulture); } + private long? GetContentLength(HttpWebResponse response) + { + var length = response.ContentLength; + + if (length == 0) + { + return null; + } + + return length; + } + protected static readonly CultureInfo UsCulture = new CultureInfo("en-US"); /// @@ -614,11 +679,6 @@ namespace MediaBrowser.Common.Implementations.HttpClientManager { if (dispose) { - foreach (var client in _httpClients.Values.ToList()) - { - client.HttpClient.Dispose(); - } - _httpClients.Clear(); } } @@ -659,6 +719,17 @@ namespace MediaBrowser.Common.Implementations.HttpClientManager } } + private void EnsureSuccessStatusCode(HttpWebResponse response) + { + var statusCode = response.StatusCode; + var isSuccessful = statusCode >= HttpStatusCode.OK && statusCode <= (HttpStatusCode)299; + + if (!isSuccessful) + { + throw new HttpException(response.StatusDescription) { StatusCode = response.StatusCode }; + } + } + /// /// Posts the specified URL. /// diff --git a/MediaBrowser.Common/Net/IHttpClient.cs b/MediaBrowser.Common/Net/IHttpClient.cs index 93348d4ca..54d6665e2 100644 --- a/MediaBrowser.Common/Net/IHttpClient.cs +++ b/MediaBrowser.Common/Net/IHttpClient.cs @@ -73,6 +73,11 @@ namespace MediaBrowser.Common.Net /// Task GetTempFile(HttpRequestOptions options); + /// + /// Gets the temporary file response. + /// + /// The options. + /// Task{HttpResponseInfo}. Task GetTempFileResponse(HttpRequestOptions options); } } \ No newline at end of file diff --git a/MediaBrowser.ServerApplication/ApplicationHost.cs b/MediaBrowser.ServerApplication/ApplicationHost.cs index fcd7d299c..be865881a 100644 --- a/MediaBrowser.ServerApplication/ApplicationHost.cs +++ b/MediaBrowser.ServerApplication/ApplicationHost.cs @@ -702,16 +702,6 @@ namespace MediaBrowser.ServerApplication OnApplicationUpdated(package.version); } - /// - /// Creates the HTTP client. - /// - /// if set to true [enable HTTP compression]. - /// HttpClient. - protected override HttpClient CreateHttpClient(bool enableHttpCompression) - { - return HttpClientFactory.GetHttpClient(enableHttpCompression); - } - protected override void ConfigureAutoRunAtStartup(bool autorun) { Autorun.Configure(autorun); diff --git a/MediaBrowser.ServerApplication/MediaBrowser.ServerApplication.csproj b/MediaBrowser.ServerApplication/MediaBrowser.ServerApplication.csproj index cfacffe08..795799ca3 100644 --- a/MediaBrowser.ServerApplication/MediaBrowser.ServerApplication.csproj +++ b/MediaBrowser.ServerApplication/MediaBrowser.ServerApplication.csproj @@ -190,7 +190,6 @@ - diff --git a/MediaBrowser.ServerApplication/Native/HttpClientFactory.cs b/MediaBrowser.ServerApplication/Native/HttpClientFactory.cs deleted file mode 100644 index 368c60254..000000000 --- a/MediaBrowser.ServerApplication/Native/HttpClientFactory.cs +++ /dev/null @@ -1,35 +0,0 @@ -using System; -using System.Net; -using System.Net.Cache; -using System.Net.Http; - -namespace MediaBrowser.ServerApplication.Native -{ - /// - /// Class HttpClientFactory - /// - public static class HttpClientFactory - { - /// - /// Gets the HTTP client. - /// - /// if set to true [enable HTTP compression]. - /// HttpClient. - public static HttpClient GetHttpClient(bool enableHttpCompression) - { - var client = new HttpClient(new WebRequestHandler - { - CachePolicy = new RequestCachePolicy(RequestCacheLevel.Revalidate), - AutomaticDecompression = enableHttpCompression ? DecompressionMethods.Deflate : DecompressionMethods.None - - }) - { - Timeout = TimeSpan.FromSeconds(20) - }; - - client.DefaultRequestHeaders.Add("Connection", "Keep-Alive"); - - return client; - } - } -} -- cgit v1.2.3 From 45a4d25e2615e5ec05befc61560ad54b419504eb Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sat, 30 Nov 2013 01:49:38 -0500 Subject: updated live tv methods + nuget --- .../HttpClientManager/HttpClientManager.cs | 13 ++-- MediaBrowser.Controller/LiveTv/ILiveTvService.cs | 7 +++ .../LiveTv/RecurringTimerInfo.cs | 73 ++++++++++++++++++++++ MediaBrowser.Controller/LiveTv/TimerInfo.cs | 12 ++-- .../MediaBrowser.Controller.csproj | 1 + MediaBrowser.Model/LiveTv/RecordingStatus.cs | 6 +- MediaBrowser.Model/LiveTv/TimerInfoDto.cs | 6 +- .../LiveTv/LiveTvManager.cs | 2 +- Nuget/MediaBrowser.Common.Internal.nuspec | 4 +- Nuget/MediaBrowser.Common.nuspec | 2 +- Nuget/MediaBrowser.Server.Core.nuspec | 4 +- 11 files changed, 109 insertions(+), 21 deletions(-) create mode 100644 MediaBrowser.Controller/LiveTv/RecurringTimerInfo.cs (limited to 'MediaBrowser.Common.Implementations/HttpClientManager/HttpClientManager.cs') diff --git a/MediaBrowser.Common.Implementations/HttpClientManager/HttpClientManager.cs b/MediaBrowser.Common.Implementations/HttpClientManager/HttpClientManager.cs index ea1a5c726..8d80185ad 100644 --- a/MediaBrowser.Common.Implementations/HttpClientManager/HttpClientManager.cs +++ b/MediaBrowser.Common.Implementations/HttpClientManager/HttpClientManager.cs @@ -24,6 +24,11 @@ namespace MediaBrowser.Common.Implementations.HttpClientManager /// public class HttpClientManager : IHttpClient { + /// + /// When one request to a host times out, we'll ban all other requests for this period of time, to prevent scans from stalling + /// + private int TimeoutSeconds = 30; + /// /// The _logger /// @@ -122,13 +127,13 @@ namespace MediaBrowser.Common.Implementations.HttpClientManager request.UserAgent = options.UserAgent; } + // This is a hack to prevent KeepAlive from getting disabled internally by the HttpWebRequest + // May need to remove this for mono var sp = request.ServicePoint; - if (_httpBehaviorPropertyInfo == null) { _httpBehaviorPropertyInfo = sp.GetType().GetProperty("HttpBehaviour", BindingFlags.Instance | BindingFlags.NonPublic); } - _httpBehaviorPropertyInfo.SetValue(sp, (byte)0, null); return request; @@ -150,7 +155,7 @@ namespace MediaBrowser.Common.Implementations.HttpClientManager var client = GetHttpClient(GetHostFromUrl(options.Url), options.EnableHttpCompression); - if ((DateTime.UtcNow - client.LastTimeout).TotalSeconds < 30) + if ((DateTime.UtcNow - client.LastTimeout).TotalSeconds < TimeoutSeconds) { throw new HttpException(string.Format("Cancelling connection to {0} due to a previous timeout.", options.Url)) { IsTimedOut = true }; } @@ -162,7 +167,7 @@ namespace MediaBrowser.Common.Implementations.HttpClientManager await options.ResourcePool.WaitAsync(options.CancellationToken).ConfigureAwait(false); } - if ((DateTime.UtcNow - client.LastTimeout).TotalSeconds < 30) + if ((DateTime.UtcNow - client.LastTimeout).TotalSeconds < TimeoutSeconds) { if (options.ResourcePool != null) { diff --git a/MediaBrowser.Controller/LiveTv/ILiveTvService.cs b/MediaBrowser.Controller/LiveTv/ILiveTvService.cs index 9bc032af3..2b58d8bc5 100644 --- a/MediaBrowser.Controller/LiveTv/ILiveTvService.cs +++ b/MediaBrowser.Controller/LiveTv/ILiveTvService.cs @@ -68,6 +68,13 @@ namespace MediaBrowser.Controller.LiveTv /// The cancellation token. /// Task{IEnumerable{RecordingInfo}}. Task> GetTimersAsync(CancellationToken cancellationToken); + + /// + /// Gets the recurring timers asynchronous. + /// + /// The cancellation token. + /// Task{IEnumerable{RecurringTimerInfo}}. + Task> GetRecurringTimersAsync(CancellationToken cancellationToken); /// /// Gets the programs asynchronous. diff --git a/MediaBrowser.Controller/LiveTv/RecurringTimerInfo.cs b/MediaBrowser.Controller/LiveTv/RecurringTimerInfo.cs new file mode 100644 index 000000000..08a8b1f92 --- /dev/null +++ b/MediaBrowser.Controller/LiveTv/RecurringTimerInfo.cs @@ -0,0 +1,73 @@ +using MediaBrowser.Model.LiveTv; +using System; + +namespace MediaBrowser.Controller.LiveTv +{ + public class RecurringTimerInfo + { + /// + /// Id of the recording. + /// + public string Id { get; set; } + + /// + /// ChannelId of the recording. + /// + public string ChannelId { get; set; } + + /// + /// ChannelName of the recording. + /// + public string ChannelName { get; set; } + + /// + /// Gets or sets the program identifier. + /// + /// The program identifier. + public string ProgramId { get; set; } + + /// + /// Name of the recording. + /// + public string Name { get; set; } + + /// + /// Description of the recording. + /// + public string Description { get; set; } + + /// + /// The start date of the recording, in UTC. + /// + public DateTime StartDate { get; set; } + + /// + /// The end date of the recording, in UTC. + /// + public DateTime EndDate { get; set; } + + /// + /// Gets or sets the status. + /// + /// The status. + public RecordingStatus Status { get; set; } + + /// + /// Gets or sets the pre padding seconds. + /// + /// The pre padding seconds. + public int PrePaddingSeconds { get; set; } + + /// + /// Gets or sets the post padding seconds. + /// + /// The post padding seconds. + public int PostPaddingSeconds { get; set; } + + /// + /// Gets or sets the type of the recurrence. + /// + /// The type of the recurrence. + public RecurrenceType RecurrenceType { get; set; } + } +} diff --git a/MediaBrowser.Controller/LiveTv/TimerInfo.cs b/MediaBrowser.Controller/LiveTv/TimerInfo.cs index 624dc62ca..0fe7c34f2 100644 --- a/MediaBrowser.Controller/LiveTv/TimerInfo.cs +++ b/MediaBrowser.Controller/LiveTv/TimerInfo.cs @@ -10,6 +10,12 @@ namespace MediaBrowser.Controller.LiveTv /// public string Id { get; set; } + /// + /// Gets or sets the recurring timer identifier. + /// + /// The recurring timer identifier. + public string RecurringTimerId { get; set; } + /// /// ChannelId of the recording. /// @@ -52,12 +58,6 @@ namespace MediaBrowser.Controller.LiveTv /// The status. public RecordingStatus Status { get; set; } - /// - /// Gets or sets a value indicating whether this instance is recurring. - /// - /// true if this instance is recurring; otherwise, false. - public bool IsRecurring { get; set; } - /// /// Gets or sets the pre padding seconds. /// diff --git a/MediaBrowser.Controller/MediaBrowser.Controller.csproj b/MediaBrowser.Controller/MediaBrowser.Controller.csproj index 2068fccf8..ec0439c2c 100644 --- a/MediaBrowser.Controller/MediaBrowser.Controller.csproj +++ b/MediaBrowser.Controller/MediaBrowser.Controller.csproj @@ -110,6 +110,7 @@ + diff --git a/MediaBrowser.Model/LiveTv/RecordingStatus.cs b/MediaBrowser.Model/LiveTv/RecordingStatus.cs index 778977340..08a7cfb0c 100644 --- a/MediaBrowser.Model/LiveTv/RecordingStatus.cs +++ b/MediaBrowser.Model/LiveTv/RecordingStatus.cs @@ -14,7 +14,9 @@ namespace MediaBrowser.Model.LiveTv public enum RecurrenceType { Manual, - NewProgramEvents, - AllProgramEvents + NewProgramEventsOneChannel, + AllProgramEventsOneChannel, + NewProgramEventsAllChannels, + AllProgramEventsAllChannels } } diff --git a/MediaBrowser.Model/LiveTv/TimerInfoDto.cs b/MediaBrowser.Model/LiveTv/TimerInfoDto.cs index 5d8ac20c4..f7d63e968 100644 --- a/MediaBrowser.Model/LiveTv/TimerInfoDto.cs +++ b/MediaBrowser.Model/LiveTv/TimerInfoDto.cs @@ -58,10 +58,10 @@ namespace MediaBrowser.Model.LiveTv public RecordingStatus Status { get; set; } /// - /// Gets or sets a value indicating whether this instance is recurring. + /// Gets or sets the recurring timer identifier. /// - /// true if this instance is recurring; otherwise, false. - public bool IsRecurring { get; set; } + /// The recurring timer identifier. + public string RecurringTimerId { get; set; } /// /// Gets or sets the pre padding seconds. diff --git a/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs b/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs index b55393213..ea8ea45b6 100644 --- a/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs +++ b/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs @@ -514,7 +514,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv ExternalId = info.Id, ChannelId = GetInternalChannelId(service.Name, info.ChannelId, info.ChannelName).ToString("N"), Status = info.Status, - IsRecurring = info.IsRecurring, + RecurringTimerId = info.RecurringTimerId, PrePaddingSeconds = info.PrePaddingSeconds, PostPaddingSeconds = info.PostPaddingSeconds }; diff --git a/Nuget/MediaBrowser.Common.Internal.nuspec b/Nuget/MediaBrowser.Common.Internal.nuspec index 77765ddc6..17311530f 100644 --- a/Nuget/MediaBrowser.Common.Internal.nuspec +++ b/Nuget/MediaBrowser.Common.Internal.nuspec @@ -2,7 +2,7 @@ MediaBrowser.Common.Internal - 3.0.253 + 3.0.254 MediaBrowser.Common.Internal Luke ebr,Luke,scottisafool @@ -12,7 +12,7 @@ Contains common components shared by Media Browser Theater and Media Browser Server. Not intended for plugin developer consumption. Copyright © Media Browser 2013 - + diff --git a/Nuget/MediaBrowser.Common.nuspec b/Nuget/MediaBrowser.Common.nuspec index ac6b606cd..e95a638ab 100644 --- a/Nuget/MediaBrowser.Common.nuspec +++ b/Nuget/MediaBrowser.Common.nuspec @@ -2,7 +2,7 @@ MediaBrowser.Common - 3.0.253 + 3.0.254 MediaBrowser.Common Media Browser Team ebr,Luke,scottisafool diff --git a/Nuget/MediaBrowser.Server.Core.nuspec b/Nuget/MediaBrowser.Server.Core.nuspec index a6c1bee11..38bb37530 100644 --- a/Nuget/MediaBrowser.Server.Core.nuspec +++ b/Nuget/MediaBrowser.Server.Core.nuspec @@ -2,7 +2,7 @@ MediaBrowser.Server.Core - 3.0.253 + 3.0.254 Media Browser.Server.Core Media Browser Team ebr,Luke,scottisafool @@ -12,7 +12,7 @@ Contains core components required to build plugins for Media Browser Server. Copyright © Media Browser 2013 - + -- cgit v1.2.3 From 58f1a314b5ef3d13c2bc034f8a8949d9e88d1c20 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sat, 30 Nov 2013 13:32:39 -0500 Subject: update to service stack 3.0.70.0 --- MediaBrowser.Api/MediaBrowser.Api.csproj | 21 ++-- MediaBrowser.Api/TvShowsService.cs | 23 ++++- MediaBrowser.Api/packages.config | 4 +- .../HttpClientManager/HttpClientManager.cs | 112 ++++----------------- .../MediaBrowser.Common.Implementations.csproj | 7 +- .../Serialization/JsonSerializer.cs | 2 + .../packages.config | 2 +- MediaBrowser.Common/MediaBrowser.Common.csproj | 21 ++-- MediaBrowser.Common/packages.config | 4 +- MediaBrowser.Model/Querying/EpisodeQuery.cs | 2 + MediaBrowser.Model/System/SystemInfo.cs | 12 +++ .../MediaBrowser.Server.Implementations.csproj | 60 +++++------ .../packages.config | 10 +- .../swagger-ui/index.html | 2 +- MediaBrowser.ServerApplication/ApplicationHost.cs | 2 + .../MediaBrowser.ServerApplication.csproj | 20 ++-- MediaBrowser.ServerApplication/packages.config | 6 +- .../MediaBrowser.WebDashboard.csproj | 21 ++-- MediaBrowser.WebDashboard/packages.config | 4 +- Nuget/MediaBrowser.Common.Internal.nuspec | 4 +- Nuget/MediaBrowser.Common.nuspec | 2 +- Nuget/MediaBrowser.Server.Core.nuspec | 4 +- 22 files changed, 155 insertions(+), 190 deletions(-) (limited to 'MediaBrowser.Common.Implementations/HttpClientManager/HttpClientManager.cs') diff --git a/MediaBrowser.Api/MediaBrowser.Api.csproj b/MediaBrowser.Api/MediaBrowser.Api.csproj index a5720dfad..706117fc2 100644 --- a/MediaBrowser.Api/MediaBrowser.Api.csproj +++ b/MediaBrowser.Api/MediaBrowser.Api.csproj @@ -38,6 +38,18 @@ Always + + False + ..\packages\ServiceStack.Common.3.9.70\lib\net35\ServiceStack.Common.dll + + + False + ..\packages\ServiceStack.Common.3.9.70\lib\net35\ServiceStack.Interfaces.dll + + + False + ..\packages\ServiceStack.Text.3.9.70\lib\net35\ServiceStack.Text.dll + @@ -47,15 +59,6 @@ ..\packages\morelinq.1.0.16006\lib\net35\MoreLinq.dll - - ..\packages\ServiceStack.Common.3.9.62\lib\net35\ServiceStack.Common.dll - - - ..\packages\ServiceStack.Common.3.9.62\lib\net35\ServiceStack.Interfaces.dll - - - ..\packages\ServiceStack.Text.3.9.62\lib\net35\ServiceStack.Text.dll - diff --git a/MediaBrowser.Api/TvShowsService.cs b/MediaBrowser.Api/TvShowsService.cs index 23b8efa7b..9191bfc0c 100644 --- a/MediaBrowser.Api/TvShowsService.cs +++ b/MediaBrowser.Api/TvShowsService.cs @@ -81,6 +81,9 @@ namespace MediaBrowser.Api [ApiMember(Name = "Season", Description = "Optional filter by season number.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")] public int? Season { get; set; } + [ApiMember(Name = "SeasonId", Description = "Optional. Filter by season id", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")] + public string SeasonId { get; set; } + [ApiMember(Name = "IsMissing", Description = "Optional filter by items that are missing episodes or not.", IsRequired = false, DataType = "bool", ParameterType = "query", Verb = "GET")] public bool? IsMissing { get; set; } @@ -442,7 +445,25 @@ namespace MediaBrowser.Api var sortOrder = ItemSortBy.SortName; - if (request.Season.HasValue) + if (!string.IsNullOrEmpty(request.SeasonId)) + { + var season = _libraryManager.GetItemById(request.Id) as Season; + + if (season.IndexNumber.HasValue) + { + episodes = FilterEpisodesBySeason(episodes, season.IndexNumber.Value, true); + + sortOrder = ItemSortBy.AiredEpisodeOrder; + } + else + { + episodes = season.RecursiveChildren.OfType(); + + sortOrder = ItemSortBy.SortName; + } + } + + else if (request.Season.HasValue) { episodes = FilterEpisodesBySeason(episodes, request.Season.Value, true); diff --git a/MediaBrowser.Api/packages.config b/MediaBrowser.Api/packages.config index c9fec8100..e9a27e8ad 100644 --- a/MediaBrowser.Api/packages.config +++ b/MediaBrowser.Api/packages.config @@ -1,6 +1,6 @@  - - + + \ No newline at end of file diff --git a/MediaBrowser.Common.Implementations/HttpClientManager/HttpClientManager.cs b/MediaBrowser.Common.Implementations/HttpClientManager/HttpClientManager.cs index 8d80185ad..8fccb7c2a 100644 --- a/MediaBrowser.Common.Implementations/HttpClientManager/HttpClientManager.cs +++ b/MediaBrowser.Common.Implementations/HttpClientManager/HttpClientManager.cs @@ -27,7 +27,7 @@ namespace MediaBrowser.Common.Implementations.HttpClientManager /// /// When one request to a host times out, we'll ban all other requests for this period of time, to prevent scans from stalling /// - private int TimeoutSeconds = 30; + private const int TimeoutSeconds = 30; /// /// The _logger @@ -42,16 +42,14 @@ namespace MediaBrowser.Common.Implementations.HttpClientManager private readonly IFileSystem _fileSystem; /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// The app paths. /// The logger. - /// The get HTTP client handler. - /// - /// appPaths + /// The file system. + /// appPaths /// or - /// logger - /// + /// logger public HttpClientManager(IApplicationPaths appPaths, ILogger logger, IFileSystem fileSystem) { if (appPaths == null) @@ -143,7 +141,6 @@ namespace MediaBrowser.Common.Implementations.HttpClientManager /// Gets the response internal. /// /// The options. - /// The HTTP method. /// Task{HttpResponseInfo}. /// /// @@ -490,27 +487,19 @@ namespace MediaBrowser.Common.Implementations.HttpClientManager } catch (OperationCanceledException ex) { - var exception = GetCancellationException(options.Url, options.CancellationToken, ex); - - throw exception; + throw GetTempFileException(ex, options, tempFile); } catch (HttpRequestException ex) { - _logger.ErrorException("Error getting response from " + options.Url, ex); - - throw new HttpException(ex.Message, ex); + throw GetTempFileException(ex, options, tempFile); } catch (WebException ex) { - _logger.ErrorException("Error getting response from " + options.Url, ex); - - throw new HttpException(ex.Message, ex); + throw GetTempFileException(ex, options, tempFile); } catch (Exception ex) { - _logger.ErrorException("Error getting response from " + options.Url, ex); - - throw; + throw GetTempFileException(ex, options, tempFile); } finally { @@ -521,65 +510,6 @@ namespace MediaBrowser.Common.Implementations.HttpClientManager } } - /// - /// Gets the message. - /// - /// The options. - /// HttpResponseMessage. - private HttpRequestMessage GetHttpRequestMessage(HttpRequestOptions options) - { - var message = new HttpRequestMessage(HttpMethod.Get, options.Url); - - foreach (var pair in options.RequestHeaders.ToList()) - { - if (!message.Headers.TryAddWithoutValidation(pair.Key, pair.Value)) - { - _logger.Error("Unable to add request header {0} with value {1}", pair.Key, pair.Value); - } - } - - return message; - } - - /// - /// Gets the length of the content. - /// - /// The response. - /// System.Nullable{System.Int64}. - private long? GetContentLength(HttpResponseMessage response) - { - IEnumerable lengthValues = null; - - // Seeing some InvalidOperationException here under mono - try - { - response.Headers.TryGetValues("content-length", out lengthValues); - } - catch (InvalidOperationException ex) - { - _logger.ErrorException("Error accessing response.Headers.TryGetValues Content-Length", ex); - } - - if (lengthValues == null) - { - try - { - response.Content.Headers.TryGetValues("content-length", out lengthValues); - } - catch (InvalidOperationException ex) - { - _logger.ErrorException("Error accessing response.Content.Headers.TryGetValues Content-Length", ex); - } - } - - if (lengthValues == null) - { - return null; - } - - return long.Parse(string.Join(string.Empty, lengthValues.ToArray()), UsCulture); - } - private long? GetContentLength(HttpWebResponse response) { var length = response.ContentLength; @@ -616,16 +546,23 @@ namespace MediaBrowser.Common.Implementations.HttpClientManager _logger.ErrorException("Error getting response from " + options.Url, ex); - var httpRequestException = ex as HttpRequestException; - // Cleanup DeleteTempFile(tempFile); + var httpRequestException = ex as HttpRequestException; + if (httpRequestException != null) { return new HttpException(ex.Message, ex); } + var webException = ex as WebException; + + if (webException != null) + { + return new HttpException(ex.Message, ex); + } + return ex; } @@ -711,19 +648,6 @@ namespace MediaBrowser.Common.Implementations.HttpClientManager return exception; } - /// - /// Ensures the success status code. - /// - /// The response. - /// - private void EnsureSuccessStatusCode(HttpResponseMessage response) - { - if (!response.IsSuccessStatusCode) - { - throw new HttpException(response.ReasonPhrase) { StatusCode = response.StatusCode }; - } - } - private void EnsureSuccessStatusCode(HttpWebResponse response) { var statusCode = response.StatusCode; diff --git a/MediaBrowser.Common.Implementations/MediaBrowser.Common.Implementations.csproj b/MediaBrowser.Common.Implementations/MediaBrowser.Common.Implementations.csproj index 9e48f3b3e..948785575 100644 --- a/MediaBrowser.Common.Implementations/MediaBrowser.Common.Implementations.csproj +++ b/MediaBrowser.Common.Implementations/MediaBrowser.Common.Implementations.csproj @@ -41,6 +41,10 @@ False ..\packages\NLog.2.1.0\lib\net45\NLog.dll + + False + ..\packages\ServiceStack.Text.3.9.70\lib\net35\ServiceStack.Text.dll + ..\packages\sharpcompress.0.10.1.3\lib\net40\SharpCompress.dll @@ -55,9 +59,6 @@ - - ..\packages\ServiceStack.Text.3.9.62\lib\net35\ServiceStack.Text.dll - diff --git a/MediaBrowser.Common.Implementations/Serialization/JsonSerializer.cs b/MediaBrowser.Common.Implementations/Serialization/JsonSerializer.cs index 4a6b9255c..3ff956040 100644 --- a/MediaBrowser.Common.Implementations/Serialization/JsonSerializer.cs +++ b/MediaBrowser.Common.Implementations/Serialization/JsonSerializer.cs @@ -169,6 +169,8 @@ namespace MediaBrowser.Common.Implementations.Serialization ServiceStack.Text.JsConfig.DateHandler = ServiceStack.Text.JsonDateHandler.ISO8601; ServiceStack.Text.JsConfig.ExcludeTypeInfo = true; ServiceStack.Text.JsConfig.IncludeNullValues = false; + ServiceStack.Text.JsConfig.AlwaysUseUtc = true; + ServiceStack.Text.JsConfig.AssumeUtc = true; } /// diff --git a/MediaBrowser.Common.Implementations/packages.config b/MediaBrowser.Common.Implementations/packages.config index f2fe48830..269ac0e56 100644 --- a/MediaBrowser.Common.Implementations/packages.config +++ b/MediaBrowser.Common.Implementations/packages.config @@ -1,7 +1,7 @@  - + \ No newline at end of file diff --git a/MediaBrowser.Common/MediaBrowser.Common.csproj b/MediaBrowser.Common/MediaBrowser.Common.csproj index f4d759a4d..a9499dedd 100644 --- a/MediaBrowser.Common/MediaBrowser.Common.csproj +++ b/MediaBrowser.Common/MediaBrowser.Common.csproj @@ -35,18 +35,21 @@ 4 - - - - - ..\packages\ServiceStack.Common.3.9.62\lib\net35\ServiceStack.Common.dll + + False + ..\packages\ServiceStack.Common.3.9.70\lib\net35\ServiceStack.Common.dll - - ..\packages\ServiceStack.Common.3.9.62\lib\net35\ServiceStack.Interfaces.dll + + False + ..\packages\ServiceStack.Common.3.9.70\lib\net35\ServiceStack.Interfaces.dll - - ..\packages\ServiceStack.Text.3.9.62\lib\net35\ServiceStack.Text.dll + + False + ..\packages\ServiceStack.Text.3.9.70\lib\net35\ServiceStack.Text.dll + + + diff --git a/MediaBrowser.Common/packages.config b/MediaBrowser.Common/packages.config index 6969b43c5..7411e313c 100644 --- a/MediaBrowser.Common/packages.config +++ b/MediaBrowser.Common/packages.config @@ -1,5 +1,5 @@  - - + + \ No newline at end of file diff --git a/MediaBrowser.Model/Querying/EpisodeQuery.cs b/MediaBrowser.Model/Querying/EpisodeQuery.cs index 56c50da7f..589b46433 100644 --- a/MediaBrowser.Model/Querying/EpisodeQuery.cs +++ b/MediaBrowser.Model/Querying/EpisodeQuery.cs @@ -5,6 +5,8 @@ namespace MediaBrowser.Model.Querying { public string UserId { get; set; } + public string SeasonId { get; set; } + public string SeriesId { get; set; } public bool? IsMissing { get; set; } diff --git a/MediaBrowser.Model/System/SystemInfo.cs b/MediaBrowser.Model/System/SystemInfo.cs index 9491139db..6a17ad133 100644 --- a/MediaBrowser.Model/System/SystemInfo.cs +++ b/MediaBrowser.Model/System/SystemInfo.cs @@ -92,6 +92,18 @@ namespace MediaBrowser.Model.System /// The program data path. public string ProgramDataPath { get; set; } + /// + /// Gets or sets the items by name path. + /// + /// The items by name path. + public string ItemsByNamePath { get; set; } + + /// + /// Gets or sets the log path. + /// + /// The log path. + public string LogPath { get; set; } + /// /// Gets or sets the HTTP server port number. /// diff --git a/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj b/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj index f5ade2516..2d32811d3 100644 --- a/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj +++ b/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj @@ -41,8 +41,29 @@ False ..\packages\MediaBrowser.BdInfo.1.0.0.5\lib\net20\BDInfo.dll - - ..\packages\ServiceStack.OrmLite.Sqlite32.3.9.63\lib\net40\ServiceStack.OrmLite.SqliteNET.dll + + False + ..\packages\ServiceStack.3.9.70\lib\net35\ServiceStack.dll + + + False + ..\packages\ServiceStack.Api.Swagger.3.9.70\lib\net35\ServiceStack.Api.Swagger.dll + + + False + ..\packages\ServiceStack.Common.3.9.70\lib\net35\ServiceStack.Common.dll + + + False + ..\packages\ServiceStack.Common.3.9.70\lib\net35\ServiceStack.Interfaces.dll + + + False + ..\packages\ServiceStack.3.9.70\lib\net35\ServiceStack.ServiceInterface.dll + + + False + ..\packages\ServiceStack.Text.3.9.70\lib\net35\ServiceStack.Text.dll @@ -72,39 +93,12 @@ ..\packages\morelinq.1.0.16006\lib\net35\MoreLinq.dll - - ..\packages\ServiceStack.3.9.62\lib\net35\ServiceStack.dll - - - ..\packages\ServiceStack.Api.Swagger.3.9.59\lib\net35\ServiceStack.Api.Swagger.dll - - - ..\packages\ServiceStack.Common.3.9.62\lib\net35\ServiceStack.Common.dll - - - ..\packages\ServiceStack.Common.3.9.62\lib\net35\ServiceStack.Interfaces.dll - ..\packages\ServiceStack.OrmLite.SqlServer.3.9.43\lib\ServiceStack.OrmLite.SqlServer.dll ..\packages\ServiceStack.Redis.3.9.43\lib\net35\ServiceStack.Redis.dll - - ..\packages\ServiceStack.3.9.62\lib\net35\ServiceStack.ServiceInterface.dll - - - ..\packages\ServiceStack.Text.3.9.62\lib\net35\ServiceStack.Text.dll - - - ..\packages\ServiceStack.OrmLite.Sqlite.Mono.3.9.64\lib\net35\Mono.Data.Sqlite.dll - - - ..\packages\ServiceStack.OrmLite.Sqlite.Mono.3.9.64\lib\net35\ServiceStack.OrmLite.dll - - - ..\packages\ServiceStack.OrmLite.Sqlite.Mono.3.9.64\lib\net35\ServiceStack.OrmLite.Sqlite.dll - @@ -268,7 +262,6 @@ - PreserveNewest @@ -287,9 +280,6 @@ PreserveNewest - - PreserveNewest - PreserveNewest @@ -323,6 +313,10 @@ PreserveNewest + + + PreserveNewest + diff --git a/MediaBrowser.Server.Implementations/packages.config b/MediaBrowser.Server.Implementations/packages.config index eeeedfe36..d5abe58ca 100644 --- a/MediaBrowser.Server.Implementations/packages.config +++ b/MediaBrowser.Server.Implementations/packages.config @@ -6,13 +6,11 @@ - - - - - + + + - + \ No newline at end of file diff --git a/MediaBrowser.Server.Implementations/swagger-ui/index.html b/MediaBrowser.Server.Implementations/swagger-ui/index.html index 0fcc06959..49f983a72 100644 --- a/MediaBrowser.Server.Implementations/swagger-ui/index.html +++ b/MediaBrowser.Server.Implementations/swagger-ui/index.html @@ -20,7 +20,7 @@ $(function () { window.swaggerUi = new SwaggerUi({ discoveryUrl: "../resources", - apiKey:"special-key", + apiKey: "special-key", dom_id:"swagger-ui-container", supportHeaderParams: false, supportedSubmitMethods: ['get', 'post', 'put'], diff --git a/MediaBrowser.ServerApplication/ApplicationHost.cs b/MediaBrowser.ServerApplication/ApplicationHost.cs index be865881a..d2d700839 100644 --- a/MediaBrowser.ServerApplication/ApplicationHost.cs +++ b/MediaBrowser.ServerApplication/ApplicationHost.cs @@ -609,6 +609,8 @@ namespace MediaBrowser.ServerApplication CompletedInstallations = InstallationManager.CompletedInstallations.ToList(), Id = _systemId, ProgramDataPath = ApplicationPaths.ProgramDataPath, + LogPath = ApplicationPaths.LogDirectoryPath, + ItemsByNamePath = ApplicationPaths.ItemsByNamePath, MacAddress = GetMacAddress(), HttpServerPortNumber = ServerConfigurationManager.Configuration.HttpServerPortNumber, OperatingSystem = Environment.OSVersion.ToString(), diff --git a/MediaBrowser.ServerApplication/MediaBrowser.ServerApplication.csproj b/MediaBrowser.ServerApplication/MediaBrowser.ServerApplication.csproj index 795799ca3..5f05bc787 100644 --- a/MediaBrowser.ServerApplication/MediaBrowser.ServerApplication.csproj +++ b/MediaBrowser.ServerApplication/MediaBrowser.ServerApplication.csproj @@ -131,17 +131,17 @@ False ..\packages\MediaBrowser.IsoMounting.3.0.65\lib\net45\pfmclrapi.dll - + False - ..\packages\ServiceStack.3.9.62\lib\net35\ServiceStack.dll + ..\packages\ServiceStack.3.9.70\lib\net35\ServiceStack.dll - + False - ..\packages\ServiceStack.Common.3.9.62\lib\net35\ServiceStack.Common.dll + ..\packages\ServiceStack.Common.3.9.70\lib\net35\ServiceStack.Common.dll - + False - ..\packages\ServiceStack.Common.3.9.62\lib\net35\ServiceStack.Interfaces.dll + ..\packages\ServiceStack.Common.3.9.70\lib\net35\ServiceStack.Interfaces.dll ..\packages\ServiceStack.OrmLite.SqlServer.3.9.44\lib\ServiceStack.OrmLite.SqlServer.dll @@ -149,13 +149,13 @@ ..\packages\ServiceStack.Redis.3.9.44\lib\net35\ServiceStack.Redis.dll - + False - ..\packages\ServiceStack.3.9.62\lib\net35\ServiceStack.ServiceInterface.dll + ..\packages\ServiceStack.3.9.70\lib\net35\ServiceStack.ServiceInterface.dll - + False - ..\packages\ServiceStack.Text.3.9.62\lib\net35\ServiceStack.Text.dll + ..\packages\ServiceStack.Text.3.9.70\lib\net35\ServiceStack.Text.dll False diff --git a/MediaBrowser.ServerApplication/packages.config b/MediaBrowser.ServerApplication/packages.config index e01ca1f67..5d7c3265f 100644 --- a/MediaBrowser.ServerApplication/packages.config +++ b/MediaBrowser.ServerApplication/packages.config @@ -3,10 +3,10 @@ - - + + - + \ No newline at end of file diff --git a/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj b/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj index 73b281d9a..d36413fc2 100644 --- a/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj +++ b/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj @@ -37,21 +37,24 @@ Always + + False + ..\packages\ServiceStack.Common.3.9.70\lib\net35\ServiceStack.Common.dll + + + False + ..\packages\ServiceStack.Common.3.9.70\lib\net35\ServiceStack.Interfaces.dll + + + False + ..\packages\ServiceStack.Text.3.9.70\lib\net35\ServiceStack.Text.dll + - - ..\packages\ServiceStack.Common.3.9.62\lib\net35\ServiceStack.Common.dll - - - ..\packages\ServiceStack.Common.3.9.62\lib\net35\ServiceStack.Interfaces.dll - - - ..\packages\ServiceStack.Text.3.9.62\lib\net35\ServiceStack.Text.dll - diff --git a/MediaBrowser.WebDashboard/packages.config b/MediaBrowser.WebDashboard/packages.config index a839ece18..4fa4e5a9e 100644 --- a/MediaBrowser.WebDashboard/packages.config +++ b/MediaBrowser.WebDashboard/packages.config @@ -1,6 +1,6 @@  - - + + \ No newline at end of file diff --git a/Nuget/MediaBrowser.Common.Internal.nuspec b/Nuget/MediaBrowser.Common.Internal.nuspec index 17311530f..150b081dc 100644 --- a/Nuget/MediaBrowser.Common.Internal.nuspec +++ b/Nuget/MediaBrowser.Common.Internal.nuspec @@ -2,7 +2,7 @@ MediaBrowser.Common.Internal - 3.0.254 + 3.0.255 MediaBrowser.Common.Internal Luke ebr,Luke,scottisafool @@ -12,7 +12,7 @@ Contains common components shared by Media Browser Theater and Media Browser Server. Not intended for plugin developer consumption. Copyright © Media Browser 2013 - + diff --git a/Nuget/MediaBrowser.Common.nuspec b/Nuget/MediaBrowser.Common.nuspec index e95a638ab..c28fa7922 100644 --- a/Nuget/MediaBrowser.Common.nuspec +++ b/Nuget/MediaBrowser.Common.nuspec @@ -2,7 +2,7 @@ MediaBrowser.Common - 3.0.254 + 3.0.255 MediaBrowser.Common Media Browser Team ebr,Luke,scottisafool diff --git a/Nuget/MediaBrowser.Server.Core.nuspec b/Nuget/MediaBrowser.Server.Core.nuspec index 38bb37530..32f1da536 100644 --- a/Nuget/MediaBrowser.Server.Core.nuspec +++ b/Nuget/MediaBrowser.Server.Core.nuspec @@ -2,7 +2,7 @@ MediaBrowser.Server.Core - 3.0.254 + 3.0.255 Media Browser.Server.Core Media Browser Team ebr,Luke,scottisafool @@ -12,7 +12,7 @@ Contains core components required to build plugins for Media Browser Server. Copyright © Media Browser 2013 - + -- cgit v1.2.3 From d2332264b399ea57e81732bcae2cbf450ede443d Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Tue, 3 Dec 2013 16:12:40 -0500 Subject: mono fixes for http requests --- .../HttpClientManager/HttpClientManager.cs | 29 ++++++++++++++++++++-- MediaBrowser.Mono.userprefs | 2 +- .../FFMpeg/FFMpegDownloader.cs | 6 +---- 3 files changed, 29 insertions(+), 8 deletions(-) (limited to 'MediaBrowser.Common.Implementations/HttpClientManager/HttpClientManager.cs') diff --git a/MediaBrowser.Common.Implementations/HttpClientManager/HttpClientManager.cs b/MediaBrowser.Common.Implementations/HttpClientManager/HttpClientManager.cs index 8fccb7c2a..214ed106d 100644 --- a/MediaBrowser.Common.Implementations/HttpClientManager/HttpClientManager.cs +++ b/MediaBrowser.Common.Implementations/HttpClientManager/HttpClientManager.cs @@ -101,10 +101,35 @@ namespace MediaBrowser.Common.Implementations.HttpClientManager return client; } - private PropertyInfo _httpBehaviorPropertyInfo; + private WebRequest GetMonoRequest(HttpRequestOptions options, string method, bool enableHttpCompression) + { + var request = WebRequest.Create(options.Url); + + if (!string.IsNullOrEmpty(options.AcceptHeader)) + { + request.Headers.Add("Accept", options.AcceptHeader); + } + + request.CachePolicy = new RequestCachePolicy(RequestCacheLevel.Revalidate); + request.ConnectionGroupName = GetHostFromUrl(options.Url); + request.Method = method; + request.Timeout = 20000; + + if (!string.IsNullOrEmpty(options.UserAgent)) + { + request.Headers.Add("User-Agent", options.UserAgent); + } - private HttpWebRequest GetRequest(HttpRequestOptions options, string method, bool enableHttpCompression) + return request; + } + + private PropertyInfo _httpBehaviorPropertyInfo; + private WebRequest GetRequest(HttpRequestOptions options, string method, bool enableHttpCompression) { +#if __MonoCS__ + return GetMonoRequest(options, method, enableHttpCompression); +#endif + var request = HttpWebRequest.CreateHttp(options.Url); if (!string.IsNullOrEmpty(options.AcceptHeader)) diff --git a/MediaBrowser.Mono.userprefs b/MediaBrowser.Mono.userprefs index 4a91e2e60..b3c4d6d23 100644 --- a/MediaBrowser.Mono.userprefs +++ b/MediaBrowser.Mono.userprefs @@ -4,7 +4,7 @@ - + diff --git a/MediaBrowser.ServerApplication/FFMpeg/FFMpegDownloader.cs b/MediaBrowser.ServerApplication/FFMpeg/FFMpegDownloader.cs index e8af0a13e..1f329446e 100644 --- a/MediaBrowser.ServerApplication/FFMpeg/FFMpegDownloader.cs +++ b/MediaBrowser.ServerApplication/FFMpeg/FFMpegDownloader.cs @@ -90,11 +90,7 @@ namespace MediaBrowser.ServerApplication.FFMpeg { Url = url, CancellationToken = CancellationToken.None, - Progress = new Progress(), - - // Make it look like a browser - // Try to hide that we're direct linking - UserAgent = "Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/30.0.1599.47 Safari/537.36" + Progress = new Progress() }); } -- cgit v1.2.3