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/java/org/apache/commons/httpclient HttpMethodBase.java
Date Thu, 19 Dec 2002 10:33:39 GMT
oglueck     2002/12/19 02:33:39

  Modified:    httpclient/src/java/org/apache/commons/httpclient
                        HttpMethodBase.java
  Log:
  Fixed exception when socket closes unexpectedly during response processing.
  Automatic retry instead.
  
  Reported by: Jack Adam
  
  Revision  Changes    Path
  1.92      +39 -36    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.91
  retrieving revision 1.92
  diff -u -r1.91 -r1.92
  --- HttpMethodBase.java	19 Dec 2002 10:23:35 -0000	1.91
  +++ HttpMethodBase.java	19 Dec 2002 10:33:38 -0000	1.92
  @@ -271,34 +271,34 @@
        * @param uri either an absolute or relative URI
        */
       public HttpMethodBase(String uri) {
  -        
  +
           try {
               // is this an absolute URI?
               URL url = new URL( uri );
  -            
  +
               // set the path, defaulting to root
  -            setPath( 
  +            setPath(
                   url.getPath() == null
                   ? "/"
                   : url.getPath()
               );
               setQueryString( url.getQuery() );
               hostConfiguration = new HostConfiguration();
  -            hostConfiguration.setHost( 
  -                url.getHost(), 
  -                url.getPort(), 
  -                url.getProtocol() 
  +            hostConfiguration.setHost(
  +                url.getHost(),
  +                url.getPort(),
  +                url.getProtocol()
               );
  -            
  +
           } catch ( MalformedURLException e ) {
               // this is not a URL
               int pa = uri.indexOf("?");
  -            
  +
               if ( !uri.startsWith("/") ) {
                   // this path must be relative to root
                   uri = "/" + uri;
               }
  -            
  +
               if (pa < 0) { //its just a path
                   setPath(uri);
               } else { //its a path with a query
  @@ -306,7 +306,7 @@
                   setQueryString(uri.substring(pa+1, uri.length()));
               }
           }
  -        
  +
       }
   
       //~ Methods ииииииииииииииииииииииииииииииииииииииииииииииииииииииииииииииии
  @@ -325,19 +325,19 @@
        * @see org.apache.commons.httpclient.HttpMethod#getURI()
        */
       public URI getURI() throws URIException {
  -        
  +
           if ( hostConfiguration == null ) {
               // just use a relative URI, the host hasn't been set
               return new URI( null, null, path, queryString, null );
           } else {
  -            
  +
               // we only want to include the port if it's not the default
               int port = hostConfiguration.getPort();
               if ( port == hostConfiguration.getProtocol().getDefaultPort() ) {
                   port = -1;
               }
  -            
  -            return new URI( 
  +
  +            return new URI(
                   hostConfiguration.getProtocol().getScheme(),
                   null,
                   hostConfiguration.getHost(),
  @@ -346,7 +346,7 @@
                   queryString
               );
           }
  -        
  +
       }
   
       /**
  @@ -1285,7 +1285,7 @@
             state.getCookies());
           if ((cookies != null) && (cookies.length > 0))
           {
  -        	setRequestHeader(matcher.formatCookieHeader(cookies));
  +            setRequestHeader(matcher.formatCookieHeader(cookies));
           }
       }
   
  @@ -1334,7 +1334,7 @@
           if ( conn.getProtocol().getDefaultPort() != port ) {
               host += (":" + port);
           }
  -            
  +
           setRequestHeader("Host", host);
       }
   
  @@ -1567,18 +1567,18 @@
   
               CookieSpec parser = CookiePolicy.getDefaultSpec();
               Cookie[] cookies = parser.parse(
  -              conn.getHost(), 
  +              conn.getHost(),
                 conn.getPort(),
  -              getPath(), 
  +              getPath(),
                 conn.isSecure(),
                 setCookieHeader);
               for (int i = 0; i < cookies.length; i++)
               {
                   Cookie cookie = cookies[i];
                   parser.validate(
  -                  conn.getHost(), 
  +                  conn.getHost(),
                     conn.getPort(),
  -                  getPath(), 
  +                  getPath(),
                     conn.isSecure(),
                     cookie);
                   if (log.isDebugEnabled()) {
  @@ -1586,7 +1586,7 @@
                   }
                   state.addCookie(cookie);
               }
  -              
  +
           } catch (HttpException e) {
               if (log.isWarnEnabled()) {
                   log.warn("Cookie rejected: \"" + setCookieHeader.getValue() + "\". " +
e.getMessage());
  @@ -1658,19 +1658,22 @@
        *
        * @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
  +     * @throws HttpException when a protocol or i/o error occurs or state is invalid
        */
       protected void readResponse(HttpState state, HttpConnection conn)
  -    throws IOException, HttpException {
  +    throws HttpException {
           log.trace(
               "enter HttpMethodBase.readResponse(HttpState, HttpConnection)");
  -        readStatusLine(state, conn);
  -        processStatusLine(state, conn);
  -        readResponseHeaders(state, conn);
  -        processResponseHeaders(state, conn);
  -        readResponseBody(state, conn);
  -        processResponseBody(state, conn);
  +        try {
  +            readStatusLine(state, conn);
  +            processStatusLine(state, conn);
  +            readResponseHeaders(state, conn);
  +            processResponseHeaders(state, conn);
  +            readResponseBody(state, conn);
  +            processResponseBody(state, conn);
  +        } catch(IOException e) {
  +            throw new HttpRecoverableException(e.toString());
  +        }
       }
   
       /**
  
  
  

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