You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hc.apache.org by "Esquivel Sanchez, Arturo" <ae...@banamex.com> on 2004/07/15 02:41:30 UTC

Problems using HttpClient 2.0 when connecting to an especific sit e

Hi, 
I'm using HttpClient 2.o to connect to the following site:
 
<http://www.aeromexico.com:9090/ClubPremier/Saldo/0,11100,11000.html?lang=0&
location=0&ncuenta=0&reqForm=1&num_socio=767871601&continuar.x=51&continuar.
y=12>
 the hyperlink works fine when using a browser. But when using my code i'm
always getting a 503 HTTP status code, instead of the 200 for ok. and
consecuently i´m not getting any HTML. 
the code is something like this (i'm using a proxy): 
url =
"http://www.aeromexico.com:9090/ClubPremier/Saldo/0,11100,11000.html?lang=0&
location=0&ncuenta=0&reqForm=1&num_socio=447739905&continuar.x=51&continuar.
y=12";
HttpClient client = new HttpClient(); 
client.getState().setProxyCredentials(null, null, new
UsernamePasswordCredentials(System.getProperty("http.proxyUserName"),
System.getProperty("http.proxyPassword"))); 
client.getHostConfiguration().setProxy(System.getProperty("http.proxyHost"),
Integer.parseInt(System.getProperty("http.proxyPort","80"))); 
GetMethod method1 = new GetMethod(url); 
try{ 
	statusCode = client.executeMethod(method1); 
	System.out.println("Return Code=> " + statusCode); //here i get
always 503 
}catch (HttpRecoverableException e) { 
	System.out.println("An recoverable exception occurred,retrying. " +
e.getMessage());
	 e.printStackTrace(); 
}finally{ 
	System.out.println("Releasing Connection method 1....." ); 
	method1.releaseConnection();
 } 

thanks in advance 

Saludos, Arturo 




Re: Problems using HttpClient 2.0 when connecting to an especific sit e

Posted by Oleg Kalnichevski <ol...@apache.org>.
Arturo,

When hit directly the site works just fine

[DEBUG] HttpConnection - -HttpConnection.setSoTimeout(0)
[DEBUG] HttpMethodBase - -Execute loop try 1
[DEBUG] header - ->> "GET
/ClubPremier/Saldo/0,11100,11000.html?lang=0&location=0&ncuenta=0&reqForm=1&num_socio=767871601&continuar.x=51&continuar.y=12 HTTP/1.1[\r][\n]"
[DEBUG] HttpMethodBase - -Adding Host request header
[DEBUG] header - ->> "User-Agent: Jakarta
Commons-HttpClient/2.0final[\r][\n]"
[DEBUG] header - ->> "Host: www.aeromexico.com:9090[\r][\n]"
[DEBUG] header - ->> "[\r][\n]"
[DEBUG] header - -<< "HTTP/1.1 200 OK[\r][\n]"
[DEBUG] header - -<< "Server: Resin/2.1.6[\r][\n]"
[DEBUG] header - -<< "Cache-Control: private[\r][\n]"
[DEBUG] header - -<< "Set-Cookie: JSESSIONID=axQFtSY14UKg;
Path=/[\r][\n]"
[DEBUG] header - -<< "Transfer-Encoding: chunked[\r][\n]"
[DEBUG] header - -<< "Date: Thu, 15 Jul 2004 19:44:28 GMT[\r][\n]"
[DEBUG] HttpMethodBase - -Cookie accepted: "$Version=0;
JSESSIONID=axQFtSY14UKg; $Path=/"
[DEBUG] HttpConnection - -HttpConnection.getSoTimeout()
[DEBUG] HttpMethodBase - -Resorting to protocol version default close
connection policy
[DEBUG] HttpMethodBase - -Should NOT close connection, using HTTP/1.1.
HTTP/1.1 200 OK

This has apparently something to do with the proxy you are using. My
guess is that it does not support HTTP/1.1. Try using HTTP/1.0 instead

HTH

Oleg



On Thu, 2004-07-15 at 02:41, Esquivel Sanchez, Arturo wrote:
> Hi, 
> I'm using HttpClient 2.o to connect to the following site:
>  
> <http://www.aeromexico.com:9090/ClubPremier/Saldo/0,11100,11000.html?lang=0&
> location=0&ncuenta=0&reqForm=1&num_socio=767871601&continuar.x=51&continuar.
> y=12>
>  the hyperlink works fine when using a browser. But when using my code i'm
> always getting a 503 HTTP status code, instead of the 200 for ok. and
> consecuently i´m not getting any HTML. 
> the code is something like this (i'm using a proxy): 
> url =
> "http://www.aeromexico.com:9090/ClubPremier/Saldo/0,11100,11000.html?lang=0&
> location=0&ncuenta=0&reqForm=1&num_socio=447739905&continuar.x=51&continuar.
> y=12";
> HttpClient client = new HttpClient(); 
> client.getState().setProxyCredentials(null, null, new
> UsernamePasswordCredentials(System.getProperty("http.proxyUserName"),
> System.getProperty("http.proxyPassword"))); 
> client.getHostConfiguration().setProxy(System.getProperty("http.proxyHost"),
> Integer.parseInt(System.getProperty("http.proxyPort","80"))); 
> GetMethod method1 = new GetMethod(url); 
> try{ 
> 	statusCode = client.executeMethod(method1); 
> 	System.out.println("Return Code=> " + statusCode); //here i get
> always 503 
> }catch (HttpRecoverableException e) { 
> 	System.out.println("An recoverable exception occurred,retrying. " +
> e.getMessage());
> 	 e.printStackTrace(); 
> }finally{ 
> 	System.out.println("Releasing Connection method 1....." ); 
> 	method1.releaseConnection();
>  } 
> 
> thanks in advance 
> 
> Saludos, Arturo 
> 
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-httpclient-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-httpclient-dev-help@jakarta.apache.org