hgomez      2005/07/26 05:10:47

  Modified:    src/java/org/apache/xmlrpc CommonsXmlRpcTransport.java
  Log:
  Add Timeout support for underlying HttpClient
  
  Revision  Changes    Path
  1.8       +34 -9     
ws-xmlrpc/src/java/org/apache/xmlrpc/CommonsXmlRpcTransport.java
  
  Index: CommonsXmlRpcTransport.java
  ===================================================================
  RCS file: 
/home/cvs/ws-xmlrpc/src/java/org/apache/xmlrpc/CommonsXmlRpcTransport.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- CommonsXmlRpcTransport.java       28 Apr 2005 09:05:06 -0000      1.7
  +++ CommonsXmlRpcTransport.java       26 Jul 2005 12:10:46 -0000      1.8
  @@ -46,6 +46,13 @@
    */
   public class CommonsXmlRpcTransport implements XmlRpcTransport 
   {
  +    private URL           url;
  +    private HttpClient    client;
  +    private final Header  userAgentHeader = new Header("User-Agent", 
XmlRpc.version);
  +    private boolean       http11          = false; // defaults to HTTP 1.0
  +    private boolean       gzip            = false;
  +    private boolean       rgzip           = false;
  +    private Credentials   creds;
       
       protected PostMethod method;
   
  @@ -53,6 +60,7 @@
       public CommonsXmlRpcTransport(URL url, HttpClient client) 
       {
           this.url = url;
  +        
           if (client == null) 
           {
               HttpClient newClient = new HttpClient();
  @@ -69,14 +77,6 @@
           this(url, null);
       }
       
  -    private URL url;
  -    private HttpClient client;
  -    private final Header userAgentHeader = new Header("User-Agent", 
XmlRpc.version);
  -    private boolean http11 = false; // defaults to HTTP 1.0
  -    private boolean gzip = false;
  -    private boolean rgzip = false;
  -    private Credentials creds;
  -    
       public InputStream sendXmlRpc(byte[] request) throws IOException, 
XmlRpcClientException 
       {
           method = new PostMethod(url.toString());
  @@ -167,6 +167,31 @@
       }
   
       /**
  +     * Sets the socket timeout (<tt>SO_TIMEOUT</tt>) in milliseconds which 
is the 
  +     * timeout for waiting for data. A timeout value of zero is interpreted 
as an 
  +     * infinite timeout.
  +     *
  +     * @param newTimeoutInMilliseconds Timeout in milliseconds
  +     */
  +    public void setTimeout(int timeout)
  +    {
  +        client.setTimeout(timeout);
  +    }
  +    
  +    /**
  +     * Sets the timeout until a connection is etablished. A timeout value of 
  +     * zero means the timeout is not used. The default value is zero.
  +     * 
  +     * @param newTimeoutInMilliseconds Timeout in milliseconds.
  +     * 
  +     * @see HttpConnection#setConnectionTimeout(int)
  +     */
  +    public void setConnectionTimeout(int ctimeout)
  +    {
  +        client.setConnectionTimeout(ctimeout);
  +    }
  +        
  +    /**
        * Sets Authentication for this client, very basic for now user/password
        * 
        * @param user
  
  
  

Reply via email to