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 ConnectMethod.java
Date Mon, 05 Aug 2002 12:26:25 GMT
dion        2002/08/05 05:26:24

  Modified:    httpclient/src/java/org/apache/commons/httpclient
                        ConnectMethod.java
  Log:
  Style violations and documentation
  
  Revision  Changes    Path
  1.4       +53 -16    jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/ConnectMethod.java
  
  Index: ConnectMethod.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/ConnectMethod.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- ConnectMethod.java	30 Jul 2002 03:01:47 -0000	1.3
  +++ ConnectMethod.java	5 Aug 2002 12:26:24 -0000	1.4
  @@ -69,63 +69,100 @@
   
   /**
    * <p>Wraps another method to tunnel through a proxy.</p>
  + *
    * @author Ortwin Glück
  + * @author dIon Gillard
  + * @since 2.0
    * @version $Revision$ $Date$
    */
  -
   public class ConnectMethod extends HttpMethodBase {
  +    /** the name of this method */
       public static final String NAME = "CONNECT";
   
       /**
        * Create a connect method wrapping the existing method
  +     *
  +     * @param method the {@link HttpMethod method} to execute after connecting
  +     *      to the server
        */
       public ConnectMethod(HttpMethod method) {
           log.trace("enter ConnectMethod(HttpMethod)");
           this.method = method;
       }
   
  +    /**
  +     * Provide the {@link #NAME name} of this method.
  +     *
  +     * @return the String "CONNECT"
  +     */
       public String getName() {
           return NAME;
       }
   
  -    public int execute(HttpState state, HttpConnection connection) 
  +    /**
  +     * Execute this method by tunnelling and then executing the wrapped method.
  +     *
  +     * @param state the current http state
  +     * @param conn the connection to write to
  +     * @return the http status code from execution
  +     * @throws HttpException when an error occurs writing the headers
  +     * @throws IOException when an error occurs writing the headers
  +     */
  +    public int execute(HttpState state, HttpConnection conn) 
       throws IOException, HttpException {
   
           log.trace("enter ConnectMethod.execute(HttpState, HttpConnection)");
  -        int code = super.execute(state,  connection);
  -        log.debug("CONNECT status code "+ code);
  +        int code = super.execute(state, conn);
  +        log.debug("CONNECT status code " + code);
           if ((code >= 200) && (code < 300)) {
  -            connection.tunnelCreated();
  -            code = method.execute(state, connection);
  +            conn.tunnelCreated();
  +            code = method.execute(state, conn);
           }
           return code;
       }
   
       /**
        * Writes a minimal set of headers to the proxy.
  +     *
  +     * @param state the current http state
  +     * @param conn the connection to write to
  +     * @throws HttpException when an error occurs writing the headers
  +     * @throws IOException when an error occurs writing the headers
        */
       protected void writeRequestHeaders(HttpState state, HttpConnection conn) 
       throws HttpException, IOException {
  -        log.trace("enter ConnectMethod.writeRequestHeaders(HttpState, HttpConnection)");
  +        log.trace("enter ConnectMethod.writeRequestHeaders(HttpState, "
  +            + "HttpConnection)");
   
           if (method instanceof HttpMethodBase) {
               ((HttpMethodBase) method).addRequestHeaders(state, conn);
           }
           conn.print(method.getRequestHeader("Host").toExternalForm());
           Header header = method.getRequestHeader(Authenticator.PROXY_AUTH_RESP);
  -        if (header == null) header = getRequestHeader(Authenticator.PROXY_AUTH_RESP);
  -        if (header != null) conn.print(header.toExternalForm());
  +        if (header == null) {
  +            header = getRequestHeader(Authenticator.PROXY_AUTH_RESP);
  +        }
  +        if (header != null) {
  +            conn.print(header.toExternalForm());
  +        }
       }
   
       /**
  -     * Special Connect request
  +     * Special Connect request.
  +     *
  +     * @param state the current http state
  +     * @param conn the connection to write to
  +     * @throws IOException when an error occurs writing the request
  +     * @throws HttpException when an error occurs writing the request
        */
  -    protected void writeRequestLine(HttpState state, HttpConnection conn) throws IOException,
HttpException {
  +    protected void writeRequestLine(HttpState state, HttpConnection conn)
  +    throws IOException, HttpException {
           int port = conn.getPort();
           if (port == -1) {
               port = conn.isSecure() ? 443 : 80;
           }
  -        String line = getName() +" "+ conn.getHost() +":"+ port +" HTTP/1.1";
  +        String line = getName() + " " + conn.getHost() + ":" + port 
  +            + " HTTP/1.1";
           conn.printLine(line);
       }
   
  
  
  

--
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