commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From oglu...@apache.org
Subject cvs commit: jakarta-commons/httpclient/src/test/org/apache/commons/httpclient TestLocalHost.java TestNoHost.java
Date Tue, 03 Dec 2002 15:28:19 GMT
oglueck     2002/12/03 07:28:18

  Modified:    httpclient/src/java/org/apache/commons/httpclient
                        HttpClient.java HttpMethodBase.java
               httpclient/src/test/org/apache/commons/httpclient
                        TestLocalHost.java TestNoHost.java
  Log:
  fixed tests
  
  Contributed by: Eric Johnson
  
  Revision  Changes    Path
  1.62      +5 -5      jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/HttpClient.java
  
  Index: HttpClient.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/HttpClient.java,v
  retrieving revision 1.61
  retrieving revision 1.62
  diff -u -r1.61 -r1.62
  --- HttpClient.java	3 Dec 2002 05:46:15 -0000	1.61
  +++ HttpClient.java	3 Dec 2002 15:28:18 -0000	1.62
  @@ -215,7 +215,7 @@
        * 
        * @param timeout the timeout in milliseconds
        * 
  -     * @see HttpConnectionManager#getConnection(String, long)
  +     * @see HttpConnectionManager#getConnection(HostConfiguration, long)
        */
       public synchronized void setHttpConnectionFactoryTimeout( long timeout ) {
           this.httpConnectionTimeout = timeout;
  
  
  
  1.83      +196 -196  jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/HttpMethodBase.java
  
  Index: HttpMethodBase.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/HttpMethodBase.java,v
  retrieving revision 1.82
  retrieving revision 1.83
  diff -u -r1.82 -r1.83
  --- HttpMethodBase.java	3 Dec 2002 15:20:32 -0000	1.82
  +++ HttpMethodBase.java	3 Dec 2002 15:28:18 -0000	1.83
  @@ -84,11 +84,11 @@
    * <p>
    * An abstract base implementation of {@link HttpMethod}.
    * </p>
  - * 
  + *
    * <p>
    * At minimum, subclasses will need to override
    * </p>
  - * 
  + *
    * <dl>
    * <dt>
    * {@link #getName}
  @@ -97,12 +97,12 @@
    * to return the approriate name for this method
    * </dd>
    * </dl>
  - * 
  + *
    * <p>
    * When a method's request may contain a body, subclasses will typically want
    * to override:
    * </p>
  - * 
  + *
    * <dl>
    * <dt>
    * {@link #getRequestContentLength}
  @@ -117,12 +117,12 @@
    * to write the body
    * </dd>
    * </dl>
  - * 
  + *
    * <p>
    * When a method requires additional request headers, subclasses will typically
    * want to override:
    * </p>
  - * 
  + *
    * <dl>
    * <dt>
    * {@link #addRequestHeaders addRequestHeaders(HttpState,HttpConnection)}
  @@ -131,12 +131,12 @@
    * to write those headers
    * </dd>
    * </dl>
  - * 
  + *
    * <p>
    * When a method expects specific response headers, subclasses may want to
    * override:
    * </p>
  - * 
  + *
    * <dl>
    * <dt>
    * {@link #processResponseHeaders
  @@ -146,8 +146,8 @@
    * to handle those headers
    * </dd>
    * </dl>
  - * 
  - * 
  + *
  + *
    * @version $Revision$ $Date$
    * @author <a href="mailto:remm@apache.org">Remy Maucherat</a>
    * @author Rodney Waldhoff
  @@ -175,7 +175,7 @@
   
       static {
           String agent = System.getProperties()
  -                             .getProperty("httpclient.useragent", 
  +                             .getProperty("httpclient.useragent",
                                             "Jakarta Commons-HttpClient/2.0M1");
           USER_AGENT = new Header("User-Agent", agent);
       }
  @@ -208,7 +208,7 @@
   
       /** The response body, assuming it has not be intercepted by a sub-class. */
       private InputStream responseStream = null;
  -    
  +
       /** The connection that the response stream was read from. */
       private HttpConnection responseConnection = null;
   
  @@ -255,7 +255,7 @@
   
       /**
        * Path-specifying constructor.
  -     * 
  +     *
        * @param path my path which can include a query
        */
       public HttpMethodBase(String path) {
  @@ -275,7 +275,7 @@
       /**
        * Obtain the name of this method, suitable for use in the "request line",
        * for example <tt>GET</tt> or <tt>POST</tt>.
  -     * 
  +     *
        * @return the name of this method
        */
       public abstract String getName();
  @@ -283,7 +283,7 @@
       /**
        * Set whether or not I should automatically follow HTTP redirects (status
        * code 302, etc.)
  -     * 
  +     *
        * @param followRedirects true to follow redirects, false otherwise
        */
       public void setFollowRedirects(boolean followRedirects) {
  @@ -293,7 +293,7 @@
       /**
        * Whether or not I should automatically follow HTTP redirects (status code
        * 302, etc.)
  -     * 
  +     *
        * @return <tt>true</tt> if I will automatically follow HTTP redirects
        */
       public boolean getFollowRedirects() {
  @@ -302,7 +302,7 @@
   
       /**
        * Set whether or not I should use the HTTP/1.1 protocol.
  -     * 
  +     *
        * @param http11 true to use HTTP/1.1, false to use 1.0
        */
       public void setHttp11(boolean http11) {
  @@ -334,9 +334,9 @@
       // ---------------------------------------------- Protected Utility Methods
   
       /**
  -     * Access to flag to determine if client should use 
  +     * Access to flag to determine if client should use
        * HTTP/1.1 protocol.
  -     * 
  +     *
        * @return <tt>true</tt> if I should use the HTTP/1.1 protocol
        */
       public boolean isHttp11() {
  @@ -345,7 +345,7 @@
   
       /**
        * Set the path part of my request.
  -     * 
  +     *
        * @param path the path to request
        */
       public void setPath(String path) {
  @@ -356,8 +356,8 @@
        * Add the specified request header.
        *
        * If a header of the same name already exists, the new value will be
  -     * appended onto the the existing value list. 
  -     * A <i>header</i> value of <code>null</code> will be ignored.

  +     * appended onto the the existing value list.
  +     * A <i>header</i> value of <code>null</code> will be ignored.
        * Note that header-name matching is case insensitive.
        *
        * @param header the header to add to the request
  @@ -382,7 +382,7 @@
   
       /**
        * Get the path part of my request.
  -     * 
  +     *
        * @return the path to request or "/" if the path is blank.
        */
       public String getPath() {
  @@ -395,7 +395,7 @@
        * URIUtil.encodeAll, URIUtil.encodeWithinQuery or URIUtil.encodeQuery can
        * be used to encode parameter names and values.
        * The query string should not start with the question mark character.
  -     * 
  +     *
        * @param queryString the query string
        */
       public void setQueryString(String queryString) {
  @@ -404,7 +404,7 @@
   
       /**
        * Set my query string.
  -     * 
  +     *
        * @param params an array of {@link NameValuePair}s to add as query string
        *        parameterss
        */
  @@ -445,7 +445,7 @@
   
       /**
        * Get my query string.
  -     * 
  +     *
        * @return The query string portion of the request
        */
       public String getQueryString() {
  @@ -455,7 +455,7 @@
       /**
        * Set the specified request header, overwriting any previous value. Note
        * that header-name matching is case-insensitive.
  -     * 
  +     *
        * @param headerName the header's name
        * @param headerValue the header's value
        */
  @@ -467,7 +467,7 @@
       /**
        * Set the specified request header, overwriting any previous value. Note
        * that header-name matching is case insensitive.
  -     * 
  +     *
        * @param header the header
        */
       public void setRequestHeader(Header header) {
  @@ -479,9 +479,9 @@
        * matching is case insensitive. <tt>null</tt> will be returned if either
        * <i>headerName</i> is <tt>null</tt> or there is no matching
header for
        * <i>headerName</i>.
  -     * 
  +     *
        * @param headerName the header name to match
  -     * 
  +     *
        * @return the matching header
        */
       public Header getRequestHeader(String headerName) {
  @@ -491,7 +491,7 @@
   
       /**
        * Provides access to the request headers.
  -     * 
  +     *
        * @return an array of my request headers.
        */
       public Header[] getRequestHeaders() {
  @@ -500,8 +500,8 @@
       }
   
       /**
  -     * Provide access to the status code.
  -     * 
  +     * Convenience method top provide access to the status code.
  +     *
        * @return the status code associated with the latest response.
        */
       public int getStatusCode() {
  @@ -510,7 +510,7 @@
   
       /**
        * Provide access to the status line.
  -     * 
  +     *
        * @return the status line object from the latest response.
        * @since 2.0
        */
  @@ -528,7 +528,7 @@
   
       /**
        * Provide access to the response headers
  -     * 
  +     *
        * @return an array of my response headers.
        */
       public Header[] getResponseHeaders() {
  @@ -541,14 +541,14 @@
        * matching is case insensitive. <tt>null</tt> will be returned if either
        * <i>headerName</i> is <tt>null</tt> or there is no matching
header for
        * <i>headerName</i>.
  -     * 
  +     *
        * @param headerName the header name to match
  -     * 
  +     *
        * @return the matching header
        */
       public Header getResponseHeader(String headerName) {
           return (headerName == null)
  -               ? null 
  +               ? null
                  : (Header) (responseHeaders.get(headerName.toLowerCase()));
       }
   
  @@ -580,9 +580,9 @@
       /**
        * Return my response body, if any, as an {@link InputStream}. Otherwise
        * return <tt>null</tt>.
  -     * 
  +     *
        * @return the response body as an {@link InputStream}
  -     * 
  +     *
        * @throws IOException when there are errors obtaining the response
        */
       public InputStream getResponseBodyAsStream() throws IOException {
  @@ -599,7 +599,7 @@
   
       /**
        * Gets the response body as a string.
  -     * 
  +     *
        * <b>Note:</b> The string conversion done on the data is done with the
        * default character encoding.  The use of this method may be non-portable.
        *
  @@ -661,7 +661,7 @@
   
       /**
        * Provide access to the status text
  -     * 
  +     *
        * @return the status text (or "reason phrase") associated with the latest
        *         response.
        */
  @@ -676,7 +676,7 @@
        * most Http user agent's do (and many HTTP servers expect. NOTE:
        * StrictMode is currently experimental and its functionlaity may change
        * in the future.
  -     * 
  +     *
        * @param strictMode true for strict mode, false otherwise
        */
       public void setStrictMode(boolean strictMode) {
  @@ -686,7 +686,7 @@
       /**
        * Returns the value of strictMode. NOTE:  StrictMode is currently
        * experimental and its functionlaity may  change in the future.
  -     * 
  +     *
        * @return true if strict mode is enabled.
        */
       public boolean isStrictMode() {
  @@ -696,7 +696,7 @@
       /**
        * Add the specified request header, NOT overwriting any previous value.
        * Note that header-name matching is case insensitive.
  -     * 
  +     *
        * @param headerName the header's name
        * @param headerValue the header's value
        */
  @@ -737,7 +737,7 @@
   
       private boolean shouldCloseConnection() {
           if (!http11) {
  -            if (getName().equals(ConnectMethod.NAME) && 
  +            if (getName().equals(ConnectMethod.NAME) &&
                       (statusLine.getStatusCode() == HttpStatus.SC_OK)) {
                   log.debug("Will leave connection open for tunneling");
                   return false;
  @@ -758,12 +758,12 @@
       }
   
       private void wrapResponseStream( HttpConnection connection ) {
  -        
  +
           if ( responseStream != null ) {
               this.responseConnection = connection;
  -            this.responseStream = new ResponseAutoReleaseInputStream(responseStream); 
 
  +            this.responseStream = new ResponseAutoReleaseInputStream(responseStream);
           }
  -           
  +
       }
   
       /**
  @@ -772,7 +772,7 @@
        * we  don't yet have a good way to get the new connection.  For  the time
        * being, we just return the redirect response code,  and allow the user
        * agent to resubmit if desired.
  -     * 
  +     *
        * @param state {@link HttpState} information to associate with this
        *        request. Must be non-null.
        * @param conn the{@link HttpConnection} to write to/read from. Must be
  @@ -781,9 +781,9 @@
        *        because we don't yet have a good way to get the new connection.
        *        For the time being, we just return the 302 response, and allow
        *        the user agent to resubmit if desired.
  -     * 
  +     *
        * @return the integer status code if one was obtained, or <tt>-1</tt>
  -     * 
  +     *
        * @throws HttpException  if an protocol exception occurs
        * @throws HttpRecoverableException if too many redirects occur.
        * @throws IOException if an I/O error occurs
  @@ -793,7 +793,7 @@
       throws HttpException, IOException, NullPointerException {
           log.trace("enter HttpMethodBase.execute(HttpState, HttpConnection)");
   
  -        //TODO: This method is too large 
  +        //TODO: This method is too large
           //check some error conditions
           if (null == state) {
               throw new NullPointerException("HttpState parameter");
  @@ -843,7 +843,7 @@
                               return statusCode;
                           }
                       } else { //let the client handle the authenticaiton
  -                        wrapResponseStream(conn);                      
  +                        wrapResponseStream(conn);
                           return statusCode;
                       }
                       break;
  @@ -854,7 +854,7 @@
                       log.debug("Redirect required");
   
                       if (! processRedirectResponse(state, conn)) {
  -                        wrapResponseStream(conn);                
  +                        wrapResponseStream(conn);
                           return statusCode;
                       }
                       break;
  @@ -885,7 +885,7 @@
           } //end of loop
   
           wrapResponseStream(conn);
  -        
  +
           log.error("Narrowly avoided an infinite loop in execute");
           throw new HttpRecoverableException("Maximum redirects ("+ maxForwards +") exceeded");
       }
  @@ -914,18 +914,18 @@
   
           //rfc2616 demands the location value be a complete URI
           //Location       = "Location" ":" absoluteURI
  -        URL redirectUrl = null; 
  -        URL currentUrl = null; 
  +        URL redirectUrl = null;
  +        URL currentUrl = null;
   
           try {
  -            currentUrl = new URL(conn.getProtocol().toLowerCase(), 
  +            currentUrl = new URL(conn.getProtocol().toLowerCase(),
                   conn.getHost(), conn.getPort(), "");
               redirectUrl = new URL(location);
           } catch (MalformedURLException e) {
               if (isStrictMode()) {
                   log.warn("Redirected location '" + location +
                           "' is not acceptable in strict mode");
  -                return false; 
  +                return false;
               } else { //location is incomplete, use current values for defaults
                   try {
                       log.debug("Redirect URL is not absolute - parsing as relative");
  @@ -961,7 +961,7 @@
       }
   
   
  -    /** 
  +    /**
        * Check for a valid redirect given the current conn and new url.
        * Redirect to a different protocol, host or port are checked for validity.
        *
  @@ -970,7 +970,7 @@
        * @throws HttpException if the redirect is invalid
        * @since 2.0
        */
  -    private static void checkValidRedirect(URL currentUrl, URL redirectUrl) 
  +    private static void checkValidRedirect(URL currentUrl, URL redirectUrl)
       throws HttpException {
           log.trace("enter HttpMethodBase.checkValidRedirect(HttpConnection, URL)");
   
  @@ -997,21 +997,21 @@
               newPort = getDefaultPort(newProtocol);
           }
           if (oldPort != newPort) {
  -            throw new HttpException("Redirect from port " + oldPort 
  +            throw new HttpException("Redirect from port " + oldPort
                       + " to " + newPort + " is not supported");
           }
       }
   
   
  -    /** 
  +    /**
        * Returns the default port for the given protocol.
  -     * 
  +     *
        * @param protocol currently only http and https are recognized
        * @return the default port of the given protocol or -1 if the
        * protocol is not recognized.
        *
        * @since 2.0
  -     * 
  +     *
        */
       private static int getDefaultPort(String protocol) {
           String proto = protocol.toLowerCase().trim();
  @@ -1026,7 +1026,7 @@
   
       /**
        * Whether the object has been used and not recycled.
  -     * 
  +     *
        * @return <tt>true</tt> if I have been {@link #execute executed} but not
        *         recycled.
        */
  @@ -1042,7 +1042,7 @@
           log.trace("enter HttpMethodBase.recycle()");
   
           releaseConnection();
  -        
  +
           path = null;
           followRedirects = false;
           doAuthentication = true;
  @@ -1058,23 +1058,23 @@
   
       /**
        * @see org.apache.commons.httpclient.HttpMethod#releaseConnection()
  -     * 
  +     *
        * @since 2.0
        */
       public void releaseConnection() {
  -        
  +
           if ( responseConnection != null ) {
               responseConnection.releaseConnection();
               this.responseConnection = null;
               this.responseStream = null;
           }
  -        
  +
       }
  -    
  +
       /**
        * Remove the request header associated with the given name. Note that
        * header-name matching is case insensitive.
  -     * 
  +     *
        * @param headerName the header name
        */
       public void removeRequestHeader(String headerName) {
  @@ -1085,11 +1085,11 @@
   
       /**
        * Confirm that I am ready to execute.
  -     * 
  +     *
        * <p>
        * This implementation always returns <tt>true</tt>.
        * </p>
  -     * 
  +     *
        * @return <tt>true</tt>
        */
       public boolean validate() {
  @@ -1099,16 +1099,16 @@
       /**
        * Return the length (in bytes) of my request body, suitable for use in a
        * <tt>Content-Length</tt> header.
  -     * 
  +     *
        * <p>
        * Return <tt>-1</tt> when the content-length is unknown.
        * </p>
  -     * 
  +     *
        * <p>
        * This implementation returns <tt>0</tt>, indicating that the request
has
        * no body.
        * </p>
  -     * 
  +     *
        * @return <tt>0</tt>, indicating that the request has no body.
        */
       protected int getRequestContentLength() {
  @@ -1118,15 +1118,15 @@
       /**
        * Adds an <tt>Authorization</tt> request if needed, as long as no
        * <tt>Authorization</tt> request header already exists.
  -     * 
  +     *
        * @param state current state of http requests
        * @param conn the connection to use for I/O
  -     * 
  +     *
        * @throws IOException when errors occur reading or writing to/from the
        *         connection
        * @throws HttpException when a recoverable error occurs
        */
  -    protected void addAuthorizationRequestHeader(HttpState state, 
  +    protected void addAuthorizationRequestHeader(HttpState state,
                                                    HttpConnection conn)
       throws IOException, HttpException {
           log.trace("enter HttpMethodBase.addAuthorizationRequestHeader("
  @@ -1150,15 +1150,15 @@
        * Adds a <tt>Content-Length</tt> or <tt>Transfer-Encoding: Chunked</tt>
        * request header, as long as no <tt>Content-Length</tt> request header
        * already exists.
  -     * 
  +     *
        * @param state current state of http requests
        * @param conn the connection to use for I/O
  -     * 
  +     *
        * @throws IOException when errors occur reading or writing to/from the
        *         connection
        * @throws HttpException when a recoverable error occurs
        */
  -    protected void addContentLengthRequestHeader(HttpState state, 
  +    protected void addContentLengthRequestHeader(HttpState state,
                                                    HttpConnection conn)
       throws IOException, HttpException {
           log.trace("enter HttpMethodBase.addContentLengthRequestHeader("
  @@ -1177,10 +1177,10 @@
   
       /**
        * Adds a <tt>Cookie</tt> request containing the matching {@link Cookie}s.
  -     * 
  +     *
        * @param state current state of http requests
        * @param conn the connection to use for I/O
  -     * 
  +     *
        * @throws IOException when errors occur reading or writing to/from the
        *         connection
        * @throws HttpException when a recoverable error occurs
  @@ -1190,11 +1190,11 @@
           log.trace("enter HttpMethodBase.addCookieRequestHeader(HttpState, "
                     + "HttpConnection)");
   
  -        Header cookieHeader = Cookie.createCookieHeader(conn.getHost(), 
  -                                                        conn.getPort(), 
  -                                                        getPath(), 
  -                                                        conn.isSecure(), 
  -                                                        new Date(), 
  +        Header cookieHeader = Cookie.createCookieHeader(conn.getHost(),
  +                                                        conn.getPort(),
  +                                                        getPath(),
  +                                                        conn.isSecure(),
  +                                                        new Date(),
                                                           state.getCookies());
           if (null != cookieHeader) {
               setRequestHeader(cookieHeader);
  @@ -1204,10 +1204,10 @@
       /**
        * Adds a <tt>Host</tt> request header, as long as no <tt>Host</tt>
request
        * header already exists.
  -     * 
  +     *
        * @param state current state of http requests
        * @param conn the connection to use for I/O
  -     * 
  +     *
        * @throws IOException when errors occur reading or writing to/from the
        *         connection
        * @throws HttpException when a recoverable error occurs
  @@ -1217,9 +1217,9 @@
           log.trace("enter HttpMethodBase.addHostRequestHeader(HttpState, "
                     + "HttpConnection)");
   
  -        // Per 19.6.1.1 of RFC 2616, it is legal for HTTP/1.0 based 
  +        // Per 19.6.1.1 of RFC 2616, it is legal for HTTP/1.0 based
           // applications to send the Host request-header.
  -        // TODO: Add the ability to disable the sending of this header for 
  +        // TODO: Add the ability to disable the sending of this header for
           //       HTTP/1.0 requests.
           String host = conn.getHost();
           int port = conn.getPort();
  @@ -1250,15 +1250,15 @@
       /**
        * Adds a <tt>Proxy-Authorization</tt> request if needed, as long as no
        * <tt>Proxy-Authorization</tt> request header already exists.
  -     * 
  +     *
        * @param state current state of http requests
        * @param conn the connection to use for I/O
  -     * 
  +     *
        * @throws IOException when errors occur reading or writing to/from the
        *         connection
        * @throws HttpException when a recoverable error occurs
        */
  -    protected void addProxyAuthorizationRequestHeader(HttpState state, 
  +    protected void addProxyAuthorizationRequestHeader(HttpState state,
                                                         HttpConnection conn)
       throws IOException, HttpException {
           log.trace("enter HttpMethodBase.addProxyAuthorizationRequestHeader("
  @@ -1281,25 +1281,25 @@
       /**
        * Populates the request headers map to with additional {@link Header
        * headers} to be submitted to the given {@link HttpConnection}.
  -     * 
  +     *
        * <p>
        * This implementation adds <tt>User-Agent</tt>, <tt>Host</tt>,
        * <tt>Cookie</tt>, <tt>Content-Length</tt>, <tt>Transfer-Encoding</tt>,
        * and <tt>Authorization</tt> headers, when appropriate.
        * </p>
  -     * 
  +     *
        * <p>
        * Subclasses may want to override this method to to add additional
        * headers, and may choose to invoke this implementation (via
        * <tt>super</tt>) to add the "standard" headers.
        * </p>
  -     * 
  +     *
        * @param state the client state
        * @param conn the {@link HttpConnection} the headers will eventually be
        *        written to
        * @throws IOException when an error occurs writing the request
        * @throws HttpException when a HTTP protocol error occurs
  -     * 
  +     *
        * @see #writeRequestHeaders
        */
       protected void addRequestHeaders(HttpState state, HttpConnection conn)
  @@ -1318,14 +1318,14 @@
       /**
        * Adds a default <tt>User-Agent</tt> request header, as long as no
        * <tt>User-Agent</tt> request header already exists.
  -     * 
  +     *
        * @param state the client state
        * @param conn the {@link HttpConnection} the headers will eventually be
        *        written to
        * @throws IOException when an error occurs writing the request
        * @throws HttpException when a HTTP protocol error occurs
        */
  -    protected void addUserAgentRequestHeader(HttpState state, 
  +    protected void addUserAgentRequestHeader(HttpState state,
                                                HttpConnection conn)
       throws IOException, HttpException {
           log.trace("enter HttpMethodBase.addUserAgentRequestHeaders(HttpState, "
  @@ -1338,8 +1338,8 @@
   
       /**
        * Throws an {@link IllegalStateException} if used but not recycled.
  -     * 
  -     * @throws IllegalStateException if the method has been used and not 
  +     *
  +     * @throws IllegalStateException if the method has been used and not
        *      recycled
        */
       protected void checkNotUsed() throws IllegalStateException {
  @@ -1350,7 +1350,7 @@
   
       /**
        * Throws an {@link IllegalStateException} if not used since last recycle.
  -     * 
  +     *
        * @throws IllegalStateException if not used
        */
       protected void checkUsed()  throws IllegalStateException {
  @@ -1363,16 +1363,16 @@
   
       /**
        * Generate an HTTP/S request line according to the specified attributes.
  -     * 
  +     *
        * @param connection the connection the request will be sent to
        * @param name the method name generate a request for
        * @param requestPath the path string for the request
        * @param query the query string for the request
        * @param protocol the protocol to use (e.g. HTTP/1.0)
  -     * 
  +     *
        * @return a line to send to the server that will fulfil the request
        */
  -    protected static String generateRequestLine(HttpConnection connection, 
  +    protected static String generateRequestLine(HttpConnection connection,
           String name, String requestPath, String query, String protocol) {
           log.trace("enter HttpMethodBase.generateRequestLine(HttpConnection, "
               + "String, String, String, String)");
  @@ -1417,18 +1417,18 @@
       /**
        * When this method is invoked, {@link #readResponseBody
        * readResponseBody(HttpState,HttpConnection)} will have been invoked.
  -     * 
  +     *
        * <p>
        * This implementation does nothing.
        * </p>
  -     * 
  +     *
        * <p>
        * Subclasses may want to override this method.
        * </p>
  -     * 
  +     *
        * @param state the client state
        * @param conn the {@link HttpConnection} to read the response from
  -     * 
  +     *
        * @see #readResponse
        * @see #readResponseBody
        */
  @@ -1440,26 +1440,26 @@
        * populated with the response headers (in other words, {@link
        * #readResponseHeaders readResponseHeaders(HttpState,HttpConnection)}
        * will have been invoked).
  -     * 
  +     *
        * <p>
        * This implementation will handle the <tt>Set-Cookie</tt> and
        * <tt>Set-Cookie2</tt> headers, if any, adding the relevant cookies to
        * the given {@link HttpState}.
        * </p>
  -     * 
  +     *
        * <p>
        * Subclasses may want to override this method to specially process
        * additional headers, and/or invoke this method (via <tt>super</tt>) to
        * process the <tt>Set-Cookie</tt> and <tt>Set-Cookie2</tt>
headers.
        * </p>
  -     * 
  +     *
        * @param state the client state
        * @param conn the {@link HttpConnection} to read the response from
  -     * 
  +     *
        * @see #readResponse
        * @see #readResponseHeaders
        */
  -    protected void processResponseHeaders(HttpState state, 
  +    protected void processResponseHeaders(HttpState state,
           HttpConnection conn) {
           log.trace("enter HttpMethodBase.processResponseHeaders(HttpState, "
               + "HttpConnection)");
  @@ -1473,8 +1473,8 @@
   
           if (setCookieHeader != null) {
               try {
  -                Cookie[] cookies = Cookie.parse(conn.getHost(), conn.getPort(), 
  -                                                getPath(), conn.isSecure(), 
  +                Cookie[] cookies = Cookie.parse(conn.getHost(), conn.getPort(),
  +                                                getPath(), conn.isSecure(),
                                                   setCookieHeader);
                   state.addCookies(cookies);
               } catch (HttpException e) {
  @@ -1490,15 +1490,15 @@
        * {@link #getStatusText status text} values will have been set (in other
        * words, {@link #readStatusLine readStatusLine(HttpState,HttpConnection}
        * will have been invoked).
  -     * 
  +     *
        * <p>
        * Subclasses may want to override this method to respond to these value.
        * This implementation does nothing.
        * </p>
  -     * 
  +     *
        * @param state the client state
        * @param conn the {@link HttpConnection} to read the response from
  -     * 
  +     *
        * @see #readResponse
        * @see #readStatusLine
        */
  @@ -1507,10 +1507,10 @@
   
       /**
        * Reads the response from the given {@link HttpConnection}.
  -     * 
  +     *
        * <p>
        * The response is written according to the following logic:
  -     * 
  +     *
        * <ol>
        * <li>
        * {@link #readStatusLine readStatusLine(HttpState,HttpConnection)} is
  @@ -1541,12 +1541,12 @@
        * method to respond to the body if desired.
        * </li>
        * </ol>
  -     * 
  +     *
        * Subclasses may want to override one or more of the above methods to to
        * customize the processing. (Or they may choose to override this method
        * if dramatically different processing is required.)
        * </p>
  -     * 
  +     *
        * @param state the client state
        * @param conn the {@link HttpConnection} to read the response from
        * @throws IOException when i/o errors occur reading the response
  @@ -1566,23 +1566,23 @@
   
       /**
        * Read the response body from the given {@link HttpConnection}.
  -     * 
  +     *
        * <p>
        * The current implementation simply consumes the expected response body
        * (according to the values of the <tt>Content-Length</tt> and
        * <tt>Transfer-Encoding</tt> headers, if any).
        * </p>
  -     * 
  +     *
        * <p>
        * Subclasses may want to override this method to to customize the
        * processing.
        * </p>
  -     * 
  +     *
        * @param state the client state
        * @param conn the {@link HttpConnection} to read the response from
        * @throws IOException when i/o errors occur reading the response
        * @throws HttpException when a protocol error occurs or state is invalid
  -     * 
  +     *
        * @see #readResponse
        * @see #processResponseBody
        */
  @@ -1610,7 +1610,7 @@
        * @param conn the {@link HttpConnection} to read the response from
        * @return InputStream to read the response body from
        */
  -    private InputStream _readResponseBody(HttpState state, HttpConnection conn) 
  +    private InputStream _readResponseBody(HttpState state, HttpConnection conn)
       throws IOException {
           log.trace("enter HttpMethodBase.readResponseBody(HttpState, HttpConnection)");
   
  @@ -1629,12 +1629,12 @@
                   result = new ChunkedInputStream(is, this);
               }
           } else if (null != lengthHeader) {
  -            
  +
               // we're using this just in case the content length is duplicated
               // i.e. '57, 57'
  -            HeaderElement[] lengthElements = lengthHeader.getValues();            
  +            HeaderElement[] lengthElements = lengthHeader.getValues();
               String lengthValue = null;
  -            
  +
               if ( lengthElements.length > 1 ) {
                   // looks like the content length header was duplicated. if so
                   // they won't be key=value pairs so we just want to get
  @@ -1647,18 +1647,18 @@
   
               try {
                   int expectedLength = Integer.parseInt(lengthValue);
  -                // FIXME: what if the content length is 0, perhaps we should 
  -                // just return an empty stream in that case                
  +                // FIXME: what if the content length is 0, perhaps we should
  +                // just return an empty stream in that case
                   result = new ContentLengthInputStream(is, expectedLength);
               } catch(NumberFormatException e) {
  -                throw new HttpException( 
  -                    "Unable to parse server response content length: '" 
  +                throw new HttpException(
  +                    "Unable to parse server response content length: '"
                       + lengthValue + "'"
                   );
  -                
  +
               }
  -            
  -        } else if(canResponseHaveBody(statusLine.getStatusCode()) 
  +
  +        } else if(canResponseHaveBody(statusLine.getStatusCode())
                   && !getName().equals(ConnectMethod.NAME)){
               result = is;
           }
  @@ -1676,24 +1676,24 @@
       /**
        * Read response headers from the given {@link HttpConnection}, populating
        * the response headers map.
  -     * 
  +     *
        * <p>
        * Subclasses may want to override this method to to customize the
        * processing.
        * </p>
  -     * 
  +     *
        * <p>
        * "It must be possible to combine the multiple header fields into one
        * "field-name: field-value" pair, without changing the semantics of the
        * message, by appending each subsequent field-value to the first, each
        * separated by a comma." - HTTP/1.0 (4.3)
        * </p>
  -     * 
  +     *
        * @param state the client state
        * @param conn the {@link HttpConnection} to read the response from
        * @throws IOException when i/o errors occur reading the response
        * @throws HttpException when a protocol error occurs or state is invalid
  -     * 
  +     *
        * @see #readResponse
        * @see #processResponseHeaders
        */
  @@ -1757,22 +1757,22 @@
        * Read the status line from the given {@link HttpConnection}, setting my
        * {@link #getStatusCode status code} and {@link #getStatusText status
        * text}.
  -     * 
  +     *
        * <p>
        * Subclasses may want to override this method to to customize the
        * processing.
        * </p>
  -     * 
  +     *
        * @param state the client state
        * @param conn the {@link HttpConnection} to read the response from
  -     * 
  +     *
        * @throws IOException when errors occur reading the status line
        * @throws HttpException If there is no status line, the protocol is not
        *      recognised, if we are unable to parse the status code from the line,
        *      or there was no status text
        * @throws HttpRecoverableException when the status line is null and the
        *      request should be retried
  -     * 
  +     *
        * @see StatusLine
        */
       protected void readStatusLine(HttpState state, HttpConnection conn)
  @@ -1815,11 +1815,11 @@
        * <p>
        * Writes my request to the given {@link HttpConnection}.
        * </p>
  -     * 
  +     *
        * <p>
        * The request is written according to the following logic:
        * </p>
  -     * 
  +     *
        * <ol>
        * <li>
        * {@link #writeRequestLine writeRequestLine(HttpState, HttpConnection)} is
  @@ -1837,13 +1837,13 @@
        * invoked to write the body part of the request.
        * </li>
        * </ol>
  -     * 
  +     *
        * <p>
        * Subclasses may want to override one or more of the above methods to to
        * customize the processing. (Or they may choose to override this method
        * if dramatically different processing is required.)
        * </p>
  -     * 
  +     *
        * @param state the client state
        * @param conn the {@link HttpConnection} to write the request to
        * @throws IOException when i/o errors occur reading the response
  @@ -1861,25 +1861,25 @@
   
       /**
        * Write the request body to the given {@link HttpConnection}.
  -     * 
  +     *
        * <p>
        * If an expectation is required, this method should ensure that it has
        * been sent by checking the {@link #getStatusCode status code}.
        * </p>
  -     * 
  +     *
        * <p>
        * This method should return <tt>true</tt> if the request body was actually
        * sent (or is empty), or <tt>false</tt> if it could not be sent for some
        * reason (for example, expectation required but not present).
        * </p>
  -     * 
  +     *
        * <p>
        * This implementation writes nothing and returns <tt>true</tt>.
        * </p>
  -     * 
  +     *
        * @param state the client state
        * @param conn the connection to write to
  -     * 
  +     *
        * @return <tt>true</tt>
        * @throws IOException when i/o errors occur reading the response
        * @throws HttpException when a protocol error occurs or state is invalid
  @@ -1891,23 +1891,23 @@
   
       /**
        * Writes the request headers to the given {@link HttpConnection}.
  -     * 
  +     *
        * <p>
        * This implementation invokes {@link #addRequestHeaders
        * addRequestHeaders(HttpState,HttpConnection)}, and then writes each
        * header to the request stream.
        * </p>
  -     * 
  +     *
        * <p>
        * Subclasses may want to override this method to to customize the
        * processing.
        * </p>
  -     * 
  +     *
        * @param state the client state
        * @param conn the {@link HttpConnection} to write to
        * @throws IOException when i/o errors occur reading the response
        * @throws HttpException when a protocol error occurs or state is invalid
  -     * 
  +     *
        * @see #addRequestHeaders
        * @see #getRequestHeaders
        */
  @@ -1924,17 +1924,17 @@
   
       /**
        * Writes the "request line" to the given {@link HttpConnection}.
  -     * 
  +     *
        * <p>
        * Subclasses may want to override this method to to customize the
        * processing.
        * </p>
  -     * 
  +     *
        * @param state the client state
        * @param conn the {@link HttpConnection} to write to
        * @throws IOException when i/o errors occur reading the response
        * @throws HttpException when a protocol error occurs or state is invalid
  -     * 
  +     *
        * @see #generateRequestLine
        */
       protected void writeRequestLine(HttpState state, HttpConnection conn)
  @@ -1957,9 +1957,9 @@
   
       /**
        * Get the HTTP version.
  -     * 
  +     *
        * @return HTTP/1.1 if http11, HTTP/1.0 otherwise
  -     * 
  +     *
        * @since 2.0
        */
       private String getHttpVersion() {
  @@ -1968,9 +1968,9 @@
   
       /**
        * Determines if the provided value is a valid IPv4 internet address.
  -     * 
  +     *
        * @param value - value to check
  -     * 
  +     *
        * @return boolean - true if value is valid, otherwise false
        */
       private static boolean isIpAddress(String value) {
  @@ -2008,12 +2008,12 @@
        * "It must be possible to combine the multiple header fields into one
        * "field-name: field-value" pair, without changing the semantics of the
        * message, by appending each subsequent field-value to the first, each
  -     * separated by a comma." 
  +     * separated by a comma."
        * //TODO: This method is trying to make up for deficiencies in Header.
  -     * 
  +     *
        * @param existingHeader the current header
        * @param value DOCUMENT ME!
  -     * 
  +     *
        * @return DOCUMENT ME!
        */
       private String getNewHeaderValue(Header existingHeader, String value) {
  @@ -2030,9 +2030,9 @@
   
       /**
        * Sets the specified response header.
  -     * 
  +     *
        * @param header the header to set.
  -     * 
  +     *
        * @since 2.0
        */
       private void setResponseHeader(Header header) {
  @@ -2045,9 +2045,9 @@
       /**
        * Per RFC 2616 section 4.3, some response can never contain a message
        * body.
  -     * 
  +     *
        * @param status - the HTTP status code
  -     * 
  +     *
        * @return true if the message may contain a body, false if it can not
        *         contain a message body
        */
  @@ -2066,27 +2066,27 @@
   
       /**
        * Generates a key used for idenifying visited URLs.
  -     * 
  +     *
        * @param conn DOCUMENT ME!
  -     * 
  +     *
        * @return DOCUMENT ME!
        */
       private String generateVisitedKey(HttpConnection conn) {
           return conn.getHost() + ":" + conn.getPort() + "|"
  -               + generateRequestLine(conn, getName(), getPath(), 
  +               + generateRequestLine(conn, getName(), getPath(),
                                        getQueryString(), getHttpVersion());
       }
   
       /**
        * process a response that requires authentication
  -     * 
  +     *
        * @param state the current state
        * @param connection the connection for communication
  -     * 
  +     *
        * @return true if the request has completed process, false if more
        *         attempts are needed
        */
  -    private boolean processAuthenticationResponse(HttpState state, 
  +    private boolean processAuthenticationResponse(HttpState state,
                                                     HttpConnection connection) {
           log.trace("enter HttpMethodBase.processAuthenticationResponse("
               + "HttpState, HttpConnection)");
  @@ -2129,7 +2129,7 @@
                           break;
                       case HttpStatus.SC_PROXY_AUTHENTICATION_REQUIRED:
                           removeRequestHeader(Authenticator.PROXY_AUTH_RESP);
  -                        authenticated = Authenticator.authenticateProxy(this, 
  +                        authenticated = Authenticator.authenticateProxy(this,
                                                                           state);
                           break;
                   }
  @@ -2162,19 +2162,19 @@
        * be retried {@link #maxRetries} times if the operation fails with a
        * HttpRecoverableException. The write will only be attempted if the read
        * has succeeded.
  -     * 
  +     *
        * <p>
        * The <i>used</i> is set to true if the write succeeds.
        * </p>
  -     * 
  +     *
        * @param state the current state
        * @param connection the connection for communication
  -     * 
  +     *
        * @throws HttpException when errors occur as part of the HTTP protocol
        *         conversation
        * @throws IOException when an I/O error occurs communicating with the
        *         server
  -     * 
  +     *
        * @see writeRequest(HttpState,HttpConnection)
        * @see readResponse(HttpState,HttpConnection)
        */
  @@ -2232,16 +2232,16 @@
       /**
        * On a {@link HttpStatus#SC_CONTINUE continue}, if there are more request
        * bytes to be sent, write them to the connection
  -     * 
  +     *
        * @param state the current state
        * @param connection the connection for communication
  -     * 
  +     *
        * @throws HttpException when errors occur as part of the HTTP protocol
        *         conversation
        * @throws IOException when an I/O error occurs communicating with the
        *         server
        */
  -    private void writeRemainingRequestBody(HttpState state, 
  +    private void writeRemainingRequestBody(HttpState state,
                                              HttpConnection connection)
       throws HttpException, IOException {
           log.trace("enter writeRemainingRequestBody(HttpState, HttpConnection)");
  
  
  
  1.6       +5 -4      jakarta-commons/httpclient/src/test/org/apache/commons/httpclient/TestLocalHost.java
  
  Index: TestLocalHost.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/httpclient/src/test/org/apache/commons/httpclient/TestLocalHost.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- TestLocalHost.java	3 Dec 2002 05:46:16 -0000	1.5
  +++ TestLocalHost.java	3 Dec 2002 15:28:18 -0000	1.6
  @@ -85,6 +85,7 @@
           suite.addTest(TestMethodsLocalHost.suite());
           suite.addTest(TestGetMethodLocal.suite());
           suite.addTest(TestTraceMethodLocal.suite());
  +        suite.addTest(TestHttpConnectionManager.suite());
           suite.addTest(TestWebapp.suite());
           return suite;
       }
  
  
  
  1.16      +4 -5      jakarta-commons/httpclient/src/test/org/apache/commons/httpclient/TestNoHost.java
  
  Index: TestNoHost.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/httpclient/src/test/org/apache/commons/httpclient/TestNoHost.java,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- TestNoHost.java	31 Oct 2002 07:45:35 -0000	1.15
  +++ TestNoHost.java	3 Dec 2002 15:28:18 -0000	1.16
  @@ -91,7 +91,6 @@
           suite.addTest(TestAuthenticator.suite());
           suite.addTest(TestHttpClientNoHost.suite());
           suite.addTest(TestHttpUrlMethod.suite());
  -        suite.addTest(TestHttpConnectionManager.suite());
           suite.addTest(TestURIUtil.suite());
           suite.addTest(TestURIUtil2.suite());
           suite.addTest(TestMethodsNoHost.suite());
  
  
  

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