コード例 #1
0
        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);
        }
コード例 #2
0
ファイル: SessionBase.cs プロジェクト: malliina/musicpimp-win
 protected virtual AuthenticationHeaderValue AuthorizationHeader(string username, string password)
 {
     return(HttpUtil.BasicAuthHeaderValue(username, password));
 }