Return-Path: Delivered-To: apmail-jakarta-commons-httpclient-dev-archive@www.apache.org Received: (qmail 1209 invoked from network); 1 Mar 2004 18:15:28 -0000 Received: from daedalus.apache.org (HELO mail.apache.org) (208.185.179.12) by minotaur-2.apache.org with SMTP; 1 Mar 2004 18:15:28 -0000 Received: (qmail 91897 invoked by uid 500); 1 Mar 2004 18:15:18 -0000 Delivered-To: apmail-jakarta-commons-httpclient-dev-archive@jakarta.apache.org Received: (qmail 91874 invoked by uid 500); 1 Mar 2004 18:15:18 -0000 Mailing-List: contact commons-httpclient-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Commons HttpClient Project" Reply-To: "Commons HttpClient Project" Delivered-To: mailing list commons-httpclient-dev@jakarta.apache.org Received: (qmail 91859 invoked from network); 1 Mar 2004 18:15:18 -0000 Received: from unknown (HELO mail1.expedia.com) (65.212.171.140) by daedalus.apache.org with SMTP; 1 Mar 2004 18:15:18 -0000 Received: from exp-vrs-01.SEA.CORP.EXPECN.COM ([172.30.101.25]) by mail1.expedia.com with Microsoft SMTPSVC(5.0.2195.6713); Mon, 1 Mar 2004 10:15:22 -0800 Received: from 172.30.153.46 by exp-vrs-01.SEA.CORP.EXPECN.COM (InterScan E-Mail VirusWall NT); Mon, 01 Mar 2004 10:16:31 -0800 Received: from BEL-MSG-03.SEA.CORP.EXPECN.COM ([172.30.153.44]) by exp-hub-02.SEA.CORP.EXPECN.COM with Microsoft SMTPSVC(5.0.2195.6713); Mon, 1 Mar 2004 10:15:12 -0800 Received: from expedia.com ([172.31.10.152]) by BEL-MSG-03.SEA.CORP.EXPECN.COM with Microsoft SMTPSVC(5.0.2195.6713); Mon, 1 Mar 2004 10:15:11 -0800 Message-ID: <40437DAE.60405@expedia.com> Date: Mon, 01 Mar 2004 13:15:10 -0500 From: Andre John Mas User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.6) Gecko/20040113 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Commons HttpClient Project Subject: Re: Once again 302 :( References: <404311E6.7040700@juntadeandalucia.es> In-Reply-To: <404311E6.7040700@juntadeandalucia.es> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 01 Mar 2004 18:15:11.0980 (UTC) FILETIME=[231F6AC0:01C3FFB9] X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N I am not really in a position to test the code, but could you see whether changing the value of the 'user-agent' header gives: method.setRequestHeader("user-agent", "Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.6) Gecko/20040113"); or method.setRequestHeader("user-agent", "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.2.1) Gecko/20021"); Values taken from: http://nycbug.org/stat/agent_200312.html Also what JDK versions are you using? Andre Thorsten Scherler wrote: > Hello group, > I have a similar problem like Emre. > > ...but this time the problem depends on the plattform I am on. I am a > little bit confused because it is running fine on win but on linux not. > > Site causing the problem: > andaluciajunta.es > > Windows: > I get 302! > > Linux (debian): > org.apache.commons.httpclient.HttpConnection$ConnectionTimeoutException > > My code: > public String getHttp(String address) throws Exception { > // Create an instance of HttpClient. > org.apache.commons.httpclient.HttpClient client = > new org.apache.commons.httpclient.HttpClient(); > String url = null; > String protocol = "http://"; > String protocolS = "https://"; > //System.out.println("address->"+address); > if (address.indexOf(protocol) > -1) { > url = address; > } else if (address.indexOf(protocolS) > -1) { > url = address; > } else { > url = protocol + address; > } > // establish a connection within 5 seconds > client.setConnectionTimeout(5000); // Create a > method instance. > HttpMethod method = new GetMethod(url); > method.setFollowRedirects(true); > // Execute the method. > int statusCode = -1; > int attempt = 0; > // We will retry up to 3 times. > while (statusCode == -1 && attempt < 3) { > attempt += 1; > try { > // execute the method. > statusCode = client.executeMethod(method); > } catch (HttpRecoverableException e) { > System.err.println( > "A recoverable exception occurred, retrying." > + e.getMessage()); > } catch (IOException e) { > System.err.println("Failed to download file."); > e.printStackTrace(); > return "666"; > } > } > // Check that we didn't run out of retries. > if (statusCode == -1) { > System.err.println("Failed to recover from exception."); > return "666"; > } > > //Read the response code > try { > int code = method.getStatusCode(); > //System.err.println(code); > //Release the connection. > method.releaseConnection(); > return String.valueOf(code); > } catch (RuntimeException e1) { > e1.printStackTrace(); > //Release the connection. > method.releaseConnection(); > //this is not a valid HTTP code, it was choosen because of > that ;-) > return "666"; > } > } > > King regards > --------------------------------------------------------------------- To unsubscribe, e-mail: commons-httpclient-dev-unsubscribe@jakarta.apache.org For additional commands, e-mail: commons-httpclient-dev-help@jakarta.apache.org