commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ortwin Gl├╝ck <>
Subject [HttpClient] Preferences Architecture Analysis
Date Wed, 18 Sep 2002 15:45:44 GMT
There have been a couple of requests in the past to allow for more fine 
grained configuration of HttpClient. At the moment there are a few 
parameters that control the behaviour of HttpClient such as 
"strict-mode" or "http11". This proposal tries to address this issue 
with a suitable architecture.

Proposoal No 1
Store preferences in Properties objects. Do not use System properties.

   HTTP offers a large number of features. And HttpClient is used by 
groups of users with different (often opposed) interests. So the number 
of configuration parameters is potentially large and will most probably 
grow as HttpClient evolves and gains popularity.

It is therefore unwise to add one pair (get/set) of methods for every 
new config parameter. A more general solution is needed.

The Java API provides the java.util.Properties class which seems to suit 
well enough for this problem.

Proposoal No 2
Do not hard-code default values.

   The "ease of use" requires that reasonable default values be set 
automatically. However it depends on the user's point of view what the 
term "reasonable" actually implies.

"Factory pre-set" default values could be stored in a properties file 
inside the /META-INF/ structure of the httpclient.jar file or 
alternative places.
Proposal No 3
Methods provide a means to locally patch the global preferences.

   For some config parameters it makes sense to set them globally for a 
whole session or even application. For others setting them on a 
per-request basis may make more sense.

Architecture Sketch

  - encapsulates preferences as key/value String pairs

  - singleton that holds the global preferences
  - reads its default values on initialization
  - provides static convenience methods to access individual parameters
    String getValue(String key, Properties localPrefs),
    boolean isEnabled(String key, Properties localPrefs)
    (localPrefs is an optional local patch for the global preferences)
  - provides methods to modify preferences

  - interface that defines the string constants for the keys
  - contains documentation for each key

  - provides setting of per-request preferences:

Parameter Candidates

http.version / [1.0, 1.1] - whether to HTTP/1.1 or HTTP/1.0
proxy.port     - domains that do not require the usage of a
preemtive.authorization   - currently a system property
max.redirect.count        - currently hard-coded
cookie.max.lifetime       - new
keep-alive.timeout        - new
request.timeout           - new
useragent.string          - currently hard-coded in HttpMethodBase
follow.redirects          - currently getters/setters exist
allow.loops               - currently not allowed by default
http11.requires.contentlength - currently hard-coded (lenient)
exception.on.protocol.violation - new

Comments appreciated.


To unsubscribe, e-mail:   <>
For additional commands, e-mail: <>

View raw message