commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject cvs commit: jakarta-commons/httpclient/src/test/org/apache/commons/httpclient TestHttpConnectionManager.java TestWebappCookie.java TestWebappMethods.java
Date Sun, 15 Feb 2004 13:30:55 GMT
olegk       2004/02/15 05:30:55

  Modified:    httpclient/src/java/org/apache/commons/httpclient
                        HttpMethod.java HttpMethodBase.java
               httpclient/src/test/org/apache/commons/httpclient
                        TestHttpConnectionManager.java
                        TestWebappCookie.java TestWebappMethods.java
  Log:
  PR #26060 (Log level for message should be debug instead of error)
  
  HttpMethod#getResponseBody & HttpMethod#getResponseBodyAsString changed to
  propagate IOException to the caller instead of logging and discarding it. The patch breaks
2.0 API compatibility.
  
  Contributed by Oleg Kalnichevski
  
  Revision  Changes    Path
  1.33      +10 -6     jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/HttpMethod.java
  
  Index: HttpMethod.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/HttpMethod.java,v
  retrieving revision 1.32
  retrieving revision 1.33
  diff -u -r1.32 -r1.33
  --- HttpMethod.java	19 Nov 2003 21:11:16 -0000	1.32
  +++ HttpMethod.java	15 Feb 2004 13:30:55 -0000	1.33
  @@ -398,8 +398,10 @@
        * 
        * @return The response body, or <code>null</code> if the
        *         body is not available.
  +     * 
  +     * @throws IOException if an I/O (transport) problem occurs
        */
  -    byte[] getResponseBody();
  +    byte[] getResponseBody() throws IOException;
   
       /**
        * Returns the response body of the HTTP method, if any, as a {@link String}. 
  @@ -413,8 +415,10 @@
        *
        * @return The response body converted to a <code>String</code>, or <code>null</code>
        *         if the body is not available.
  +     * 
  +     * @throws IOException if an I/O (transport) problem occurs
        */
  -    String getResponseBodyAsString();
  +    String getResponseBodyAsString() throws IOException;
   
       /**
        * Returns the response body of the HTTP method, if any, as an InputStream.
  
  
  
  1.198     +23 -22    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.197
  retrieving revision 1.198
  diff -u -r1.197 -r1.198
  --- HttpMethodBase.java	14 Jan 2004 20:48:43 -0000	1.197
  +++ HttpMethodBase.java	15 Feb 2004 13:30:55 -0000	1.198
  @@ -672,26 +672,24 @@
        * If response body is not available or cannot be read, returns <tt>null</tt>
        * 
        * @return The response body.
  +     * 
  +     * @throws IOException If an I/O (transport) problem occurs while obtaining the 
  +     * response body.
        */
  -    public byte[] getResponseBody() {
  +    public byte[] getResponseBody() throws IOException {
           if (this.responseBody == null) {
  -            try {
  -                InputStream instream = getResponseBodyAsStream();
  -                if (instream != null) {
  -                    LOG.debug("Buffering response body");
  -                    ByteArrayOutputStream outstream = new ByteArrayOutputStream();
  -                    byte[] buffer = new byte[4096];
  -                    int len;
  -                    while ((len = instream.read(buffer)) > 0) {
  -                        outstream.write(buffer, 0, len);
  -                    }
  -                    outstream.close();
  -                    setResponseStream(null);
  -                    this.responseBody = outstream.toByteArray();
  +            InputStream instream = getResponseBodyAsStream();
  +            if (instream != null) {
  +                LOG.debug("Buffering response body");
  +                ByteArrayOutputStream outstream = new ByteArrayOutputStream();
  +                byte[] buffer = new byte[4096];
  +                int len;
  +                while ((len = instream.read(buffer)) > 0) {
  +                    outstream.write(buffer, 0, len);
                   }
  -            } catch (IOException e) {
  -                LOG.error("I/O failure reading response body", e);
  -                this.responseBody = null;
  +                outstream.close();
  +                setResponseStream(null);
  +                this.responseBody = outstream.toByteArray();
               }
           }
           return this.responseBody;
  @@ -725,8 +723,11 @@
        * in <tt>Content-Type</tt> header.
        *
        * @return The response body.
  +     * 
  +     * @throws IOException If an I/O (transport) problem occurs while obtaining the 
  +     * response body.
        */
  -    public String getResponseBodyAsString() {
  +    public String getResponseBodyAsString() throws IOException {
           byte[] rawdata = null;
           if (responseAvailable()) {
               rawdata = getResponseBody();
  
  
  
  1.17      +6 -6      jakarta-commons/httpclient/src/test/org/apache/commons/httpclient/TestHttpConnectionManager.java
  
  Index: TestHttpConnectionManager.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/httpclient/src/test/org/apache/commons/httpclient/TestHttpConnectionManager.java,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- TestHttpConnectionManager.java	12 Jan 2004 23:03:12 -0000	1.16
  +++ TestHttpConnectionManager.java	15 Feb 2004 13:30:55 -0000	1.17
  @@ -109,7 +109,7 @@
        * Test that the ConnectMethod correctly releases connections when
        * CONNECT fails.
        */
  -    public void testConnectMethodFailureRelease() {
  +    public void testConnectMethodFailureRelease() throws Exception {
           
           MultiThreadedHttpConnectionManager mgr = new MultiThreadedHttpConnectionManager();
           mgr.getParams().setIntParameter(
  @@ -331,7 +331,7 @@
        * Makes sure that a connection gets released after the content of the body
        * is read.
        */
  -    public void testResponseAutoRelease() {
  +    public void testResponseAutoRelease() throws Exception  {
   
           MultiThreadedHttpConnectionManager connectionManager = new MultiThreadedHttpConnectionManager();
           connectionManager.getParams().setIntParameter(
  
  
  
  1.14      +5 -5      jakarta-commons/httpclient/src/test/org/apache/commons/httpclient/TestWebappCookie.java
  
  Index: TestWebappCookie.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/httpclient/src/test/org/apache/commons/httpclient/TestWebappCookie.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- TestWebappCookie.java	20 Oct 2003 22:17:12 -0000	1.13
  +++ TestWebappCookie.java	15 Feb 2004 13:30:55 -0000	1.14
  @@ -711,7 +711,7 @@
       }
       
       
  -    public void testCookiePolicies() {
  +    public void testCookiePolicies() throws Exception  {
           HttpClient client = createHttpClient();
   
   
  
  
  
  1.20      +6 -6      jakarta-commons/httpclient/src/test/org/apache/commons/httpclient/TestWebappMethods.java
  
  Index: TestWebappMethods.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/httpclient/src/test/org/apache/commons/httpclient/TestWebappMethods.java,v
  retrieving revision 1.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- TestWebappMethods.java	13 Jan 2004 18:47:27 -0000	1.19
  +++ TestWebappMethods.java	15 Feb 2004 13:30:55 -0000	1.20
  @@ -359,7 +359,7 @@
       }
   
   
  -    public void testPostBodyChunked() {
  +    public void testPostBodyChunked() throws Exception  {
           HttpClient client = createHttpClient();
           PostMethod method = new PostMethod("/" + getWebappContext() + "/body");
           
  @@ -392,7 +392,7 @@
       }
   
   
  -    public void testPostMethodRecycle() {
  +    public void testPostMethodRecycle() throws Exception {
           HttpClient client = createHttpClient();
           PostMethod method = new PostMethod("/" + getWebappContext() + "/body");
           
  
  
  

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