OSDN Git Service

na-get,認証プロキシではネットワーク接続できなかった問題の暫定対処(http://ユーザ:パス@example.com:port/ の手動設定のみ対応;IEの設定か...
authorttp <ttp@users.sourceforge.jp>
Sun, 31 Oct 2010 10:54:41 +0000 (19:54 +0900)
committerttp <ttp@users.sourceforge.jp>
Sun, 31 Oct 2010 10:54:41 +0000 (19:54 +0900)
na-get-lib/NaGet/Env.cs

index 260452e..2f799d2 100644 (file)
@@ -173,7 +173,24 @@ namespace NaGet
                                        return null;\r
                                } else {\r
                                        // host:portが設定されているならば、それをもとに設定\r
-                                       return new WebProxy(pref.ProxyAddress);\r
+                                       WebProxy proxy = new WebProxy(pref.ProxyAddress);\r
+                                       \r
+                                       // 認証プロキシの場合、認証情報を付加する\r
+                                       try {\r
+                                               Uri uri = new Uri(pref.ProxyAddress);\r
+                                               if (! string.IsNullOrEmpty(uri.UserInfo)) {\r
+                                                       int pos = uri.UserInfo.IndexOf(':');\r
+                                                       if (pos >= 0) {\r
+                                                               proxy.Credentials = new NetworkCredential(\r
+                                                                       uri.UserInfo.Substring(0, pos),\r
+                                                                       uri.UserInfo.Substring(pos+1)\r
+                                                               );\r
+                                                       }\r
+                                               }\r
+                                       } catch (Exception) {\r
+                                       }\r
+                                       \r
+                                       return proxy;\r
                                }\r
                        }\r
                }\r