using System; using System.Net; using System.Net.Http; namespace MediaBrowser.ApiInteraction { /// /// Provides a base class used by the api and image services /// public abstract class BaseClient : IDisposable { /// /// Gets or sets the server host name (myserver or 192.168.x.x) /// public string ServerHostName { get; set; } /// /// Gets or sets the port number used by the API /// public int ServerApiPort { get; set; } /// /// Gets the current api url based on hostname and port. /// protected string ApiUrl { get { return string.Format("http://{0}:{1}/mediabrowser/api", ServerHostName, ServerApiPort); } } protected HttpClient HttpClient { get; private set; } public BaseClient() : this(new HttpClientHandler()) { } public BaseClient(HttpClientHandler clientHandler) { clientHandler.AutomaticDecompression = DecompressionMethods.Deflate; HttpClient = new HttpClient(clientHandler); } public void Dispose() { HttpClient.Dispose(); } } }