Here's the output of a url header snoop:
n/v: Date:Wed, 28 Jun 2000 18:27:04 GMT
n/v: Server:Apache/1.3.11 (Unix) PHP/4.0b3 ApacheJServ/1.1
n/v: Set-Cookie:JServSessionIdnfl=f15rpktmk1; path=/
n/v: Set-Cookie:user.count=51; expires=Sun, 22-Oct-2000 12:13:44 GMT; domain
=ncsa.edu
n/v: Keep-Alive:timeout=15, max=100
n/v: Connection:Keep-Alive
n/v: Content-Type:text/html
So there are two (in this example) Set-Cookie header (which is valid
according to rfc 2109).
The problem is only the last one is saved when I do response.setHeader().
I could combine both cookies before calling setHeader(), but what is
the token used to separate multiple cookie's? RFC says a ',' but that
won't work because of the ',' in the expires field. Or do you ignore
any ',' in the value field?
Anyone have this cookie parsing code?
mike
On Wed, Jun 28, 2000 at 10:46:37AM -0600, Kevin Mukhar wrote:
> Mike Haberman wrote:
> >
> > for a little more information. I am processing header values of one
> > http header and creating a new header with the same values (writing a
> > proxy). I would like to avoid calling addCookie() since that would involve
> > looking at each header value and then parsing the cookie string, creating a
> > cookie and then calling addCookie(); Also, there might be multiple
> > non-cookie values that need to be added to the header.
>
> Can you clarify more please? The header does not contain multiple
> entries for multiple cookies. All the cookies are contained in a single
> header string containing all the name/value pairs. If you're creating a
> new header with the same values as the old header, then just get the
> value of the request header with the name "Cookie" and add that value to
> the new header using the name "Cookie" (or "Set-Cookie", depending on
> what you are doing). It shouldn't matter that the value might represent
> multiple cookies.
>
> Here's some code I wrote in a servlet to see the value of the headers:
>
> out.println("Header Parameters:");
> Enumeration enum = req.getHeaderNames();
> while (enum.hasMoreElements()) {
> String name = (String) enum.nextElement();
> String value = req.getHeader(name);
> out.println(name + ": " + value);
> }
>
> Using this code, the name is reported as "COOKIE", the value is a
> semicolon separated string of the name value pairs of all the cookies.
> To use this in a new header in a request, I would simply call
> request.addHeader(name, value). If you are really putting it into a
> response, then the name is "Set-Cookie": so, to show it literally:
> response.setHeader("Set-Cookie", "name1=value1; name2=value2;
> name3=value3");
>
> KMukhar
>
> ___________________________________________________________________________
> To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
> of the message "signoff SERVLET-INTEREST".
>
> Archives: http://archives.java.sun.com/archives/servlet-interest.html
> Resources: http://java.sun.com/products/servlet/external-resources.html
> LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html