hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Oleg Kalnichevski <ol...@apache.org>
Subject Re: Problems to use HTTP proxy settings
Date Tue, 02 Jun 2009 19:53:30 GMT
Meinhardt Baer wrote:
> Log ie as follows:
> DEBUG [org.apache.commons.httpclient.HttpClient] Java version: 1.6.0_03
> DEBUG [org.apache.commons.httpclient.HttpClient] Java vendor: Sun Microsystems Inc.
> DEBUG [org.apache.commons.httpclient.HttpClient] Java class path: ...\servlet\servlet-api\2.3\servlet-api-2.3.jar;C:\Users\Admin\.m2\repository\org\springframework\spring\2.5.4\spring-2.5.4.jar
> DEBUG [org.apache.commons.httpclient.HttpClient] Operating system name: Windows Vista
> DEBUG [org.apache.commons.httpclient.HttpClient] Operating system architecture: x86
> DEBUG [org.apache.commons.httpclient.HttpClient] Operating system version: 6.0
> DEBUG [org.apache.commons.httpclient.HttpClient] SUN 1.6: SUN (DSA key/parameter generation;
DSA signing; SHA-1, MD5 digests; SecureRandom; X.509 certificates; JKS keystore; PKIX CertPathValidator;
PKIX CertPathBuilder; LDAP, Collection CertStores, JavaPolicy Policy; JavaLoginConfig Configuration)
> DEBUG [org.apache.commons.httpclient.HttpClient] SunRsaSign 1.5: Sun RSA signature provider
> DEBUG [org.apache.commons.httpclient.HttpClient] SunJSSE 1.6: Sun JSSE provider(PKCS12,
SunX509 key/trust factories, SSLv3, TLSv1)
> DEBUG [org.apache.commons.httpclient.HttpClient] SunJCE 1.6: SunJCE Provider (implements
RSA, DES, Triple DES, AES, Blowfish, ARCFOUR, RC2, PBE, Diffie-Hellman, HMAC)
> DEBUG [org.apache.commons.httpclient.HttpClient] SunJGSS 1.0: Sun (Kerberos v5, SPNEGO)
> DEBUG [org.apache.commons.httpclient.HttpClient] SunSASL 1.5: Sun SASL provider(implements
client mechanisms for: DIGEST-MD5, GSSAPI, EXTERNAL, PLAIN, CRAM-MD5; server mechanisms for:
DIGEST-MD5, GSSAPI, CRAM-MD5)
> DEBUG [org.apache.commons.httpclient.HttpClient] XMLDSig 1.0: XMLDSig (DOM XMLSignatureFactory;
DOM KeyInfoFactory)
> DEBUG [org.apache.commons.httpclient.HttpClient] SunPCSC 1.6: Sun PC/SC provider
> DEBUG [org.apache.commons.httpclient.HttpClient] SunMSCAPI 1.6: Sun's Microsoft Crypto
API provider
> DEBUG [org.apache.commons.httpclient.params.DefaultHttpParams] Set parameter http.useragent
= Jakarta Commons-HttpClient/3.1
> DEBUG [org.apache.commons.httpclient.params.DefaultHttpParams] Set parameter http.protocol.version
= HTTP/1.1
> DEBUG [org.apache.commons.httpclient.params.DefaultHttpParams] Set parameter http.connection-manager.class
= class org.apache.commons.httpclient.SimpleHttpConnectionManager
> DEBUG [org.apache.commons.httpclient.params.DefaultHttpParams] Set parameter http.protocol.cookie-policy
= default
> DEBUG [org.apache.commons.httpclient.params.DefaultHttpParams] Set parameter http.protocol.element-charset
= US-ASCII
> DEBUG [org.apache.commons.httpclient.params.DefaultHttpParams] Set parameter http.protocol.content-charset
= ISO-8859-1
> DEBUG [org.apache.commons.httpclient.params.DefaultHttpParams] Set parameter http.method.retry-handler
= org.apache.commons.httpclient.DefaultHttpMethodRetryHandler@1f94884
> DEBUG [org.apache.commons.httpclient.params.DefaultHttpParams] Set parameter http.dateparser.patterns
= [EEE, dd MMM yyyy HH:mm:ss zzz, EEEE, dd-MMM-yy HH:mm:ss zzz, EEE MMM d HH:mm:ss yyyy, EEE,
dd-MMM-yyyy HH:mm:ss z, EEE, dd-MMM-yyyy HH-mm-ss z, EEE, dd MMM yy HH:mm:ss z, EEE dd-MMM-yyyy
HH:mm:ss z, EEE dd MMM yyyy HH:mm:ss z, EEE dd-MMM-yyyy HH-mm-ss z, EEE dd-MMM-yy HH:mm:ss
z, EEE dd MMM yy HH:mm:ss z, EEE,dd-MMM-yy HH:mm:ss z, EEE,dd-MMM-yyyy HH:mm:ss z, EEE, dd-MM-yyyy
HH:mm:ss z]
> DEBUG [org.apache.commons.httpclient.params.DefaultHttpParams] Set parameter http.method.retry-handler
= org.apache.commons.httpclient.DefaultHttpMethodRetryHandler@167c5e3
> DEBUG [org.apache.commons.httpclient.HttpConnection] Open connection to syswebs.info:80
> DEBUG [httpclient.wire.header] >> "GET http://www.catserver.com/cat1/cat2/cat3.xml
HTTP/1.1[\r][\n]"
> DEBUG [org.apache.commons.httpclient.HttpMethodBase] Adding Host request header
> DEBUG [httpclient.wire.header] >> "User-Agent: Jakarta Commons-HttpClient/3.1[\r][\n]"
> DEBUG [httpclient.wire.header] >> "Host: www.catserver.com[\r][\n]"
> DEBUG [httpclient.wire.header] >> "Proxy-Connection: Keep-Alive[\r][\n]"
> DEBUG [httpclient.wire.header] >> "[\r][\n]"
> DEBUG [httpclient.wire.header] << "HTTP/1.1 404 Not Found[\r][\n]"
> DEBUG [httpclient.wire.header] << "HTTP/1.1 404 Not Found[\r][\n]"
> DEBUG [httpclient.wire.header] << "Date: Tue, 02 Jun 2009 19:32:12 GMT[\r][\n]"
> DEBUG [httpclient.wire.header] << "Server: Apache/2.2.3 (CentOS)[\r][\n]"
> DEBUG [httpclient.wire.header] << "Content-Length: 236[\r][\n]"
> DEBUG [httpclient.wire.header] << "Connection: close[\r][\n]"
> DEBUG [httpclient.wire.header] << "Content-Type: text/html; charset=iso-8859-1[\r][\n]"
> DEBUG [httpclient.wire.header] << "[\r][\n]"

