commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject cvs commit: jakarta-commons/httpclient/src/java/org/apache/commons/httpclient HttpConnection.java
Date Sun, 14 Jul 2002 05:16:07 GMT
dion        2002/07/13 22:16:06

  Modified:    httpclient/src/java/org/apache/commons/httpclient
                        HttpConnection.java
  Log:
  Fix comments and imports
  
  Revision  Changes    Path
  1.10      +103 -48   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.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- HttpConnection.java	12 Apr 2002 21:09:20 -0000	1.9
  +++ HttpConnection.java	14 Jul 2002 05:16:06 -0000	1.10
  @@ -62,15 +62,17 @@
   
   package org.apache.commons.httpclient;
   
  -import java.net.Socket;
  -import java.net.SocketException;
   import java.io.InputStream;
  -import java.io.OutputStream;
   import java.io.IOException;
  -import javax.net.ssl.SSLSocket;
  -import javax.net.ssl.SSLSocketFactory;
  -import org.apache.commons.httpclient.log.*;
  +import java.io.OutputStream;
   import java.lang.reflect.Method;
  +import java.net.Socket;
  +import java.net.SocketException;
  +import javax.net.ssl.SSLSocketFactory;
  +
  +import org.apache.commons.httpclient.log.Log;
  +import org.apache.commons.httpclient.log.LogSource;
  +
   
   /**
    * <p>
  @@ -86,43 +88,48 @@
   
       /**
        * Constructor.
  +     *
        * @param host the host I should connect to
        * @param port the port I should connect to
        */
       public HttpConnection(String host, int port) {
  -        this(null,-1,host,port,false);
  +        this(null, -1, host, port, false);
       }
   
       /**
        * Constructor.
  +     *
        * @param host the host I should connect to
        * @param port the port I should connect to
        * @param secure when <tt>true</tt>, connect via HTTPS (SSL)
        */
       public HttpConnection(String host, int port, boolean secure) {
  -        this(null,-1,host,port,secure);
  +        this(null, -1, host, port, secure);
       }
   
       /**
        * Constructor.
  +     *
        * @param proxyHost the host I should proxy via
        * @param proxyPort the port I should proxy via
        * @param host the host I should connect to
        * @param port the port I should connect to
        */
       public HttpConnection(String proxyHost, int proxyPort, String host, int port) {
  -        this(proxyHost,proxyPort,host,port,false);
  +        this(proxyHost, proxyPort, host, port, false);
       }
   
       /**
        * Fully-specified constructor.
  +     *
        * @param proxyHost the host I should proxy via
        * @param proxyPort the port I should proxy via
        * @param host the host I should connect to. Parameter value must be non-null.
        * @param port the port I should connect to
        * @param secure when <tt>true</tt>, connect via HTTPS (SSL)
        */
  -    public HttpConnection(String proxyHost, int proxyPort, String host, int port, boolean
secure) {
  +    public HttpConnection(String proxyHost, int proxyPort, String host, 
  +    int port, boolean secure) {
           log.debug("HttpConnection.HttpConnection");
           if (host == null) {
               throw new NullPointerException("host parameter is null");
  @@ -138,6 +145,7 @@
   
       /**
        * Return my host.
  +     *
        * @return my host.
        */
       public String getHost() {
  @@ -146,6 +154,7 @@
   
       /**
        * Set my host.
  +     *
        * @param host the host I should connect to. Parameter value must be non-null.
        * @throws IllegalStateException if I am already connected
        */
  @@ -159,6 +168,7 @@
   
       /**
        * Return my port.
  +     *
        * @return my port.
        */
       public int getPort() {
  @@ -167,6 +177,7 @@
   
       /**
        * Set my port.
  +     *
        * @param port the port I should connect to
        * @throws IllegalStateException if I am already connected
        */
  @@ -177,6 +188,7 @@
   
       /**
        * Return my proxy host.
  +     *
        * @return my proxy host.
        */
       public String getProxyHost() {
  @@ -185,6 +197,7 @@
   
       /**
        * Set the host I should proxy through.
  +     *
        * @param host the host I should proxy through.
        * @throws IllegalStateException if I am already connected
        */
  @@ -195,6 +208,7 @@
   
       /**
        * Return my proxy port.
  +     *
        * @return my proxy port.
        */
       public int getProxyPort() {
  @@ -203,6 +217,7 @@
   
       /**
        * Set the port I should proxy through.
  +     *
        * @param port the host I should proxy through.
        * @throws IllegalStateException if I am already connected
        */
  @@ -214,6 +229,7 @@
       /**
        * Return <tt>true</tt> if I will (or I am) connected over a
        * secure (HTTPS/SSL) protocol.
  +     *
        * @return <tt>true</tt> if I will (or I am) connected over a
        *         secure (HTTPS/SSL) protocol.
        */
  @@ -223,6 +239,7 @@
   
       /**
        * Set whether or not I should connect over HTTPS (SSL).
  +     *
        * @param secure whether or not I should connect over HTTPS (SSL).
        * @throws IllegalStateException if I am already connected
        */
  @@ -234,6 +251,7 @@
       /**
        * Return <tt>true</tt> if I am connected,
        * <tt>false</tt> otherwise.
  +     *
        * @return <tt>true</tt> if I am connected
        */
       public boolean isOpen() {
  @@ -243,6 +261,7 @@
       /**
        * Return <tt>true</tt> if I am (or I will be)
        * connected via a proxy, <tt>false</tt> otherwise.
  +     *
        * @return <tt>true</tt> if I am (or I will be)
        *         connected via a proxy, <tt>false</tt> otherwise.
        */
  @@ -253,15 +272,17 @@
       // --------------------------------------------------- Other Public Methods
   
       /**
  -     * Set my {@link Socket}'s timeout, via
  -     * {@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.
  +     * Set my {@link Socket}'s timeout, via {@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.
  +     *
  +     * @param timeout 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
{
  +    public void setSoTimeout(int timeout) throws SocketException, 
  +    IllegalStateException {
           log.debug("HttpConnection.setSoTimeout()");
           _so_timeout = timeout;
           if(_socket != null){
  @@ -272,6 +293,8 @@
       /**
        * Open this connection to the current host and port
        * (via a proxy if so configured).
  +     *
  +     * @throws IOException when there are errors opening the connection
        */
       public void open() throws IOException {
           log.debug("HttpConnection.open()");
  @@ -299,12 +322,12 @@
       }
   
       /**
  -     * Return a {@link RequestOutputStream}
  -     * suitable for writing (possibly chunked)
  -     * bytes to my {@link OutputStream}.
  +     * Return a {@link RequestOutputStream} suitable for writing (possibly 
  +     * chunked) bytes to my {@link OutputStream}.
        *
        * @throws IllegalStateException if I am not connected
        * @throws IOException if an I/O problem occurs
  +     * @return a stream to write the request to
        */
       public OutputStream getRequestOutputStream() throws IOException, IllegalStateException
{
           assertOpen();
  @@ -313,14 +336,14 @@
       }
   
       /**
  -     * Return a {@link RequestOutputStream}
  -     * suitable for writing (possibly chunked) bytes to my
  -     * {@link OutputStream}.
  -     *
  -     * @param useChunking when <tt>true</tt> the chunked transfer-encoding
will be used
  +     * Return a {@link RequestOutputStream} suitable for writing (possibly 
  +     * chunked) bytes to my {@link OutputStream}.
        *
  +     * @param useChunking when <tt>true</tt> the chunked transfer-encoding
will
  +     *      be used
        * @throws IllegalStateException if I am not connected
        * @throws IOException if an I/O problem occurs
  +     * @return a stream to write the request to
        */
       public OutputStream getRequestOutputStream(boolean useChunking) throws IOException,
IllegalStateException {
           assertOpen();
  @@ -329,29 +352,36 @@
       }
   
       /**
  -     * Return a {@link ResponseInputStream}
  -     * suitable for reading (possibly chunked)
  -     * bytes from my {@link InputStream}.
  +     * Return a {@link ResponseInputStream} suitable for reading (possibly 
  +     * chunked) bytes from my {@link InputStream}.
        * <p>
        * If the given {@link HttpMethod} contains
        * a <tt>Transfer-Encoding: chunked</tt> header,
        * the returned stream will be configured
        * to read chunked bytes.
        *
  +     * @param method the http method to get the input stream from
        * @throws IllegalStateException if I am not connected
        * @throws IOException if an I/O problem occurs
  +     * @return a stream to read the response from
        */
  -    public InputStream getResponseInputStream(HttpMethod method) throws IOException, IllegalStateException
{
  +    public InputStream getResponseInputStream(HttpMethod method) 
  +    throws IOException, IllegalStateException {
           assertOpen();
           return new ResponseInputStream(_input,method);
       }
   
       /**
        * Write the specified bytes to my output stream.
  +     *
  +     * @param data the data to be written
  +     * @throws HttpRecoverableException when socket exceptions occur writing
  +     *      data
        * @throws IllegalStateException if I am not connected
        * @throws IOException if an I/O problem occurs
        */
  -    public void write(byte[] data) throws IOException, IllegalStateException, HttpRecoverableException
{
  +    public void write(byte[] data) throws IOException, IllegalStateException, 
  +    HttpRecoverableException {
           if(log.isDebugEnabled()){
               log.debug("HttpConnection.write(byte[])");
           }
  @@ -376,12 +406,17 @@
   
   
       /**
  -     * Write the specified bytes, followed by
  -     * <tt>"\r\n".getBytes()</tt> to my output stream.
  +     * Write the specified bytes, followed by <tt>"\r\n".getBytes()</tt> to
my
  +     * output stream.
  +     *
  +     * @param data the bytes to be written
  +     * @throws HttpRecoverableException when socket exceptions occur writing
  +     *      data
        * @throws IllegalStateException if I am not connected
        * @throws IOException if an I/O problem occurs
        */
  -    public void writeLine(byte[] data) throws IOException, IllegalStateException, HttpRecoverableException
{
  +    public void writeLine(byte[] data) throws IOException, 
  +    IllegalStateException, HttpRecoverableException {
           if(log.isDebugEnabled()){
               log.debug("HttpConnection.writeLine(byte[])");
           }
  @@ -404,10 +439,14 @@
   
       /**
        * Write <tt>"\r\n".getBytes()</tt> to my output stream.
  +     *
  +     * @throws HttpRecoverableException when socket exceptions occur writing
  +     *      data
        * @throws IllegalStateException if I am not connected
        * @throws IOException if an I/O problem occurs
        */
  -    public void writeLine() throws IOException, IllegalStateException, HttpRecoverableException
{
  +    public void writeLine() throws IOException, IllegalStateException, 
  +    HttpRecoverableException {
           if(log.isDebugEnabled()){
               log.debug("HttpConnection.writeLine()");
           }
  @@ -426,36 +465,52 @@
   
       /**
        * Write the specified String (as bytes) to my output stream.
  +     *
  +     * @param data the string to be written
  +     * @throws HttpRecoverableException when socket exceptions occur writing
  +     *      data
        * @throws IllegalStateException if I am not connected
        * @throws IOException if an I/O problem occurs
        */
  -    public void print(String data) throws IOException, IllegalStateException, HttpRecoverableException
{
  +    public void print(String data) throws IOException, IllegalStateException,
  +    HttpRecoverableException {
           write(data.getBytes());
       }
   
       /**
  -     * Write the specified String (as bytes), followed by
  +     * Write the specified String (as bytes), followed by 
        * <tt>"\r\n".getBytes()</tt> to my output stream.
  +     *
  +     * @param data the data to be written
  +     * @throws HttpRecoverableException when socket exceptions occur writing
  +     *      data
        * @throws IllegalStateException if I am not connected
        * @throws IOException if an I/O problem occurs
        */
  -    public void printLine(String data) throws IOException, IllegalStateException, HttpRecoverableException
{
  +    public void printLine(String data) throws IOException, 
  +    IllegalStateException, HttpRecoverableException {
           writeLine(data.getBytes());
       }
   
       /**
        * Write <tt>"\r\n".getBytes()</tt> to my output stream.
  +     *
  +     * @throws HttpRecoverableException when socket exceptions occur writing
  +     *      data
        * @throws IllegalStateException if I am not connected
        * @throws IOException if an I/O problem occurs
        */
  -    public void printLine() throws IOException, IllegalStateException, HttpRecoverableException
{
  +    public void printLine() throws IOException, IllegalStateException, 
  +    HttpRecoverableException {
           writeLine();
       }
   
       /**
        * Read up to <tt>"\r\n"</tt> from my (unchunked) input stream.
  +     *
        * @throws IllegalStateException if I am not connected
        * @throws IOException if an I/O problem occurs
  +     * @return a line from the response
        */
       public String readLine() throws IOException, IllegalStateException {
           log.debug("HttpConnection.readLine()");
  @@ -463,7 +518,6 @@
           StringBuffer buf = new StringBuffer();
           for(;;) {
               int ch = _input.read();
  -//            log.debug("HttpConnection.readLine() read " + ch);
               if(ch < 0) {
                   if(buf.length() == 0) {
                       return null;
  @@ -486,11 +540,9 @@
       }
   
       /**
  -     * Shutdown my {@link Socket}'s output, via
  -     * {@link Socket#shutdownOutput}.
  -     * @throws IOException if an I/O problem occurs
  +     * Shutdown my {@link Socket}'s output, via {@link Socket#shutdownOutput}.
        */
  -    public void shutdownOutput() throws IOException {
  +    public void shutdownOutput() { 
           log.debug("HttpConnection.shutdownOutput()");
           try {
               // Socket.shutdownOutput is a JDK 1.3
  @@ -509,9 +561,8 @@
   
       /**
        * Close my socket and streams.
  -     * @throws IOException if an I/O problem occurs
        */
  -    public void close() throws IOException {
  +    public void close() {
           log.debug("HttpConnection.close()");
           closeSocketAndStreams();
       }
  @@ -547,8 +598,10 @@
           _open = false;
       }
   
  -    /**
  +    /** 
        * Throw an {@link IllegalStateException} if I am connected.
  +     *
  +     * @throws IllegalStateException if connected
        */
       protected void assertNotOpen() throws IllegalStateException {
           if(_open) {
  @@ -558,6 +611,8 @@
   
       /**
        * Throw an {@link IllegalStateException} if I am not connected.
  +     *
  +     * @throws IllegalStateException if not connected
        */
       protected void assertOpen() throws IllegalStateException {
           if(!_open) {
  
  
  

--
To unsubscribe, e-mail:   <mailto:commons-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache.org>


Mime
View raw message