[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[iaik-ssl] Problem reading HTTP headers via getHeaderField(int) and getHeaderFieldKey(int)

--- Received from FPU.CLARKC1 0115-9810103                18-12-01 20:37

  -> IN=iaik-ssl@iaik.at


I'm using IAIK JCE 2.6 and iSaSiLk 3.01. I'd like to read all the HTTP
headers returned by my Web server (MS IIS 4.0) when requesting a URL via
HTTPS from my Java application. I don't know the header names in advance
of reading them, so the APIs that are exactly right for this job are

  java.net.URLConnection.getHeaderField(int n) and
  java.net.URLConnection.getHeaderFieldKey(int n)

getHeaderField(n) should return a String containing the value of the
n'th header field in the Web server's HTTP response, and
getHeaderFieldKey(n) should return a String containing the corresponding
header field's key (name). My plan was that by incrementing n in a loop,
starting at 0, I could retrieve each HTTP response header in turn. When
the APIs returned null values, I'd stop, having got them all.

Using the standard JDK 1.2.2 classes with a java.net.URLConnection
object and an HTTP URL, this technique indeed works just fine. The only
slight oddity is that when n=0, getHeaderFieldKey(0) returns null, and
getHeaderField(0) returns the HTTP status line (eg, "HTTP/1.1 200 OK") -
but that's OK, and it's what you might expect if the HTTP status line is
just being treated as the zeroth header (as it's the first line sent
back by the server).

However, when I use the IAIK classes to create an HTTPS URL, and get an
iaik.protocol.https.HttpsURLConnection object from it, these API calls
always return null. HttpsURLConnection inherits both these APIs from
overrides in org.w3c.www.protocol.http.HttpURLConnection, so is this
problem really a problem with the w3c class?

My Java application is a standalone program, by the way, and not an
applet. Everything else in it seems to work fine with HTTPS URLs, apart
from getting the headers. As there doesn't seem to be any other way of
getting the headers (unless you know all their names in advance, which I
don't) I'm a bit stuck. So I'd be very grateful for any ideas or

Chris Clark

This e-mail may contain confidential information and/or copyright
material. This e-mail is intended for the use of the addressee
only. Any unauthorised use may be unlawful.

If you receive this e-mail by mistake please advise the sender
immediately by using the reply facility in your e-mail software.

Friends Provident Marketing Group consists of the following

Friends Provident Life and Pensions Limited.
Registered number 4096141.
Friends' Provident Unit Trust Managers Limited.
Registered number 970641
FP Life Assurance Limited.
Registered number 782698
Friends Provident Pensions Limited.
Registered number 475201
Friends Ivory & Sime Managed Pensions Funds Limited.
Registered number 1020044
Registered and Head Office of each of the above companies is at Pixham End,
Dorking, Surrey RH4 1QA.
Registered in England. Incorporated companies limited by shares.
Ivory & Sime Trustlink Limited. Registered number 151198
Registered and Head Office: One Charlotte Square, Edinburgh EH2
4DZ.  Registered in Scotland. Incorporated company limited by

Companies within this Group transact life assurance, pension,
permanent health, unit trust and investment trust business

All are regulated by the Financial Services Authority.
Mailinglist-archive at http://jcewww.iaik.at/mailarchive/iaik-ssl/sslthreads.html

To unsubscribe send an email to listserv@iaik.at with the folowing content: UNSUBSCRIBE iaik-ssl