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"
<[EMAIL PROTECTED]> 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:[EMAIL PROTECTED]
> Sent: Monday, February 16, 2004 13:37
> To: Commons HttpClient Project
> Cc: [EMAIL PROTECTED]
> 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<requestHeaders.length; 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<responseHeaders.length;
> 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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]