commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jeff Dever <jsde...@sympatico.ca>
Subject Re: [HttpClient] HttpURLConnection wrapper problems caused by deficienciesin HttpClient
Date Tue, 03 Sep 2002 10:41:34 GMT
Ortwin Gl├╝ck wrote:

> Jeff Dever wrote:
> > For Problem1 we could store the status line as a string and add a getStatusLine
> > method.  Alternatively, we could create a header for it with the name StatusLine
> > (or perhaps just null) which would preserve the interface.
>
> IMHO we should *not* save non-header information in the header data
> structure. The status line should have its own data structure. If this
> is a complex one, make a separate class.

Its just a string.  Would you prefer a new member and function in HttpMethod:
String getStatusLine();

>
>
> > For Problem2 we could use a Vector in place of a HashMap for the headers so that
> > the order is preserved, but would have abstract away the lookups by the name
> > field (which there are many).  Alternatively, we could mirror the contents in
> > the hashmap in a vector (or array) so that we still have fast and convienent
> > lookups, but still have order preservation of the headers.
>
> Storing headers / footers in a List is just fine. We don't need a
> HashMap since performance is not an issue here. Remember we usually
> don't have 100 Headers but maybe 10. Providing both HashMap and List is
> a code mess and does not add significant benefit.
>

A Map makes more sense than a list because the members are most commonly looked up by
name so its just more logical.  But the order preservation is a problem.  We could
just use a list and iterate over it for lookups, but there would be insertion issues
with repeated entries and such.

As Ryan suggested, a SequencedHashMap is perfect because it is both a Map and a
List.  It would be easy to add as well, because it implements the Map interface.

The only real drawback (and this applies to HashMap as well as SequencedHashMap) is
that they take up more space than a simple List.


--
To unsubscribe, e-mail:   <mailto:commons-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache.org>


Mime
View raw message