From: ttp Date: Sun, 31 Oct 2010 10:54:41 +0000 (+0900) Subject: na-get,認証プロキシではネットワーク接続できなかった問題の暫定対処(http://ユーザ:パス@example.com:port/ の手動設定のみ対応;IEの設定か... X-Git-Tag: v1.3.6~1 X-Git-Url: http://git.sourceforge.jp/view?p=applistation%2FAppliStation.git;a=commitdiff_plain;h=50a4e847f0062f49715eb0cdd4d2231659e0690e na-get,認証プロキシではネットワーク接続できなかった問題の暫定対処(ユーザ:パス@example.com:port/ の手動設定のみ対応;IEの設定からは引き継がれない) --- diff --git a/na-get-lib/NaGet/Env.cs b/na-get-lib/NaGet/Env.cs index 260452e..2f799d2 100644 --- a/na-get-lib/NaGet/Env.cs +++ b/na-get-lib/NaGet/Env.cs @@ -173,7 +173,24 @@ namespace NaGet return null; } else { // host:portが設定されているならば、それをもとに設定 - return new WebProxy(pref.ProxyAddress); + WebProxy proxy = new WebProxy(pref.ProxyAddress); + + // 認証プロキシの場合、認証情報を付加する + try { + Uri uri = new Uri(pref.ProxyAddress); + if (! string.IsNullOrEmpty(uri.UserInfo)) { + int pos = uri.UserInfo.IndexOf(':'); + if (pos >= 0) { + proxy.Credentials = new NetworkCredential( + uri.UserInfo.Substring(0, pos), + uri.UserInfo.Substring(pos+1) + ); + } + } + } catch (Exception) { + } + + return proxy; } } }