Changes from Version 0.1
Here is a (not necessarily complete) list of changes and new features
since Version 0.1:
-
A new HTTPConnection constructor with a protocol parameter
was added; this is for future expansion to handle similar protocols
such as HTTPS and HTTP-NG. A new exception
ProtocolNotSupportedException is thrown by this and a
couple other constructors. URLException is not thrown
anymore by HTTPConnection(URL).
-
New request methods (as defined in HTTP/1.1) added to
HTTPConnection: Trace(), Delete() and
Options(). Furthermore arbitrary request methods can be
sent via the new ExtensionMethod() method.
-
Changed the request method parameter enc_type to a more
general headers parameter to allow the sending of arbitrary
request headers. All request methods can take this parameter.
-
Added setDefaultHeaders and getDefaultHeaders
to handle default headers to be sent with every request.
-
Proxy handling added. Http proxies can be set via the
setProxyServer() and SOCKS via the
setSocksServer() methods. The acl's proxySet,
proxyHost, proxyPort, socksHost,
socksPort and socksVersion are now recognized.
-
HTTPResponse is revamped. The variables are not directly
accessible anymore. Instead use getStatusCode(),
getReasonLine(), getServer(),
getEffectiveURL(), getHeader(),
getHeaderAsDate() and getData(). All previous
variables such as e.g. Public should now be accessed via
the getHeader() or the getHeaderAsDate() method.
-
HTTPResponse now has a method getInputStream()
to get an an input stream from which the data can be read. This is
especially useful if you're doing server-push (previously all the data
was read in one go into the Data field, making server-push
impossible).
-
AuthorizationStruct has been renamed to
AuthorizationInfo and revamped. New static methods have been
added, some of the constructors have disappeared, and internal variables
are now hidden and must be accesses via getXyz() calls.
-
setAuthHandler() has been moved to the
AuthorizationInfo class and now returns the old AuthHandler.
-
Proxy authorization challenges are now recognized and handled.
-
Redirection now conforms to HTTP/1.1 spec; status codes 300,
301, 302, 303 and 305 are handled.
-
Status code 100 is now also handled.
-
Moved coders from HTTPConnection into new Codecs
class. A number of new methods have been added; among them are
quotedPrintableEncode(), quotedPrintableDecode(),
mpFormDataEncode(), mpFormDataDecode(),
URLEncode(), URLDecode(), nv2query()
and query2nv().
-
New exception ParseException thrown by various decoders in
Codecs.
-
Handles Transfer-Encoding chunked automatically; also
correctly determines end of data if Content-Length or multipart
Content-Types are used.
-
Persistent connections are new and are the default. For pipelining
the new method setRawMode() is added which circumvents
redirection and authorization handling.
-
A number of visibility changes have been made (things which shouldn't
have been accessible are now truly hidden).
-
A number of bugs have been fixed too.
Upgrading from Version 0.1
To ease the transition from Version 0.1 you can run the following sed
script over your files. It is doubtful that it will do all the work, but
it should help. I've probably missed some stuff, so let me know what
you had to do that could've been done by the script so I can update it.
Furthermore, if anybody wants to write a Windoze equivalent I'll put it
up here. You can also download it directly.
#!/bin/sh
#
# Tries to upgrade methods from V0.1 to V0.2
#
# Those methods that have changed their signature are marked with the
# comment /* NEEDS WORK */
#
# Usage: upgrade < OldCode.java > NewCode.java
#
sed -e '
s/\.statusCode/\.getStatusCode()/g
s/\.ReasonLine/\.getReasonLine()/g
s/\.Version/\.getVersion()/g
s/\.Server/\.getServer()/g
s/\.EffectiveURL/\.getEffectiveURL()/g
s/\.ContentType/\.getHeader("Content-type")/g
s/\.ContentLength/\.getHeader("Content-length")/g
s/\.ContentEncoding/\.getHeader("Content-encoding")/g
s/\.ContentTransferEncoding/\.getHeader("Content-transfer-encoding")/g
s/\.Date/\.getHeaderAsDate("Date")/g
s/\.Expires/\.getHeaderAsDate("Expires")/g
s/\.LastModified/\.getHeaderAsDate("Last-modified")/g
s/\.Allowed/\.getHeader("Allowed")/g
s/\.Public/\.getHeader("Public")/g
s/\.WWWAuthenticate/\.getHeader("WWW-Authenticate")/g
s/\.unparsed_headers/\.listHeaders() \/* NEEDS WORK *\/ /g
s/\.Data/\.getData()/g
s/HTTPConnection\.base64Encode/Codecs\.base64Encode/g
s/HTTPConnection\.base64Decode/Codecs\.base64Decode/g
s/HTTPConnection\.quotedPrintableEncode/Codecs\.quotedPrintableEncode/g
s/HTTPConnection\.quotedPrintableDecode/Codecs\.quotedPrintableDecode/g
s/AuthorizationStruct/AuthorizationInfo/g
s/HTTPConnection\.setAuthHandler/AuthorizationInfo\.setAuthHandler \/* NEEDS WORK *\/ /g
'
# the end
Ronald Tschalär / 23 March 1997 /
ronald@innovation.ch.