Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
jenkins
提交
553a3850
J
jenkins
项目概览
xxadev
/
jenkins
与 Fork 源项目一致
从无法访问的项目Fork
通知
3
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
J
jenkins
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
553a3850
编写于
11月 01, 2013
作者:
S
ssogabe
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Use Common HttpClient instead of URLConnection
上级
1c89aed2
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
29 addition
and
14 deletion
+29
-14
core/src/main/java/hudson/ProxyConfiguration.java
core/src/main/java/hudson/ProxyConfiguration.java
+27
-14
core/src/main/resources/hudson/Messages.properties
core/src/main/resources/hudson/Messages.properties
+1
-0
core/src/main/resources/hudson/Messages_ja.properties
core/src/main/resources/hudson/Messages_ja.properties
+1
-0
未找到文件。
core/src/main/java/hudson/ProxyConfiguration.java
浏览文件 @
553a3850
...
...
@@ -30,7 +30,6 @@ import hudson.model.Descriptor;
import
hudson.model.Saveable
;
import
hudson.model.listeners.SaveableListener
;
import
hudson.util.FormValidation
;
import
hudson.util.IOUtils
;
import
hudson.util.Scrambler
;
import
hudson.util.Secret
;
import
hudson.util.XStream2
;
...
...
@@ -39,6 +38,7 @@ import java.io.IOException;
import
java.io.InputStream
;
import
java.io.Serializable
;
import
java.net.Authenticator
;
import
java.net.HttpURLConnection
;
import
java.net.InetSocketAddress
;
import
java.net.PasswordAuthentication
;
import
java.net.Proxy
;
...
...
@@ -48,6 +48,11 @@ import java.util.Collections;
import
java.util.List
;
import
java.util.regex.Pattern
;
import
jenkins.model.Jenkins
;
import
org.apache.commons.httpclient.Credentials
;
import
org.apache.commons.httpclient.HttpClient
;
import
org.apache.commons.httpclient.UsernamePasswordCredentials
;
import
org.apache.commons.httpclient.auth.AuthScope
;
import
org.apache.commons.httpclient.methods.GetMethod
;
import
org.jvnet.robust_http_client.RetryableHttpStream
;
import
org.kohsuke.stapler.DataBoundConstructor
;
import
org.kohsuke.stapler.QueryParameter
;
...
...
@@ -233,14 +238,10 @@ public final class ProxyConfiguration extends AbstractDescribableImpl<ProxyConfi
return
con
;
}
public
static
InputStream
getInputStream
(
URL
url
)
throws
IOException
{
Jenkins
h
=
Jenkins
.
getInstance
();
// this code might run on slaves
final
ProxyConfiguration
p
=
(
h
!=
null
)
?
h
.
proxy
:
null
;
return
getInputStream
(
url
,
p
);
}
public
static
InputStream
getInputStream
(
URL
url
,
final
ProxyConfiguration
p
)
throws
IOException
{
if
(
p
==
null
)
return
new
RetryableHttpStream
(
url
);
...
...
@@ -303,18 +304,30 @@ public final class ProxyConfiguration extends AbstractDescribableImpl<ProxyConfi
return
FormValidation
.
error
(
Messages
.
ProxyConfiguration_TestUrlRequired
());
}
ProxyConfiguration
pc
=
null
;
if
(
Util
.
fixEmptyAndTrim
(
name
)
!=
null
)
{
pc
=
new
ProxyConfiguration
(
name
,
port
,
userName
,
password
,
noProxyHost
);
}
InputStream
is
=
null
;
GetMethod
method
=
null
;
try
{
is
=
ProxyConfiguration
.
getInputStream
(
new
URL
(
testUrl
),
pc
);
method
=
new
GetMethod
(
testUrl
);
method
.
getParams
().
setParameter
(
"http.socket.timeout"
,
new
Integer
(
30
*
1000
));
HttpClient
client
=
new
HttpClient
();
if
(
Util
.
fixEmptyAndTrim
(
name
)
!=
null
)
{
client
.
getHostConfiguration
().
setProxy
(
name
,
port
);
Credentials
credentials
=
new
UsernamePasswordCredentials
(
userName
,
Secret
.
fromString
(
password
).
getPlainText
());
AuthScope
scope
=
new
AuthScope
(
AuthScope
.
ANY_HOST
,
AuthScope
.
ANY_PORT
);
client
.
getState
().
setProxyCredentials
(
scope
,
credentials
);
}
int
code
=
client
.
executeMethod
(
method
);
if
(
code
!=
HttpURLConnection
.
HTTP_OK
)
{
return
FormValidation
.
error
(
Messages
.
ProxyConfiguration_FailedToConnect
(
testUrl
,
code
));
}
}
catch
(
IOException
e
)
{
return
FormValidation
.
error
(
e
,
Messages
.
ProxyConfiguration_FailedToConnectViaProxy
(
testUrl
));
}
finally
{
IOUtils
.
closeQuietly
(
is
);
if
(
method
!=
null
)
{
method
.
releaseConnection
();
}
}
return
FormValidation
.
ok
(
Messages
.
ProxyConfiguration_Success
());
...
...
core/src/main/resources/hudson/Messages.properties
浏览文件 @
553a3850
...
...
@@ -66,4 +66,5 @@ AboutJenkins.Description=See the version and license information.
ProxyConfiguration.TestUrlRequired
=
Test URL is required.
ProxyConfiguration.FailedToConnectViaProxy
=
Failed to connect to {0}.
ProxyConfiguration.FailedToConnect
=
Failed to connect to {0} (code {1}).
ProxyConfiguration.Success
=
Success
\ No newline at end of file
core/src/main/resources/hudson/Messages_ja.properties
浏览文件 @
553a3850
...
...
@@ -66,4 +66,5 @@ AboutJenkins.Description=\u30d0\u30fc\u30b8\u30e7\u30f3\u3068\u30e9\u30a4\u30bb\
ProxyConfiguration.TestUrlRequired
=
\u
30c6
\u
30b9
\u
30c8URL
\u
306f
\u
5fc5
\u9808\u3067\u3059\u3002
ProxyConfiguration.FailedToConnectViaProxy
=
{0}
\u
306b
\u
63a5
\u
7d9a
\u3067\u
304d
\u
307e
\u
305b
\u3093\u3067\u3057\u
305f
\u3002
ProxyConfiguration.FailedToConnect
=
{0}
\u
306b
\u
63a5
\u
7d9a
\u3067\u
304d
\u
307e
\u
305b
\u3093\u3067\u3057\u
305f
\u3002
(
\u
30b3
\u
30fc
\u
30c9 {1}).
ProxyConfiguration.Success
=
\u6210\u
529f
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录