Return-Path: Delivered-To: apmail-jakarta-commons-httpclient-dev-archive@www.apache.org Received: (qmail 19432 invoked from network); 16 Feb 2004 16:18:42 -0000 Received: from daedalus.apache.org (HELO mail.apache.org) (208.185.179.12) by minotaur-2.apache.org with SMTP; 16 Feb 2004 16:18:42 -0000 Received: (qmail 66004 invoked by uid 500); 16 Feb 2004 16:18:30 -0000 Delivered-To: apmail-jakarta-commons-httpclient-dev-archive@jakarta.apache.org Received: (qmail 65966 invoked by uid 500); 16 Feb 2004 16:18:30 -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 65838 invoked from network); 16 Feb 2004 16:18:29 -0000 Received: from unknown (HELO web8202.mail.in.yahoo.com) (203.199.70.115) by daedalus.apache.org with SMTP; 16 Feb 2004 16:18:29 -0000 Message-ID: <20040216161830.4383.qmail@web8202.mail.in.yahoo.com> Received: from [202.88.222.7] by web8202.mail.in.yahoo.com via HTTP; Mon, 16 Feb 2004 16:18:30 GMT Date: Mon, 16 Feb 2004 16:18:30 +0000 (GMT) From: =?iso-8859-1?q?hareesh=20babu?= Subject: RE: Cookie Problem To: Commons HttpClient Project In-Reply-To: <825BF35A92B3F0479CC164ECBBE9376E5F0394@kccxoex06.corp.kpmgconsulting.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit 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 Kalnichevski, Oleg, For this reason, i download the lastest build from cvs of 20040215.zip. Then i am getting this expection. But this code some sort with httpclinet 2.0 rc3 version. java.lang.IllegalArgumentException: Entity enclosing requests cannot be redirected without user intervention [java] at org.apache.commons.httpclient.methods.EntityEnclosingMethod.setFollowRedirects(EntityEnclosingMethod.java:239) [java] at Test1.main(Test1.java:127) [java] Exception in thread "main" Hareesh. --- "Kalnichevski, Oleg" wrote: > Hi Hareesh, > > None of the cookie specs in the stable (HttpClient > 2.0) branch can handle malformed cookies with > unescaped commas. The development branch (HttpClient > 3.0-pre-alpha) contains an improved Netscape cookie > spec capable of handling commas in cookie values. > For more details on the problem refer to the bug > report below: > > http://nagoya.apache.org/bugzilla/show_bug.cgi?id=11240 > > Oleg > > -----Original Message----- > From: hareesh babu [mailto:hareeshyv@yahoo.co.in] > Sent: Monday, February 16, 2004 13:37 > To: Commons HttpClient Project > Cc: ROLWEBER@de.ibm.com > Subject: Re: Cookie Problem > > > Hi Roland Weber, > > Thanks for you immediate reponse. Even if set the > cookie policy by different i am getting the problem. > > Let me explain the problem i am facing, I am sending > a > get request the home page of the xxx website, it is > comming fine, after that i am sending a post with > user > and password, and that is also comming after that if > send a another get request in the internal site > which > requies authorized user, website is checking the > cookie, but the cookie problem, the website is > redirecting the request into home page one agian. > I try do by removing the SEPARATORS.set(','); in > the > HeaderElement, no use. > > Here i placing my sample request program > > ***************************** > > import java.io.IOException; > import java.net.MalformedURLException; > import org.apache.commons.httpclient.Credentials; > import > org.apache.commons.httpclient.UsernamePasswordCredentials; > import org.apache.commons.httpclient.Header; > import org.apache.commons.httpclient.HttpClient; > import org.apache.commons.httpclient.HttpException; > import org.apache.commons.httpclient.HttpMethod; > import org.apache.commons.httpclient.Cookie; > import > org.apache.commons.httpclient.cookie.CookiePolicy; > import > org.apache.commons.httpclient.methods.GetMethod; > import > org.apache.commons.httpclient.methods.PostMethod; > import org.apache.commons.httpclient.NameValuePair; > import org.apache.commons.httpclient.Header; > > > public class Test1 > { > > public static void main(String[] args) throws > Exception > { > > System.setProperty("org.apache.commons.logging.Log", > "org.apache.commons.logging.impl.SimpleLog"); > > System.setProperty("org.apache.commons.logging.simplelog.showdatetime", > "true"); > > System.setProperty("org.apache.commons.logging.simplelog.log.httpclient.wire", > "debug"); > > System.setProperty("org.apache.commons.logging.simplelog.log.org.apache.commons.httpclient", > "debug"); > > > //create a singular HttpClient object > String HOST ="yyyy.xxx.com"; > int PORT = 80; > > HttpClient client = new HttpClient(); > client.getHostConfiguration().setHost(HOST, > PORT, "http"); > client.getState().setCookiePolicy( > CookiePolicy.COMPATIBILITY ); > > > String url = "/online/on_login1.jsp"; > GetMethod getMethod = null; > Header header1 = new Header ("Accept", > "image/gif, image/x-xbitmap, image/jpeg, > image/pjpeg, > application/msword, */*"); > Header header2 = new Header ("Referer", > "http://" + HOST); > Header header3 = new Header > ("Accept-Language", "en-us"); > Header header4 = new Header > ("Content-Type", > "application/x-www-form-urlencoded"); > Header header5 = new Header > ("Accept-Encoding", "gzip, deflate"); > Header header6 = new Header > ("Proxy-Connection", "Keep-Alive"); > Header header7 = new Header ("Pragma", > "no-cache"); > Header header8 = new Header ("Cookie", > "name=Online"); > > getMethod = new GetMethod(url); > getMethod.setFollowRedirects(true); > getMethod.setStrictMode(false); > getMethod.setRequestHeader(header1); > getMethod.setRequestHeader(header2); > getMethod.setRequestHeader(header3); > getMethod.setRequestHeader(header4); > getMethod.setRequestHeader(header5); > getMethod.setRequestHeader(header6); > getMethod.setRequestHeader(header7); > getMethod.setRequestHeader(header8); > > //execute the method > String responseBody = null; > try{ > client.executeMethod(getMethod); > responseBody = > getMethod.getResponseBodyAsString(); > } catch (HttpException he) { > System.err.println("Http error > connecting > to '" + url + "'"); > System.err.println(he.getMessage()); > System.exit(-4); > } catch (IOException ioe){ > System.err.println("Unable to connect to > '" + url + "'"); > System.exit(-3); > } > > Cookie[] logoncookies = > client.getState().getCookies(HOST, PORT, "/", > false); > System.out.println("First Request Cookies"); > if (logoncookies.length == 0) { > System.out.println("None"); > } else { > for (int i = 0; i < logoncookies.length; > i++) { > System.out.println("- " + > logoncookies[i].toString()); > } > } > > //write out the request headers > System.out.println("*** Request ***"); > System.out.println("Request Path: " + > getMethod.getPath()); > System.out.println("Request Query: " + > getMethod.getQueryString()); > Header[] requestHeaders = > getMethod.getRequestHeaders(); > for (int i=0; i System.out.print(requestHeaders[i]); > } > > //write out the response headers > System.out.println("*** Response ***"); > System.out.println("Status Line: " + > getMethod.getStatusLine()); > Header[] responseHeaders = > getMethod.getResponseHeaders(); > for (int i=0; i i++){ > System.out.print(responseHeaders[i]); > } > > //write out the response body > System.out.println("*** Response Body > ***"); > System.out.println(responseBody); > > //clean up the connection resources > getMethod.releaseConnection(); > getMethod.recycle(); > > > > NameValuePair[] formData = new > NameValuePair[3]; > formData[0] = new NameValuePair ("username", > "aaaa"); > === message truncated === ________________________________________________________________________ Yahoo! India Insurance Special: Be informed on the best policies, services, tools and more. Go to: http://in.insurance.yahoo.com/licspecial/index.html --------------------------------------------------------------------- To unsubscribe, e-mail: commons-httpclient-dev-unsubscribe@jakarta.apache.org For additional commands, e-mail: commons-httpclient-dev-help@jakarta.apache.org