Return-Path: Delivered-To: apmail-jakarta-commons-user-archive@www.apache.org Received: (qmail 61039 invoked from network); 3 Aug 2005 18:47:11 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 3 Aug 2005 18:47:11 -0000 Received: (qmail 37670 invoked by uid 500); 3 Aug 2005 18:47:03 -0000 Delivered-To: apmail-jakarta-commons-user-archive@jakarta.apache.org Received: (qmail 37619 invoked by uid 500); 3 Aug 2005 18:47:03 -0000 Mailing-List: contact commons-user-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Help: List-Post: List-Id: "Jakarta Commons Users List" Reply-To: "Jakarta Commons Users List" Delivered-To: mailing list commons-user@jakarta.apache.org Received: (qmail 37606 invoked by uid 99); 3 Aug 2005 18:47:03 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 03 Aug 2005 11:47:03 -0700 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received-SPF: neutral (asf.osuosl.org: local policy) Received: from [195.186.18.61] (HELO mail11.bluewin.ch) (195.186.18.61) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 03 Aug 2005 11:46:53 -0700 Received: from [192.168.0.3] (83.78.14.191) by mail11.bluewin.ch (Bluewin 7.2.063) id 42DF555000252C65 for commons-user@jakarta.apache.org; Wed, 3 Aug 2005 18:47:00 +0000 Subject: Re: httpclient running in a loop From: Oleg Kalnichevski To: Jakarta Commons Users List In-Reply-To: References: Content-Type: text/plain Date: Wed, 03 Aug 2005 20:46:59 +0200 Message-Id: <1123094819.2814.3.camel@localhost.localdomain> Mime-Version: 1.0 X-Mailer: Evolution 2.2.2 (2.2.2-5) Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Zhaohua, (1) Please state the exact version of HttpClient you are using (2) If you are using the latest release (3.0RC3) post the complete context/wire log of the HTTP session and the source code of PostXML.MyCredentialsProvider class Oleg On Wed, 2005-08-03 at 14:10 -0400, Zhaohua Meng wrote: > Gurus, > My following code ends up in the httpclient sending request/getting > response again and again, when Basic Authentication failed. How do I make > it stop after "Authorization: Basic dGVzdGltYW46aW1hbjg=" header is sent > to server and and the server responds with 401 (the second trip)? > Thanks, > Zhaohua > > public static void postWithSupportedAuth() throws IOException, > HttpException, IllegalAccessException, InstantiationException, > ClassNotFoundException, ParserConfigurationException { > String secProviderName = "com.sun.crypto.provider.SunJCE"; > java.security.Provider secProvider = > (java.security.Provider)Class.forName(secProviderName).newInstance(); > Security.addProvider(secProvider); > String strURL = > "http://driman8.cgsh.com/worksite/services/factory.asmx"; > String strXMLFilename = "C:/project/junk/Test/Java > Source/request.xml"; > String requestDoc = > ImanageCreateWorkspaceSOAP.getTestDoc(); > // Prepare HTTP post > PostMethod post = new PostMethod(strURL); > post.setRequestEntity(new StringRequestEntity(requestDoc, > "text/xml; charset=UTF-8","UTF-8")); > post.setRequestHeader("Content-type", "text/xml; charset=UTF-8"); > post.setRequestHeader("SOAPAction", > "\"http://worksite.imanage.com/CreateWorkspace\"" > ); > HttpClient httpclient = new HttpClient(); > post.getParams().setVersion(HttpVersion.HTTP_1_1); > httpclient.getParams().setParameter(CredentialsProvider.PROVIDER, > new PostXML.MyCredentialsProvider()); > post.setDoAuthentication(true); > try { > int result = httpclient.executeMethod(post); > System.out.println("Response status code: " + result); > System.out.println("Response body: "); > } finally { > // Release current connection to the connection pool once you > are done > post.releaseConnection(); > } > } > This message is being sent from a law firm and may contain confidential or privileged information. If you are not the intended recipient, please advise the sender immediately by reply e-mail and delete this message and any attachments without retaining a copy. --------------------------------------------------------------------- To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org For additional commands, e-mail: commons-user-help@jakarta.apache.org