This does not look like a response from a proxy. Apparently HttpClient 
has not been configured correctly.


> DEBUG [org.apache.commons.httpclient.HttpMethodBase] Buffering response body
> DEBUG [httpclient.wire.content] << "<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML
2.0//EN">[\n]"
> DEBUG [httpclient.wire.content] << "<html><head>[\n]"
> DEBUG [httpclient.wire.content] << "<title>404 Not Found</title>[\n]"
> DEBUG [httpclient.wire.content] << "</head><body>[\n]"
> DEBUG [httpclient.wire.content] << "<h1>Not Found</h1>[\n]"
> DEBUG [httpclient.wire.content] << "<p>The requested URL /cat1/cat2/cat3.xml
was not found on this server.</p>[\n]"
> DEBUG [httpclient.wire.content] << "</body></html>[\n]"Methods failed:
HTTP/1.1 404 Not FoundDEBUG [org.apache.commons.httpclient.HttpMethodBase] Should close connection
in response to directive: close
> DEBUG [org.apache.commons.httpclient.HttpConnection] Releasing connection back to connection
manager.
> With aim to preserver some security I removed almost all the classpath entries and also
- I change my URL to catserver.com and resrouce to cat1/cat2/cat3.xml. I am using Spring configuration,
so - I keep proxy configuration in the applicationContext.xml, where my proxy settings are
(now - they are the real data, no changes here):
> <entrykey="http.proxyHost"value="syswebs.info"/><entrykey="http.proxyPort"value="80"/><entrykey="http.agent"value="Java_1.6.0"/>
> So - the first thing I am trying to understand is - whether I am using the right data
- e.g. is it OK to use public proxy server for my tests and whether is it OK to ask on port
80. I have tried to use port 8080 - there is the same HTTP404 error and I also tried to use
port 3128 - but then the error was connection refused. So - is there any suggestion about
some public proxy server for such tests, maybe the public proxy server are for viewing webpages
only? Besides - now I am trying to install Squid on my computer and to check - maybe I have
choose the bad proxy for my tests. How do you make tests?
> 

