I hope it works this time around Oleg
On Thu, 2003-02-13 at 07:30, Jeffrey Dever wrote: > Haven't had time to review all of this, but I am a bit concerned over > any performance issues and buffering. The wirelog is a good thing, but > there are other ways of getting a request/response log. I wouldnot like > to see it excessively effect performance or resident set size, or add > too much complexity. > > Also I find that the wirelog output conforms to the 10%/90% rule where > 90% of its troubleshooting value comes from 10% of its output, namely > the headers and request/response status lines. The applications I have > written based on HttpClient would never enable the wirelog because the > output was too large (and could contain offensive binary data), so I > would just never enable it and use the applications logging system and > my own methods to write out the headers. This should be a better > service provided by HttpClient. > > We could just read/buffer/process/log headers in one shot in one logger, > and handle the body logging seperately. The header logs might be part > of the normal operation of some applications where the body log would > only be used for headscratching debugging. That might help a little bit > with the seperation of concerns that we are grappling here. > > Jandalf. > > > Michael Becke wrote: > > > Well after looking at this further it seems one problem with this is > > that bytes get written one at a time to the input WireLog. I made a > > few changes in HttpConnection and WireLogInputStream that pose a > > possible solution. This version of the InputStream buffers content > > until a "\r\n" is read or until a certain number of bytes are read. > > This way wire log will always work even if content is read using the > > socket input stream. Take a look. These are just some other ideas. > > > > Mike > > > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] >
Index: java/org/apache/commons/httpclient/ChunkedOutputStream.java =================================================================== RCS file: /home/cvspublic/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/ChunkedOutputStream.java,v retrieving revision 1.8 diff -u -r1.8 ChunkedOutputStream.java --- java/org/apache/commons/httpclient/ChunkedOutputStream.java 8 Feb 2003 19:22:49 -0000 1.8 +++ java/org/apache/commons/httpclient/ChunkedOutputStream.java 23 Feb 2003 21:31:47 -0000 @@ -103,9 +103,6 @@ /** Log object for this class. */ private static final Log LOG = LogFactory.getLog(ChunkedOutputStream.class); - /** Log for any wire messages. */ - private static final Log WIRE_LOG = LogFactory.getLog("httpclient.wire"); - // ----------------------------------------------------- Instance Variables /** Has this stream been closed? */ @@ -190,10 +187,7 @@ stream.write(CRLF, 0, CRLF.length); stream.write(b); stream.write(ENDCHUNK, 0, ENDCHUNK.length); - if (WIRE_LOG.isDebugEnabled()) { - WIRE_LOG.debug(">> byte 1 \\r\\n (chunk length \"header\")"); - WIRE_LOG.debug(">> byte " + b + "\\r\\n (chunked byte)"); - } + LOG.debug("Writing chunk (length: 1)"); } /** @@ -215,11 +209,8 @@ stream.write(chunkHeader, 0, chunkHeader.length); stream.write(b, off, len); stream.write(ENDCHUNK, 0, ENDCHUNK.length); - if (WIRE_LOG.isDebugEnabled()) { - WIRE_LOG.debug(">> byte(s)" + len + " \\r\\n (chunk length " - + "\"header\")"); - WIRE_LOG.debug(">> \"" + new String(b, off, len) - + "\"\\r\\n (chunked bytes)"); + if (LOG.isDebugEnabled()) { + LOG.debug("Writing chunk (length: " + len + ")"); } } @@ -239,7 +230,7 @@ stream.write(ZERO, 0, ZERO.length); stream.write(CRLF, 0, CRLF.length); stream.write(ENDCHUNK, 0, ENDCHUNK.length); - WIRE_LOG.debug(">> byte 0 \\r\\n\\r\\n (final chunk)"); + LOG.debug("Writing closing chunk"); } catch (IOException e) { LOG.debug("Unexpected exception caught when closing " + "output stream", e); Index: java/org/apache/commons/httpclient/HttpConnection.java =================================================================== RCS file: /home/cvspublic/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/HttpConnection.java,v retrieving revision 1.45 diff -u -r1.45 HttpConnection.java --- java/org/apache/commons/httpclient/HttpConnection.java 16 Feb 2003 13:08:32 -0000 1.45 +++ java/org/apache/commons/httpclient/HttpConnection.java 23 Feb 2003 21:31:47 -0000 @@ -1,5 +1,5 @@ /* - * $Header: /home/cvspublic/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/HttpConnection.java,v 1.45 2003/02/16 13:08:32 olegk Exp $ + * $Header: /home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/HttpConnection.java,v 1.45 2003/02/16 13:08:32 olegk Exp $ * $Revision: 1.45 $ * $Date: 2003/02/16 13:08:32 $ * @@ -745,10 +745,6 @@ assertOpen(); - if (WIRE_LOG.isDebugEnabled()) { - String dataString = new String(data, offset, length, "ISO-8859-1"); - WIRE_LOG.debug(">> \"" + dataString + "\" [\\r\\n]"); - } try { outputStream.write(data, offset, length); } catch (SocketException se) { @@ -776,10 +772,7 @@ LOG.trace("enter HttpConnection.writeLine(byte[])"); assertOpen(); - if (WIRE_LOG.isDebugEnabled() && (data.length > 0)) { - String dataString = HttpConstants.getContentString(data); - WIRE_LOG.debug(">> \"" + dataString.trim() + "\" [\\r\\n]"); - } + try { outputStream.write(data); writeLine(); @@ -804,7 +797,6 @@ throws IOException, IllegalStateException, HttpRecoverableException { LOG.trace("enter HttpConnection.writeLine()"); - WIRE_LOG.debug(">> [\\r\\n]"); try { outputStream.write(CRLF); } catch (SocketException se) { @@ -1060,9 +1052,6 @@ /** Log object for this class. */ private static final Log LOG = LogFactory.getLog(HttpConnection.class); - - /** Log for any wire messages. */ - private static final Log WIRE_LOG = LogFactory.getLog("httpclient.wire"); // ----------------------------------------------------- Instance Variables /** My host. */ Index: java/org/apache/commons/httpclient/HttpMethodBase.java =================================================================== RCS file: /home/cvspublic/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/HttpMethodBase.java,v retrieving revision 1.115 diff -u -r1.115 HttpMethodBase.java --- java/org/apache/commons/httpclient/HttpMethodBase.java 21 Feb 2003 13:48:09 -0000 1.115 +++ java/org/apache/commons/httpclient/HttpMethodBase.java 23 Feb 2003 21:31:53 -0000 @@ -147,9 +147,6 @@ /** Log object for this class. */ private static final Log LOG = LogFactory.getLog(HttpMethod.class); - /** Log for any wire messages. */ - private static final Log WIRE_LOG = LogFactory.getLog("httpclient.wire"); - /** The User-Agent header sent on every request. */ protected static final Header USER_AGENT; @@ -665,7 +662,7 @@ try { ByteArrayOutputStream os = new ByteArrayOutputStream(); InputStream is = getResponseBodyAsStream(); - byte[] buffer = new byte[10000]; + byte[] buffer = new byte[4096]; int len; while ((len = is.read(buffer)) > 0) { os.write(buffer, 0, len); @@ -1799,8 +1796,8 @@ Header lengthHeader = getResponseHeader("Content-Length"); Header transferEncodingHeader = getResponseHeader("Transfer-Encoding"); InputStream is = conn.getResponseInputStream(); - if (WIRE_LOG.isDebugEnabled()) { - is = new WireLogInputStream(is); + if (Wire.enabled()) { + is = new WireLogInputStream(is, "US-ASCII"); } InputStream result = null; // We use Transfer-Encoding if present and ignore Content-Length. @@ -1885,6 +1882,11 @@ getResponseHeaderGroup().clear(); Header[] headers = HttpParser.parseHeaders(conn.getResponseInputStream()); + if (Wire.enabled()) { + for (int i = 0; i < headers.length; i++) { + Wire.input(headers[i].toExternalForm()); + } + } getResponseHeaderGroup().setHeaders(headers); } @@ -1926,7 +1928,9 @@ + " line from the response: unable to find line starting with" + " \"HTTP/\""); } - + if (Wire.enabled()) { + Wire.input(statusString); + } //create the status line from the status string statusLine = new StatusLine(statusString); @@ -1990,6 +1994,9 @@ writeRequestLine(state, conn); writeRequestHeaders(state, conn); conn.writeLine(); // close head + if (Wire.enabled()) { + Wire.output("\r\n"); + } bodySent = writeRequestBody(state, conn); } @@ -2053,7 +2060,11 @@ Header[] headers = getRequestHeaders(); for (int i = 0; i < headers.length; i++) { - conn.print(headers[i].toExternalForm()); + String s = headers[i].toExternalForm(); + if (Wire.enabled()) { + Wire.output(s); + } + conn.print(s); } } @@ -2077,6 +2088,9 @@ LOG.trace( "enter HttpMethodBase.writeRequestLine(HttpState, HttpConnection)"); String requestLine = getRequestLine(conn); + if (Wire.enabled()) { + Wire.output(requestLine); + } conn.print(requestLine); } Index: java/org/apache/commons/httpclient/HttpParser.java =================================================================== RCS file: /home/cvspublic/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/HttpParser.java,v retrieving revision 1.2 diff -u -r1.2 HttpParser.java --- java/org/apache/commons/httpclient/HttpParser.java 20 Feb 2003 16:36:20 -0000 1.2 +++ java/org/apache/commons/httpclient/HttpParser.java 23 Feb 2003 21:31:48 -0000 @@ -21,8 +21,6 @@ /** Log object for this class. */ private static final Log LOG = LogFactory.getLog(HttpParser.class); - /** Log for any wire messages. */ - private static final Log WIRE_LOG = LogFactory.getLog("httpclient.wire"); /** * Constructor for HttpParser. */ @@ -57,9 +55,6 @@ break; } } - } - if (WIRE_LOG.isDebugEnabled()) { - WIRE_LOG.debug("<< \"" + buf.toString() + (ch>0 ? "\" [\\r\\n]" : "")); } if (buf.size() == 0) { return null; Index: java/org/apache/commons/httpclient/Wire.java =================================================================== RCS file: java/org/apache/commons/httpclient/Wire.java diff -N java/org/apache/commons/httpclient/Wire.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ java/org/apache/commons/httpclient/Wire.java 23 Feb 2003 21:31:48 -0000 @@ -0,0 +1,201 @@ +/* + * ==================================================================== + * + * The Apache Software License, Version 1.1 + * + * Copyright (c) 1999-2003 The Apache Software Foundation. All rights + * reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. The end-user documentation included with the redistribution, if + * any, must include the following acknowlegement: + * "This product includes software developed by the + * Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowlegement may appear in the software itself, + * if and wherever such third-party acknowlegements normally appear. + * + * 4. The names "The Jakarta Project", "Commons", and "Apache Software + * Foundation" must not be used to endorse or promote products derived + * from this software without prior written permission. For written + * permission, please contact [EMAIL PROTECTED] + * + * 5. Products derived from this software may not be called "Apache" + * nor may "Apache" appear in their names without prior written + * permission of the Apache Group. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * ==================================================================== + * + * This software consists of voluntary contributions made by many + * individuals on behalf of the Apache Software Foundation. For more + * information on the Apache Software Foundation, please see + * <http://www.apache.org/>. + * + * [Additional notices, if required by prior licensing conditions] + * + */ + +package org.apache.commons.httpclient; + +import java.io.IOException; +import java.io.InputStream; +import java.io.ByteArrayInputStream; +import java.io.Reader; +import java.io.InputStreamReader; +import java.io.BufferedReader; +import java.io.UnsupportedEncodingException; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +/** + * Logs data to the wire LOG. + * + * @author <a href="mailto:[EMAIL PROTECTED]">Oleg Kalnichevski</a> + * + * @since 2.0beta1 + */ + +public class Wire { + + /** Log for any wire messages. */ + private static final Log WIRE_LOG = LogFactory.getLog("httpclient.wire"); + + private static void wire(String header, InputStream instream, String charset) + throws IOException { + if (charset == null) { + charset = "US-ASCII"; + } + Reader reader = null; + try { + reader = new InputStreamReader(instream, charset); + } catch (UnsupportedEncodingException e) { + reader = new InputStreamReader(instream); + } + StringBuffer buffer = new StringBuffer(); + int ch; + while ((ch = reader.read()) != -1) { + if (ch == 13) { + buffer.append("[\\r]"); + } else if (ch == 10){ + buffer.append("[\\n]\""); + buffer.insert(0, "\""); + buffer.insert(0, header); + WIRE_LOG.debug(buffer.toString()); + buffer.setLength(0); + } else if ((ch < 32) || (ch > 127)) { + buffer.append("[0x"); + buffer.append(Integer.toHexString(ch)); + buffer.append("]"); + } else { + buffer.append((char)ch); + } + } + if (buffer.length() > 0) { + buffer.append("\""); + buffer.insert(0, "\""); + buffer.insert(0, header); + WIRE_LOG.debug(buffer.toString()); + } + } + + + public static final boolean enabled() { + return WIRE_LOG.isDebugEnabled(); + } + + public static final void output(InputStream outstream, String charset) + throws IOException { + if (outstream == null) { + throw new IllegalArgumentException("Output may not be null"); + } + wire(">> ", outstream, charset); + } + + public static final void input(InputStream instream, String charset) + throws IOException { + if (instream == null) { + throw new IllegalArgumentException("Input may not be null"); + } + wire("<< ", instream, charset); + } + + public static final void output(byte[] b, int off, int len, String charset) + throws IOException { + if (b == null) { + throw new IllegalArgumentException("Output may not be null"); + } + wire(">> ", new ByteArrayInputStream(b, off, len), charset); + } + + public static final void input(byte[] b, int off, int len, String charset) + throws IOException { + if (b == null) { + throw new IllegalArgumentException("Input may not be null"); + } + wire("<< ", new ByteArrayInputStream(b, off, len), charset); + } + + public static final void output(byte[] b, String charset) + throws IOException { + if (b == null) { + throw new IllegalArgumentException("Output may not be null"); + } + wire(">> ", new ByteArrayInputStream(b), charset); + } + + public static final void input(byte[] b, String charset) + throws IOException { + if (b == null) { + throw new IllegalArgumentException("Input may not be null"); + } + wire("<< ", new ByteArrayInputStream(b), charset); + } + + public static final void output(int b, String charset) + throws IOException { + output(new byte[] {(byte)b}, charset); + } + + public static final void input(int b, String charset) + throws IOException { + input(new byte[] {(byte)b}, charset); + } + + public static final void output(final String s) + throws IOException { + if (s == null) { + throw new IllegalArgumentException("Output may noy be null"); + } + output(s.getBytes(), null); + } + + public static final void input(final String s) + throws IOException { + if (s == null) { + throw new IllegalArgumentException("Input may noy be null"); + } + input(s.getBytes(), null); + } +} Index: java/org/apache/commons/httpclient/WireLogInputStream.java =================================================================== RCS file: /home/cvspublic/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/WireLogInputStream.java,v retrieving revision 1.8 diff -u -r1.8 WireLogInputStream.java --- java/org/apache/commons/httpclient/WireLogInputStream.java 31 Jan 2003 00:33:36 -0000 1.8 +++ java/org/apache/commons/httpclient/WireLogInputStream.java 23 Feb 2003 21:31:54 -0000 @@ -67,27 +67,38 @@ import java.io.IOException; import java.io.InputStream; import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; +import org.apache.commons.logging.LogFactory; /** * Logs all data read to the wire LOG. * * @author Ortwin GlО?╫ * @author <a href="mailto:[EMAIL PROTECTED]">Mike Bowler</a> + * @author <a href="mailto:[EMAIL PROTECTED]">Oleg Kalnichevski</a> * * @since 2.0 */ -class WireLogInputStream extends FilterInputStream { +public class WireLogInputStream extends FilterInputStream { + /** Log for any wire messages. */ private static final Log WIRE_LOG = LogFactory.getLog("httpclient.wire"); + /** Content encoding. */ + private String charset = "US-ASCII"; + + /** Original input stream. */ + private InputStream in; /** * Create an instance that wraps the specified input stream. * @param in The input stream. */ - public WireLogInputStream(InputStream in) { + public WireLogInputStream(InputStream in, String charset) { super(in); + if (charset != null) { + this.charset = charset; + } + this.in = in; } /** @@ -95,8 +106,10 @@ * @see java.io.InputStream#read(byte[], int, int) */ public int read(byte[] b, int off, int len) throws IOException { - int l = super.read(b, off, len); - WIRE_LOG.debug("<< " + new String(b, off, len)); + int l = this.in.read(b, off, len); + if (l > 0) { + Wire.input(b, off, l, null); + } return l; } @@ -105,9 +118,9 @@ * @see java.io.InputStream#read() */ public int read() throws IOException { - int l = super.read(); + int l = this.in.read(); if (l > 0) { - WIRE_LOG.debug("<< " + (char) l); + Wire.input(l, null); } return l; } @@ -117,8 +130,10 @@ * @see java.io.InputStream#read(byte[]) */ public int read(byte[] b) throws IOException { - int l = super.read(b); - WIRE_LOG.debug("<< " + HttpConstants.getString(b)); + int l = this.in.read(b); + if (l > 0) { + Wire.input(b, null); + } return l; } } Index: java/org/apache/commons/httpclient/WireLogOutputStream.java =================================================================== RCS file: java/org/apache/commons/httpclient/WireLogOutputStream.java diff -N java/org/apache/commons/httpclient/WireLogOutputStream.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ java/org/apache/commons/httpclient/WireLogOutputStream.java 23 Feb 2003 21:31:54 -0000 @@ -0,0 +1,131 @@ +/* + * ==================================================================== + * + * The Apache Software License, Version 1.1 + * + * Copyright (c) 1999-2003 The Apache Software Foundation. All rights + * reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. The end-user documentation included with the redistribution, if + * any, must include the following acknowlegement: + * "This product includes software developed by the + * Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowlegement may appear in the software itself, + * if and wherever such third-party acknowlegements normally appear. + * + * 4. The names "The Jakarta Project", "Commons", and "Apache Software + * Foundation" must not be used to endorse or promote products derived + * from this software without prior written permission. For written + * permission, please contact [EMAIL PROTECTED] + * + * 5. Products derived from this software may not be called "Apache" + * nor may "Apache" appear in their names without prior written + * permission of the Apache Group. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * ==================================================================== + * + * This software consists of voluntary contributions made by many + * individuals on behalf of the Apache Software Foundation. For more + * information on the Apache Software Foundation, please see + * <http://www.apache.org/>. + * + * [Additional notices, if required by prior licensing conditions] + * + */ + +package org.apache.commons.httpclient; + +import java.io.FilterOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.io.ByteArrayInputStream; +import java.io.Reader; +import java.io.InputStreamReader; +import java.io.BufferedReader; +import java.io.UnsupportedEncodingException; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +/** + * Logs all data written to the wire LOG. + * + * @author <a href="mailto:[EMAIL PROTECTED]">Oleg Kalnichevski</a> + * + * @since 2.0beta1 + */ + +public class WireLogOutputStream extends FilterOutputStream { + + /** Log for any wire messages. */ + private static final Log WIRE_LOG = LogFactory.getLog("httpclient.wire"); + + /** Content encoding. */ + private String charset = "US-ASCII"; + + /** Original input stream. */ + private OutputStream out; + + /** + * Create an instance that wraps the specified output stream. + * @param out The output stream. + */ + public WireLogOutputStream(OutputStream out, String charset) { + super(out); + if (charset != null) { + this.charset = charset; + } + this.out = out; + } + + /** + * + * @see java.io.OutputStream#write(byte[], int, int) + */ + public void write(byte[] b, int off, int len) throws IOException { + this.out.write(b, off, len); + Wire.output(b, off, len, this.charset); + } + + /** + * + * @see java.io.OutputStream#write() + */ + public void write(int b) throws IOException { + this.out.write(b); + Wire.output(b, this.charset); + } + + /** + * + * @see java.io.OutputStream#write(byte[]) + */ + public void write(byte[] b) throws IOException { + this.out.write(b); + Wire.output(b, this.charset); + } +} Index: java/org/apache/commons/httpclient/methods/EntityEnclosingMethod.java =================================================================== RCS file: /home/cvspublic/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/methods/EntityEnclosingMethod.java,v retrieving revision 1.9 diff -u -r1.9 EntityEnclosingMethod.java --- java/org/apache/commons/httpclient/methods/EntityEnclosingMethod.java 13 Feb 2003 21:31:53 -0000 1.9 +++ java/org/apache/commons/httpclient/methods/EntityEnclosingMethod.java 23 Feb 2003 21:31:55 -0000 @@ -80,6 +80,8 @@ import org.apache.commons.httpclient.Header; import org.apache.commons.httpclient.ChunkedOutputStream; import org.apache.commons.httpclient.ContentLengthInputStream; +import org.apache.commons.httpclient.Wire; +import org.apache.commons.httpclient.WireLogOutputStream; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -424,6 +426,11 @@ this.repeatCount++; OutputStream outstream = conn.getRequestOutputStream(); + + if (Wire.enabled()) { + outstream = new WireLogOutputStream(outstream, "US-ASCII"); + } + if (contentLength == CONTENT_LENGTH_CHUNKED) { outstream = new ChunkedOutputStream(outstream); } Index: java/org/apache/commons/httpclient/methods/MultipartPostMethod.java =================================================================== RCS file: /home/cvspublic/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/methods/MultipartPostMethod.java,v retrieving revision 1.10 diff -u -r1.10 MultipartPostMethod.java --- java/org/apache/commons/httpclient/methods/MultipartPostMethod.java 13 Feb 2003 21:31:53 -0000 1.10 +++ java/org/apache/commons/httpclient/methods/MultipartPostMethod.java 23 Feb 2003 21:31:56 -0000 @@ -77,6 +77,8 @@ import org.apache.commons.httpclient.methods.multipart.FilePart; import org.apache.commons.httpclient.methods.multipart.Part; import org.apache.commons.httpclient.methods.multipart.StringPart; +import org.apache.commons.httpclient.Wire; +import org.apache.commons.httpclient.WireLogOutputStream; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -286,8 +288,13 @@ return false; } } - OutputStream out = conn.getRequestOutputStream(); - Part.sendParts(out, getParts()); + OutputStream outstream = conn.getRequestOutputStream(); + + if (Wire.enabled()) { + outstream = new WireLogOutputStream(outstream, "US-ASCII"); + } + + Part.sendParts(outstream, getParts()); return true; }
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]