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
java.util.Properties:
- encapsulates preferences as key/value String pairs
httpclient.Configuration:
- singleton that holds the global preferences
- reads its default values on initialization
- provides static convenience methods to access individual parameters
Samples:
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
httpclient.ConfigKeys:
- interface that defines the string constants for the keys
- contains documentation for each key
httpclient.HttpMethodBase:
- provides setting of per-request preferences:
setPrefs(Properties)
____________________
Parameter Candidates
http.version / [1.0, 1.1] - whether to HTTP/1.1 or HTTP/1.0
proxy.host
proxy.port
proxy.noproxy.domains - domains that do not require the usage of a
proxy
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.
Odi
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>