You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by ma...@apache.org on 2002/04/12 23:09:20 UTC

cvs commit: jakarta-commons/httpclient/src/java/org/apache/commons/httpclient HttpConnection.java

marcsaeg    02/04/12 14:09:20

  Modified:    httpclient/src/java/org/apache/commons/httpclient
                        HttpConnection.java
  Log:
  The setSoTimeout() method can now be called before the socket is opened.
  In this case, Socket.setSoTimeout() will be called when the new socket
  is created in open().
  
  Revision  Changes    Path
  1.9       +14 -7     jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/HttpConnection.java
  
  Index: HttpConnection.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/HttpConnection.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- HttpConnection.java	22 Feb 2002 19:14:43 -0000	1.8
  +++ HttpConnection.java	12 Apr 2002 21:09:20 -0000	1.9
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/HttpConnection.java,v 1.8 2002/02/22 19:14:43 marcsaeg Exp $
  - * $Revision: 1.8 $
  - * $Date: 2002/02/22 19:14:43 $
  + * $Header: /home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/HttpConnection.java,v 1.9 2002/04/12 21:09:20 marcsaeg Exp $
  + * $Revision: 1.9 $
  + * $Date: 2002/04/12 21:09:20 $
    * ====================================================================
    *
    * The Apache Software License, Version 1.1
  @@ -79,7 +79,7 @@
    * </p>
    * @author Rod Waldhoff
    * @author Sean C. Sullivan
  - * @version $Revision: 1.8 $ $Date: 2002/02/22 19:14:43 $
  + * @version $Revision: 1.9 $ $Date: 2002/04/12 21:09:20 $
    */
   public class HttpConnection {
       // ----------------------------------------------------------- Constructors
  @@ -254,15 +254,19 @@
   
       /**
        * Set my {@link Socket}'s timeout, via
  -     * {@link Socket#setSoTimeout}.
  +     * {@link Socket#setSoTimeout}.  If the connection is already open,
  +     * the SO_TIMEOUT is changed.  If no connection is open, then subsequent
  +     * connections will use the timeout value.
        * @throws SocketException - if there is an error in the underlying
        * protocol, such as a TCP error.
        * @throws IllegalStateException if I am not connected
        */
       public void setSoTimeout(int timeout) throws SocketException, IllegalStateException {
           log.debug("HttpConnection.setSoTimeout()");
  -        assertOpen();
  -        _socket.setSoTimeout(timeout);
  +        _so_timeout = timeout;
  +        if(_socket != null){
  +            _socket.setSoTimeout(timeout);
  +        }
       }
   
       /**
  @@ -282,6 +286,7 @@
                       _socket = new Socket(host,port);
                   }
               }
  +            _socket.setSoTimeout(_so_timeout);
               _input = _socket.getInputStream();
               _output = _socket.getOutputStream();
               _open = true;
  @@ -586,5 +591,7 @@
       private boolean _ssl = false;
       /** <tt>"\r\n"</tt>, as bytes. */
       private static final byte[] CRLF = "\r\n".getBytes();
  +    /** SO_TIMEOUT value */
  +    private int _so_timeout = 0;
   
   }
  
  
  

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>