- From: John Philip Anderson <jpanderson_215@hotmail.com>
- Date: Fri, 08 Dec 2000 20:46:57 -0000
- To: www-jigsaw@w3.org
Dear Gentlemen,
I find Jigsaw and Winie to be invaluable, thank you very much for sharing
this work. I have studied all the posted resources, yet I still do not
understand how to handle Client-Side cookies.
Posted below is sourcecode ("CookieTest.java") and its output, that uses
Client-Side Jigsaw components to send an HTTP.GET Request to
www.netscape.com. As indicated by output enumeration of the Reply Header
Descriptions, the Reply contains a "set-cookie" header and applying the
methods: getHeaderValue("set-cookie") and value.getValue() to the Reply does
indeed returns an unparsed "set-cookie" value for the netscape.com Domain
(as expected).
However, the CookieFilter and HttpManager do not appear to process this
information because a "cookie" header does is enumerated in the Request2
headers (to the same URL: www.netscape.com). Furthermore, applying the
method: getSetCookie() to the Reply returns an empty SetCookieList.
So, I would be extremely grateful if you could tell me what I am doing
wrong.
Specifically:
1.) Why do CookieFilter and HttpManager appear not to process the
"set-cookie" header in the Reply by not yielding a "cookie" header in
Request2?
2.) Why does Reply.getSetCookie() generate an empty SetCookieList while
getHeaderValue("set-cookie") and value.getValue() appear to find a cookie.
3.) And finally, is there any technical reason why CookieFilter has not
been incorporated into Winie? (I can usually answer my own Client-Side
questions by studying Winie sourcecode.)
Truly yours,
John Philip Anderson
jpanderson_215@hotmail.com
~~~~~~~~~~~~~~~~~~~~~~~~
CookieTest.java OUTPUT::
Reply Header Descriptions:
date
transfer-encoding
set-cookie
content-type
server
Cooks Array Length:
0
SET-COOKIE header value:
uidc=24.19.89.21:0976303991:634295;domain=.netscape.com;path=/;expires=31-Dec-2010
23:59:59 GMT
Request2 Header Descriptions:
date
accept
host
user-agent
~~~~~~~~~~~~~~~~~~~~~~~~
CookieTest.java SOURCECODE::
// CookieTest.java
import java.io.*;
import java.util.*;
import java.net.*;
import org.w3c.util.*;
import org.w3c.www.http.*;
import org.w3c.www.protocol.http.*;
import org.w3c.www.protocol.http.cookies.*;
public class CookieTest{
public static void main(String[] args) {
try {
PrintStream out1 = new PrintStream(
new BufferedOutputStream(
new FileOutputStream("log.txt")), true);
System.setOut(out1);
HttpManager manager = HttpManager.getManager(); CookieFilter cfilter
= new CookieFilter();
cfilter.initialize(manager);
Request request1 = manager.createRequest();
request1.setMethod("GET");
String host = "http://www.netscape.com";
request.setURL(new URL(host));
Reply reply = manager.runRequest(request1);
System.out.println("Reply Header Descriptions:");
Enumeration e = reply.enumerateHeaderDescriptions();
while(e.hasMoreElements()){
System.out.println(((HeaderDescription) e.nextElement()).getName());
}
System.out.println();
System.out.println("Cooks Array Length:");
HttpSetCookieList list = reply.getSetCookie();
if (list != null){
HttpSetCookie[] cooks = list.getSetCookies();
System.out.println(cooks.length);
System.out.println();
}
HeaderValue value = reply.getHeaderValue("set-cookie");
HttpSetCookieList list1 = (HttpSetCookieList) value.getValue();
System.out.println("SET-COOKIE header value:");
System.out.println(list1.toString());
System.out.println();
Request request2 = manager.createRequest();
request2.setURL(new URL(host));
manager.runRequest(request2);
System.out.println("Request2 Header Descriptions:");
e = request2.enumerateHeaderDescriptions();
while(e.hasMoreElements()){
System.out.println(((HeaderDescription) e.nextElement()).getName());
}
out1.close();
} catch(PropRequestFilterException prfexcpt) {
System.out.println("PropRequestFilterException : " + prfexcpt);
} catch(HttpException excpt) {
System.out.println("HttpException : " + excpt);
} catch(IOException e) {
System.out.println("IO Exception:" + e);
}
System.exit(0);
}
}
_____________________________________________________________________________________
Get more from the Web. FREE MSN Explorer download : http://explorer.msn.com
Received on Friday, 8 December 2000 15:47:29 UTC