commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From di...@apache.org
Subject cvs commit: jakarta-commons/latka/src/java/org/apache/commons/latka/http MethodFactory.java RequestImpl.java ResponseImpl.java
Date Sat, 06 Mar 2004 12:46:52 GMT
dirkv       2004/03/06 04:46:52

  Modified:    latka/src/java/org/apache/commons/latka/http
                        MethodFactory.java RequestImpl.java
                        ResponseImpl.java
  Log:
  fix gump build (httpclient changes)
  - setUseDisk
  - startSession, endSession
  - getResponseBody throws exception
  
  Revision  Changes    Path
  1.4       +0 -2      jakarta-commons/latka/src/java/org/apache/commons/latka/http/MethodFactory.java
  
  Index: MethodFactory.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/latka/src/java/org/apache/commons/latka/http/MethodFactory.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- MethodFactory.java	28 Feb 2004 13:48:19 -0000	1.3
  +++ MethodFactory.java	6 Mar 2004 12:46:52 -0000	1.4
  @@ -48,11 +48,9 @@
           switch (method) {
               case Request.HTTP_METHOD_GET:
                   httpMethod = new GetMethod(url.getPath());
  -                ((GetMethod) httpMethod).setUseDisk(false);
                   break;
               case Request.HTTP_METHOD_POST:
                   httpMethod = new PostMethod(url.getPath());
  -                ((PostMethod) httpMethod).setUseDisk(false);
                   break;
               case Request.HTTP_METHOD_HEAD:
                   httpMethod = new HeadMethod(url.getPath());
  
  
  
  1.41      +7 -9      jakarta-commons/latka/src/java/org/apache/commons/latka/http/RequestImpl.java
  
  Index: RequestImpl.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/latka/src/java/org/apache/commons/latka/http/RequestImpl.java,v
  retrieving revision 1.40
  retrieving revision 1.41
  diff -u -r1.40 -r1.41
  --- RequestImpl.java	28 Feb 2004 13:48:19 -0000	1.40
  +++ RequestImpl.java	6 Mar 2004 12:46:52 -0000	1.41
  @@ -23,6 +23,7 @@
   import java.util.List;
   import java.util.LinkedList;
   // latka imports
  +import org.apache.commons.httpclient.HostConfiguration;
   import org.apache.commons.httpclient.UsernamePasswordCredentials;
   import org.apache.commons.httpclient.HttpClient;
   import org.apache.commons.httpclient.HttpException;
  @@ -470,16 +471,13 @@
           _host = host;
           _port = port;
           
  -        if (getProxy() == null) {
  -            // start session
  -            _httpClient.startSession(host, port, port == HTTPS_PORT);
  -        } else {
  -            _httpClient.startSession(host, port, getProxy().getHost(),
  -                getProxy().getPort());
  +        HostConfiguration hostConfiguration = _httpClient.getHostConfiguration();
  +        hostConfiguration.setHost(host, port, protocol);
  +        if (getProxy() != null) {
  +            hostConfiguration.setProxy(getProxy().getHost(), getProxy().getPort());
           }
           
           _log.debug("connection open");
  -        
       }
       
       /**
  @@ -488,7 +486,7 @@
        */
       protected void closeConnection() throws IOException {
           _log.debug("closing connection");
  -        _httpClient.endSession();
  +        _httpMethod.releaseConnection();
           _log.debug("connection closed");
       }
       
  
  
  
  1.22      +12 -4     jakarta-commons/latka/src/java/org/apache/commons/latka/http/ResponseImpl.java
  
  Index: ResponseImpl.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/latka/src/java/org/apache/commons/latka/http/ResponseImpl.java,v
  retrieving revision 1.21
  retrieving revision 1.22
  diff -u -r1.21 -r1.22
  --- ResponseImpl.java	28 Feb 2004 13:48:19 -0000	1.21
  +++ ResponseImpl.java	6 Mar 2004 12:46:52 -0000	1.22
  @@ -83,7 +83,11 @@
        *         or null if there was no response body
        */
       public String getResource() {
  -        return _httpMethod.getResponseBodyAsString();
  +        try {
  +            return _httpMethod.getResponseBodyAsString();
  +        } catch (Exception e) {
  +            return null;
  +        }
       }
   
       /**
  @@ -110,12 +114,16 @@
        * @return Byte length of the response stream
        */
       public int getByteLength() {
  -        byte[] responseBytes = _httpMethod.getResponseBody();
  +        byte[] responseBytes = null;
  +        try {
  +            responseBytes = _httpMethod.getResponseBody();
  +        } catch (Exception e) {
  +        }
           if (responseBytes == null) {
               return -1;
           }
   
  -        return _httpMethod.getResponseBody().length;
  +        return responseBytes.length;
       }
   
       /**
  
  
  

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


Mime
View raw message