Kaffe's HttpURLConnection implementation is broken

Nic Ferrier nferrier at tapsellferrier.co.uk
Wed Jun 7 18:06:40 PDT 2000


The current HttpURLConnection does not handle headers properly... or
anything like Sun's implementation.

The Kaffe impl uses a fixed array of response header keys which
indexes an instance array of values for those keys.


This has 2 problems:

1. if a particular key (that is present in the index) is not present
in the response the associated value will be null... this causes 2
problems:
(i) if a key is returned by:
   HttpURLConnection.getHeaderFieldKey(int)
then it's associated value should NEVER be null - with the current
Kaffe implementation it will be.

2. if additional response headers are sent by the server Kaffe will
never detect them.
This is a BIG problem. I have been helping someone on the Sun
Servlet-Interest list who was developing a proxy server using
HttpURLConnection, using Kaffe a proxy server would be impossible this
way.
So would an applet based tool which wanted to persist cookies over
connections.


There is also a third incompatability with the Sun version:

3. with Sun the header index 0 is reserved for the response message
so the header doesn't start till index: 1


I have redeveloped the class, my version is attached. 


How does the new implementation work?
It uses 2 Vector classes, 1 for keys and 1 for values. It needs to be
done like this (rather than with a hash) because of the appaling way
the class is speced.

The header manipulation uses int indexed methods which can only
return String, int or long.


Why can't a simple hash be used?
Therefore a hash cannot be used because if it were headers with
multiple values (such as Cookie) could only ever return the first
value.

The indexed system gets around this but requires the int indexing and
therefore the Vectors.


Have we lost performance?
There is still a quick index system of well known fields but this is
not really necessary and Kaffe maintainers might want to get rid of
it.

The implementation also changes the way the header is parsed to make
it more robust and ensures that the response line is stored at header
line index 0.



Could someone put this into Kaffe please? or fix the problem?


A couple of other (related) things:

- the BasicURLConnection needs to be altered too... I'm happy to do
that if people want me to (please let me know)

- I'm working on an HTTP/1.1 version which allows re-use of
connections by caching persistent connections for a short period of
time... it will use a single thread to manage the system.
Is there any interest in this?
Would people prefer it as an additional option rather than a
replacement of the current version?

- I'd never realised how utterly appaling this class was - is there
anyway Kaffe can lobby Sun to change this class? 
The header manipulation is absolutely awfull - a response header
needs to be treated as a hash of Strings or String[]s. See the Servlet
API for details.



Nic Ferrier
-------------- next part --------------
A non-text attachment was scrubbed...
Name: HttpURLConnection.java
Type: application/octet-stream
Size: 9438 bytes
Desc: not available
Url : http://kaffe.org/pipermail/kaffe/attachments/20000608/043bbf98/attachment-0003.obj 


More information about the kaffe mailing list