473,472 Members | 1,831 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Reading multiple "set-cookie" header attributes

1 New Member
I'm use HttpURLConnection get cookie information from a server. In the response header it uses "Set-Cookie" twice and I am only able to get the 2nd value.

I've done some googling and found that I needed to try looping though the different fields by index instead of trying to get the value by name. I used the following code that claimed to work
Expand|Select|Wrap|Line Numbers
  1. for (int i=1; (headerName = conn.getHeaderFieldKey(i))!=null; i++) {
  2.                  System.out.println(headerName);
  3.                 if (headerName.equals("Set-Cookie")) {                  
  4.                 cookie += conn.getHeaderField(i);   }            
  5.             }
  6.  
This code however also resulted in finding only the last "set-cookie" field. Is there something i must set before trying to loop?
Other examples I've seen look like this or say only that i must access by index instead of name and it will work.
Feb 17 '09 #1
1 5695
chaarmann
785 Recognized Expert Contributor
Why are you starting your loop with "1" instead of "0"? You are skipping the first entry! Maybe that's the reason for your problem.

Also, can you please list in this email what's the output of your "System.out.println(headerName); " statement? Maybe you have an issue with upper/lowercase or misspelling, that's why it's skipping. If so, use equalsIgnoreCase() instead.
Feb 24 '09 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Alan Little | last post by:
Has anyone ever figured out the problem with this? I have sendmail_from set in my php.ini, and I also in this case have a custom From: header, but I still get this message. Here's the relevant...
2
by: alex | last post by:
I need to set a directory with hidden and/or system attribute from my c# code. Similar to what is c:\RECYCLER folder set to in WinXP. So it is not visible to a user with default "Folder Options". ...
2
by: Anders Borum | last post by:
Hello! I was looking at marking objects with a changed state, once properties have been changed. The reason behind this is, that I would like to enlist such objects for processing in a...
0
by: =?Utf-8?B?SkhhbGV5?= | last post by:
Our system is: IIS Server: dual Intel Xeon 2.80 GHz, 4 GB Ram Windows Server 2003 SP2 IIS 6.0 SQL Server: dual Intel Xeon 2.80 GHz, 4 GB Ram (separate server) Windows Server 2003 SP2 SQL...
7
by: Jan | last post by:
Hi: I was so sure this was easy that I left it for the last minute and now I'm stuck. I'm working on the student directory for my kids' school and since it will be printed on 3-hole punch...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.