由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Java版 - 如何用Proxy
相关主题
java这个是什么逻辑?模拟LOGIN用哪个LIBRARY好?
Help!! a cookie questionhow to sent progress message back from a servlet to a client?
[转载] Re: 觉得自己很笨weblogic Server中如果写一个HTTP Client的程序
Re: Display, edit, and save Image on HTM问个HttpClient 的问题
java怎么display web page找不到HttpClient Class
soap questions, continues怎么可以练习多线程编程呢?
which http client package is good to use?网页自动填表提交怎么实现比较好?
sevlet questionjava http request能做到打开一次多次发送http request吗
相关话题的讨论汇总
话题: proxy话题: code话题: httpclient话题: didn话题: sample
进入Java版参与讨论
1 (共1页)
k***r
发帖数: 4260
1
哪位大峡知道如何在HttpURLConnection里面使用proxy?
我找到的很多sample code 都是用 system property (见下),
但是都不work。里面随便设成bogus ip:port也能拿到page,
说明没有通过proxy出去。
System.setProperty("https.proxyHost", proxyHost);
System.setProperty("https.proxyPort", new
Integer(proxyPort).toString());
有了解的请知会一声,如果找到类似sample code,这个不work :(
g*****g
发帖数: 34805
2
这个东西我用过,就是这么用没错。你试试看在hosts文件里
把你要去的ip禁掉,再试试看。

【在 k***r 的大作中提到】
: 哪位大峡知道如何在HttpURLConnection里面使用proxy?
: 我找到的很多sample code 都是用 system property (见下),
: 但是都不work。里面随便设成bogus ip:port也能拿到page,
: 说明没有通过proxy出去。
: System.setProperty("https.proxyHost", proxyHost);
: System.setProperty("https.proxyPort", new
: Integer(proxyPort).toString());
: 有了解的请知会一声,如果找到类似sample code,这个不work :(

k***r
发帖数: 4260
3
It falls back to no proxy if proxy server doesn't connect!
But this isn't the behavior I want. Why not leave the logic
to the application. Java tries to be smart where it really
shouldn't :(

【在 g*****g 的大作中提到】
: 这个东西我用过,就是这么用没错。你试试看在hosts文件里
: 把你要去的ip禁掉,再试试看。

m******t
发帖数: 2416
4

How did you make sure that it actually tried the proxy first?
Take a look at httpclient. It has more sophisticated
proxy handling code than the jdk code.

【在 k***r 的大作中提到】
: 哪位大峡知道如何在HttpURLConnection里面使用proxy?
: 我找到的很多sample code 都是用 system property (见下),
: 但是都不work。里面随便设成bogus ip:port也能拿到page,
: 说明没有通过proxy出去。
: System.setProperty("https.proxyHost", proxyHost);
: System.setProperty("https.proxyPort", new
: Integer(proxyPort).toString());
: 有了解的请知会一声,如果找到类似sample code,这个不work :(

k***r
发帖数: 4260
5
i'm not so sure. but from the time it uses to connect,
it seems that it didn't fail then try the proxy.
Yeah, I may just use the httpclient lib. I didn't want
to bother with an additional jar - didn't know jvm handles
proxies like this.

【在 m******t 的大作中提到】
:
: How did you make sure that it actually tried the proxy first?
: Take a look at httpclient. It has more sophisticated
: proxy handling code than the jdk code.

m******t
发帖数: 2416
6

The reason I suspect that it's not even trying the proxy
is that it should definitely blow up if the proxy address
isn't correct, instead of falling back _silently_.

【在 k***r 的大作中提到】
: i'm not so sure. but from the time it uses to connect,
: it seems that it didn't fail then try the proxy.
: Yeah, I may just use the httpclient lib. I didn't want
: to bother with an additional jar - didn't know jvm handles
: proxies like this.

k***r
发帖数: 4260
7
I've seen bugs on sun.com discussing the fallback.

【在 m******t 的大作中提到】
:
: The reason I suspect that it's not even trying the proxy
: is that it should definitely blow up if the proxy address
: isn't correct, instead of falling back _silently_.

1 (共1页)
进入Java版参与讨论
相关主题
java http request能做到打开一次多次发送http request吗java怎么display web page
httpclient poolingsoap questions, continues
java 就不能提供一个象curl这样简单一点的API吗?which http client package is good to use?
java 抓取网页内容sevlet question
java这个是什么逻辑?模拟LOGIN用哪个LIBRARY好?
Help!! a cookie questionhow to sent progress message back from a servlet to a client?
[转载] Re: 觉得自己很笨weblogic Server中如果写一个HTTP Client的程序
Re: Display, edit, and save Image on HTM问个HttpClient 的问题
相关话题的讨论汇总
话题: proxy话题: code话题: httpclient话题: didn话题: sample