commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jsde...@apache.org
Subject cvs commit: jakarta-commons/httpclient/src/java/org/apache/commons/httpclient HttpMethodBase.java
Date Tue, 03 Sep 2002 11:19:35 GMT
jsdever     2002/09/03 04:19:35

  Modified:    httpclient/src/java/org/apache/commons/httpclient
                        HttpMethodBase.java
  Log:
  Final fixups for Ortwin Gluck's responseStream patch.
  
  Revision  Changes    Path
  1.55      +5 -94     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.54
  retrieving revision 1.55
  diff -u -r1.54 -r1.55
  --- HttpMethodBase.java	3 Sep 2002 01:36:26 -0000	1.54
  +++ HttpMethodBase.java	3 Sep 2002 11:19:35 -0000	1.55
  @@ -220,7 +220,7 @@
       private boolean http11 = true;
   
       /** True if we're in strict mode. */
  -    private boolean strictMode = true;
  +    private boolean strictMode = false;
   
       /** Whether or not I have been executed. */
       private boolean used = false;
  @@ -1407,95 +1407,6 @@
               "enter HttpMethodBase.readResponseBody(HttpState, HttpConnection)");
   
           setResponseStream(_readResponseBody(state, conn));
  -    }
  -
  -    /**
  -     * 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
  -     * @param out OutputStream to write the response body to
  -     * @throws IOException when i/o errors occur reading the response
  -     *
  -     * @see #readResponse
  -     * @see #processResponseBody
  -     */
  -    protected void readResponseBody(HttpState state, HttpConnection conn, 
  -                                    OutputStream out)
  -    throws IOException {
  -        log.trace(
  -            "enter HttpMethodBase.readResponseBody(HttpState, HttpConnection, OutputStream)");
  -        responseBody = null;
  -        int expectedLength = 0;
  -        int foundLength = 0;
  -        {
  -            Header lengthHeader = getResponseHeader("Content-Length");
  -            Header transferEncodingHeader = getResponseHeader(
  -                                                "Transfer-Encoding");
  -            if (null != lengthHeader) {
  -                try {
  -                    expectedLength = Integer.parseInt(lengthHeader.getValue());
  -                } catch (NumberFormatException e) {
  -                    // ignored
  -                }
  -            } else if (null != transferEncodingHeader) {
  -                if ("chunked".equalsIgnoreCase(
  -                        transferEncodingHeader.getValue())) {
  -                    expectedLength = -1;
  -                }
  -            } else if (canResponseHaveBody(statusCode)
  -                       && !getName().equals(ConnectMethod.NAME)) {
  -                /*
  -                 * According to the specification, a response with neither 
  -                 * Content-Length nor Transfer-Encoding indicates that the 
  -                 * response has no body.  In the real world, this usually means
  -                 * that the server just didn't know the content-length when it
  -                 * sent the response.
  -                 * FIXME:  Should we do this only in non-strict mode?
  -                 * If we do this we will hang forever waiting for a body!
  -                 */
  -                expectedLength = -1;
  -            }
  -        }
  -        InputStream is = conn.getResponseInputStream(this);
  -        byte[] buffer = new byte[4096];
  -        int nb = 0;
  -        while ((expectedLength == -1) || (foundLength < expectedLength)) {
  -            nb = is.read(buffer);
  -            if (nb == -1) {
  -                break;
  -            }
  -            if (out == null) {
  -                throw new IOException("Unable to buffer data");
  -            }
  -            if (wireLog.isDebugEnabled()) {
  -                wireLog.debug("<< \"" + new String(buffer, 0, nb) + "\"");
  -            }
  -            out.write(buffer, 0, nb);
  -            foundLength += nb;
  -            if (expectedLength > -1) {
  -                if (foundLength == expectedLength) {
  -                    break;
  -                } else if (foundLength > expectedLength) {
  -                    log.warn(
  -                        "HttpMethodBase.readResponseBody(): expected length ("
  -                        + expectedLength + ") exceeded.  Found " + foundLength
  -                        + " bytes.");
  -                    break;
  -                }
  -            }
  -        }
       }
   
       /**
  
  
  

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