I'm writing application that connects to different web sites (HTTP/HTTPS) and then it tries to enumerate HTTP headers.

To enumerate all headers I'm using this code:

String returnString = new String();
for(int index = 0; ;index++ ){
String headerName = c.getHeaderFieldKey(index);
if ( headerName != null )
returnString += headerName + ": " + c.getHeaderField(index) + "\n";

It works OK on emulators I have, but it doesn't work OK on my Nokia.
Everything works OK if all headers names are unique. It is not necessary the case as for example sites can use mulitple cookies, so I will have a number (>1) of "set-cookie" headers. Above code will return the right number of "set-cookie" headers, but all will be set to the value of the last occurance.

Is it another bug to be added to MIDP 2.0 implementation? Does anyone know a way round this problem.

Any help will be appreciated.