Set up Squid and test against it.

Oleg

> Thanks, Meinhardt
> 
> 
> 
> ________________________________
> From: Oleg Kalnichevski <olegk@apache.org>
> To: HttpClient User Discussion <httpclient-users@hc.apache.org>
> Sent: Tuesday, June 2, 2009 9:54:20 PM
> Subject: Re: Problems to use HTTP proxy settings
> 
> Meinhardt Baer wrote:
>> Hi!
>>
>> I have pretty simple code to download XML file using Apache HTTP client:
>>
>> HttpClient client =  if(configurationSettings!= null) {client.getHostConfiguration().setProxy(
>> Integer.parseInt(configurationSettings.get("http.proxyHost"), configurationSettings.get("http.proxyPort")));}
>>   GetMethod method = method.getParams().setParameter(HttpMethodParams.
>> System.
>> }newGetMethod(url);RETRY_HANDLER, newDefaultHttpMethodRetryHandler(3,false));try{intstatusCode
= client.executeMethod(method);if(statusCode != HttpStatus.SC_OK) {err.println("Methods failed:
"+method.getStatusLine()); ByteArrayInputStream input = } e.printStackTrace();
>> } method.releaseConnection();
>> }byte[] responseBody = method.getResponseBody();newByteArrayInputStream(responseBody);returninput;catch(Exception
e) {finally{returnnull;}  if I am using the configurationSettings as null (actually - it was
class variable, but I added it to the method parameters because I wanted the code to be consistent,
I am not sure that synatx for this parameter is correct), then proxy settings are not used
and the response is what I want, but if configurationSettings is not null - i.e. I am using
proxy server, then there is HTTP 404 error, I tried to save the result stream in file the
the resuls was a bit different for different proxy servers - but all are like the following:
>>   <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
>> <html><head>
>> <title>404 Not Found</title>
>> </head><body>
>> <h1>Not Found</h1>
>> <p>The requested URL /cat1/cat2/cat3.xml was not found on this server.</p>
>> <p>Additionally, a 404 Not Found
>> error was encountered while trying to use an ErrorDocument to handle the request.</p>
>> <hr>
>> <address>Apache/2 Server at www.catserver.com Port 80</address>
>> </body></html>
>>   I changed the actual URL and server name. I am not sure wether it is security problem,
because - when I am trying to use this cat-URL from the editbox, that is usually provided
in proxy servers webpage, then the response is what I intended. Well - maybe public prxy servers
are not suitable to test such programs? If they are not suitable, then - could you provide
some names of proxy servers that are suitable for such tests.
>>   Thanks in advance for any usefull hint!
>>   Meinhardt
>>   publicjava.io.InputStream download(String url, Map configurationSettings){newHttpClient();
>>
> 
> Please post wire / context log of the session
> 
> http://hc.apache.org/httpclient-3.x/logging.html
> 
> Oleg
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: mailto:httpclient-users-unsubscribe@hc.apache.org
> For additional commands, e-mail: mailto:httpclient-users-help@hc.apache.org
> 
> 
>       


---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org


Mime
View raw message