I'm goning to skip this one (though I'm not against someone else sprucing that up and merging it in). What's actually needed is some code normalization between client, client lite, and server header generation.
Ryan Hoegg <[EMAIL PROTECTED]> writes: > Hi all, > > Not too sure if this is something you guys want to include. It is > within the spec at http://www.xmlrpc.com/spec: > > A User-Agent and Host must be specified. > > Basically, I needed to be able to set this because a service provider > I use requires this field to be used as a part of the "authentication" > process. > > So without further ado... > > -------------------------------------------------------------------------- > diff -u -r1.8 XmlRpcClient.java > --- XmlRpcClient.java 20 Feb 2002 18:06:04 -0000 1.8 > +++ XmlRpcClient.java 8 Mar 2002 02:43:19 -0000 > @@ -70,7 +70,10 @@ > public class XmlRpcClient > implements XmlRpcHandler > { > + private static final String DEFAULT_USER_AGENT = XmlRpc.version; > + protected URL url; > + protected String userAgent; > private String auth; > // pool of worker instances > @@ -131,7 +134,14 @@ > .getBytes())).trim(); > } > } > - > + + /** > + * Set a custom User-Agent header for XML-RPC requests > + */ > + public void setUserAgent(String customUserAgent) > + { > + userAgent = customUserAgent; > + } > /** > * Generate an XML-RPC request and send it to the server. Parse > the result and > @@ -381,6 +391,11 @@ > con.setRequestProperty("Content-Length", > Integer.toString(request.length)); > con.setRequestProperty("Content-Type", "text/xml"); > + if (userAgent == "") // Client has not given us a > custom User-Agent property > + { > + userAgent = DEFAULT_USER_AGENT; > + } > + con.setRequestProperty("User-Agent", userAgent); > if (auth != null) > { > con.setRequestProperty("Authorization", "Basic " > + auth);