public static HttpClient BuildClient(MusicEndpoint e) { var handler = new HttpClientHandler(); if (handler.SupportsAutomaticDecompression) { handler.AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate; } else { handler.AutomaticDecompression = DecompressionMethods.None; } var client = new HttpClient(handler); client.BaseAddress = new Uri(e.Protocol + "://" + e.Server + ":" + e.Port); var headers = client.DefaultRequestHeaders; headers.Authorization = HttpUtil.BasicAuthHeaderValue(e.Username, e.Password); return(client); }
protected virtual AuthenticationHeaderValue AuthorizationHeader(string username, string password) { return(HttpUtil.BasicAuthHeaderValue(username, password)); }