- From: Edison Aspert <aspertedison@yahoo.com>
- Date: Mon, 18 Dec 2000 15:49:08 -0800 (PST)
- To: www-jigsaw@w3.org
Hi, I am trying to post a form to mail.yahoo.com with a valid username and password. The problem is I am getting an error page that says "An Error occured while setting the cookies". Here is the code HttpManager manager = HttpManager.getManager() ; Request request = manager.createRequest() ; CookieFilter cflt = new CookieFilter(); cflt.initialize(manager); request.setMethod("POST") ; request.setUserAgent("Mozilla/4.0 (compatible; MSIE 4.01; Windows 95)"); request.setContentType(new MimeType("application/"+"x-www-form-urlencoded")); request.setURL(this.url); request.setOutputStream(new StringBufferInputStream(param)); request.setContentLength(param.length()); Reply reply = manager.runRequest(request) ; while(reply.getStatus() == 302) { String redirectURL = reply.getLocation(); Enumeration e = reply.enumerateHeaderDescriptions(); while(e.hasMoreElements()) { System.out.println(((HeaderDescription) e.nextElement()).getName()); } System.out.println("Redirect "+redirectURL); /*StringBuffer buf = new StringBuffer("http://www.cleanoffer.com/"); buf.append(redirectURL); redirectURL = buf.toString();*/ if(!redirectURL.startsWith("http")) redirectURL = WebServlet.convertReltoAbs(this.url, redirectURL); System.out.println("Redirect URL "+redirectURL); request.setUserAgent("Mozilla/4.0 (compatible; MSIE 4.01; Windows 95)"); request = manager.createRequest(); request.setURL(new URL(redirectURL)); /*HeaderValue value = reply.getHeaderValue("set-cookie"); if(value != null) { HttpSetCookieList list1 = (HttpSetCookieList) value.getValue(); request.setSetCookie(list1); }*/ reply = manager.runRequest(request); } InputStream in = reply.getInputStream() ; BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(in)); BufferedWriter bufferedWriter = new BufferedWriter(new FileWriter(new File(htmlPath))); String inputLine; while ((inputLine = bufferedReader.readLine()) != null) { bufferedWriter.write(inputLine+EOL); } bufferedWriter.flush(); Thanks Aspert Edison __________________________________________________ Do You Yahoo!? Yahoo! Shopping - Thousands of Stores. Millions of Products. http://shopping.yahoo.com/
Received on Monday, 18 December 2000 18:49:13 UTC