Index: src/java/org/apache/commons/httpclient/ConnectMethod.java =================================================================== retrieving revision 1.28 diff -u -r1.28 ConnectMethod.java --- src/java/org/apache/commons/httpclient/ConnectMethod.java 13 May 2004 04:03:25 -0000 1.28 +++ src/java/org/apache/commons/httpclient/ConnectMethod.java 14 Jun 2004 02:14:27 -0000 @@ -173,8 +173,8 @@ buffer.append(" HTTP/1.1"); String line = buffer.toString(); conn.printLine(line, getParams().getHttpElementCharset()); - if (Wire.enabled()) { - Wire.output(line); + if (Wire.HEADER_WIRE.enabled()) { + Wire.HEADER_WIRE.output(line); } } Index: src/java/org/apache/commons/httpclient/HttpConnection.java =================================================================== retrieving revision 1.92 diff -u -r1.92 HttpConnection.java --- src/java/org/apache/commons/httpclient/HttpConnection.java 1 Jun 2004 00:55:10 -0000 1.92 +++ src/java/org/apache/commons/httpclient/HttpConnection.java 14 Jun 2004 02:14:30 -0000 @@ -773,8 +773,8 @@ LOG.trace("enter HttpConnection.getRequestOutputStream()"); assertOpen(); OutputStream out = this.outputStream; - if (Wire.traceEnabled()) { - out = new WireLogOutputStream(out); + if (Wire.CONTENT_WIRE.enabled()) { + out = new WireLogOutputStream(out, Wire.CONTENT_WIRE); } return out; } Index: src/java/org/apache/commons/httpclient/HttpMethodBase.java =================================================================== retrieving revision 1.208 diff -u -r1.208 HttpMethodBase.java --- src/java/org/apache/commons/httpclient/HttpMethodBase.java 13 Jun 2004 20:22:19 -0000 1.208 +++ src/java/org/apache/commons/httpclient/HttpMethodBase.java 14 Jun 2004 02:14:35 -0000 @@ -1628,8 +1628,8 @@ responseBody = null; // is this desired? InputStream is = conn.getResponseInputStream(); - if (Wire.traceEnabled()) { - is = new WireLogInputStream(is); + if (Wire.CONTENT_WIRE.enabled()) { + is = new WireLogInputStream(is, Wire.CONTENT_WIRE); } InputStream result = null; Header transferEncodingHeader = responseHeaders.getFirstHeader("Transfer-Encoding"); @@ -1742,9 +1742,9 @@ Header[] headers = HttpParser.parseHeaders( conn.getResponseInputStream(), getParams().getHttpElementCharset()); - if (Wire.enabled()) { + if (Wire.HEADER_WIRE.enabled()) { for (int i = 0; i < headers.length; i++) { - Wire.input(headers[i].toExternalForm()); + Wire.HEADER_WIRE.input(headers[i].toExternalForm()); } } getResponseHeaderGroup().setHeaders(headers); @@ -1783,8 +1783,8 @@ String s; do { s = conn.readLine(getParams().getHttpElementCharset()); - if (Wire.enabled()) { - Wire.input(s + "\r\n"); + if (Wire.HEADER_WIRE.enabled()) { + Wire.HEADER_WIRE.input(s + "\r\n"); } if (s != null && StatusLine.startsWithHTTP(s)) { // Got one @@ -1869,8 +1869,8 @@ conn.writeLine(); // close head // make sure the status line and headers have been sent conn.flushRequestOutputStream(); - if (Wire.enabled()) { - Wire.output("\r\n"); + if (Wire.HEADER_WIRE.enabled()) { + Wire.HEADER_WIRE.output("\r\n"); } HttpVersion ver = getParams().getVersion(); @@ -1984,8 +1984,8 @@ Header[] headers = getRequestHeaders(); for (int i = 0; i < headers.length; i++) { String s = headers[i].toExternalForm(); - if (Wire.enabled()) { - Wire.output(s); + if (Wire.HEADER_WIRE.enabled()) { + Wire.HEADER_WIRE.output(s); } conn.print(s, charset); } @@ -2015,8 +2015,8 @@ LOG.trace( "enter HttpMethodBase.writeRequestLine(HttpState, HttpConnection)"); String requestLine = getRequestLine(conn); - if (Wire.enabled()) { - Wire.output(requestLine); + if (Wire.HEADER_WIRE.enabled()) { + Wire.HEADER_WIRE.output(requestLine); } conn.print(requestLine, getParams().getHttpElementCharset()); } Index: src/java/org/apache/commons/httpclient/Wire.java =================================================================== retrieving revision 1.8 diff -u -r1.8 Wire.java --- src/java/org/apache/commons/httpclient/Wire.java 18 Apr 2004 23:51:35 -0000 1.8 +++ src/java/org/apache/commons/httpclient/Wire.java 14 Jun 2004 02:14:35 -0000 @@ -44,10 +44,18 @@ */ class Wire { + public static Wire HEADER_WIRE = new Wire(LogFactory.getLog("httpclient.wire.header")); + + public static Wire CONTENT_WIRE = new Wire(LogFactory.getLog("httpclient.wire.content")); + /** Log for any wire messages. */ - private static final Log WIRE_LOG = LogFactory.getLog("httpclient.wire"); - - private static void wire(String header, InputStream instream) + private Log log; + + private Wire(Log log) { + this.log = log; + } + + private void wire(String header, InputStream instream) throws IOException { StringBuffer buffer = new StringBuffer(); int ch; @@ -58,7 +66,7 @@ buffer.append("[\\n]\""); buffer.insert(0, "\""); buffer.insert(0, header); - WIRE_LOG.debug(buffer.toString()); + log.debug(buffer.toString()); buffer.setLength(0); } else if ((ch < 32) || (ch > 127)) { buffer.append("[0x"); @@ -72,20 +80,16 @@ buffer.append("\""); buffer.insert(0, "\""); buffer.insert(0, header); - WIRE_LOG.debug(buffer.toString()); + log.debug(buffer.toString()); } } - public static final boolean enabled() { - return WIRE_LOG.isDebugEnabled(); - } - - public static final boolean traceEnabled() { - return WIRE_LOG.isTraceEnabled(); + public boolean enabled() { + return log.isDebugEnabled(); } - public static final void output(InputStream outstream) + public void output(InputStream outstream) throws IOException { if (outstream == null) { throw new IllegalArgumentException("Output may not be null"); @@ -93,7 +97,7 @@ wire(">> ", outstream); } - public static final void input(InputStream instream) + public void input(InputStream instream) throws IOException { if (instream == null) { throw new IllegalArgumentException("Input may not be null"); @@ -101,7 +105,7 @@ wire("<< ", instream); } - public static final void output(byte[] b, int off, int len) + public void output(byte[] b, int off, int len) throws IOException { if (b == null) { throw new IllegalArgumentException("Output may not be null"); @@ -109,7 +113,7 @@ wire(">> ", new ByteArrayInputStream(b, off, len)); } - public static final void input(byte[] b, int off, int len) + public void input(byte[] b, int off, int len) throws IOException { if (b == null) { throw new IllegalArgumentException("Input may not be null"); @@ -117,7 +121,7 @@ wire("<< ", new ByteArrayInputStream(b, off, len)); } - public static final void output(byte[] b) + public void output(byte[] b) throws IOException { if (b == null) { throw new IllegalArgumentException("Output may not be null"); @@ -125,7 +129,7 @@ wire(">> ", new ByteArrayInputStream(b)); } - public static final void input(byte[] b) + public void input(byte[] b) throws IOException { if (b == null) { throw new IllegalArgumentException("Input may not be null"); @@ -133,17 +137,17 @@ wire("<< ", new ByteArrayInputStream(b)); } - public static final void output(int b) + public void output(int b) throws IOException { output(new byte[] {(byte) b}); } - public static final void input(int b) + public void input(int b) throws IOException { input(new byte[] {(byte) b}); } - public static final void output(final String s) + public void output(final String s) throws IOException { if (s == null) { throw new IllegalArgumentException("Output may not be null"); @@ -151,7 +155,7 @@ output(s.getBytes()); } - public static final void input(final String s) + public void input(final String s) throws IOException { if (s == null) { throw new IllegalArgumentException("Input may not be null"); Index: src/java/org/apache/commons/httpclient/WireLogInputStream.java =================================================================== retrieving revision 1.14 diff -u -r1.14 WireLogInputStream.java --- src/java/org/apache/commons/httpclient/WireLogInputStream.java 18 Apr 2004 23:51:35 -0000 1.14 +++ src/java/org/apache/commons/httpclient/WireLogInputStream.java 14 Jun 2004 02:14:36 -0000 @@ -45,15 +45,20 @@ class WireLogInputStream extends FilterInputStream { /** Original input stream. */ - private InputStream in; + private InputStream in; + /** The wire log to use for writing. */ + private Wire wire; + /** * Create an instance that wraps the specified input stream. * @param in The input stream. + * @param wire The wire log to use. */ - public WireLogInputStream(InputStream in) { + public WireLogInputStream(InputStream in, Wire wire) { super(in); this.in = in; + this.wire = wire; } /** * @@ -62,7 +67,7 @@ public int read(byte[] b, int off, int len) throws IOException { int l = this.in.read(b, off, len); if (l > 0) { - Wire.input(b, off, l); + wire.input(b, off, l); } return l; } @@ -74,7 +79,7 @@ public int read() throws IOException { int l = this.in.read(); if (l > 0) { - Wire.input(l); + wire.input(l); } return l; } @@ -86,7 +91,7 @@ public int read(byte[] b) throws IOException { int l = this.in.read(b); if (l > 0) { - Wire.input(b, 0, l); + wire.input(b, 0, l); } return l; } Index: src/java/org/apache/commons/httpclient/WireLogOutputStream.java =================================================================== retrieving revision 1.6 diff -u -r1.6 WireLogOutputStream.java --- src/java/org/apache/commons/httpclient/WireLogOutputStream.java 18 Apr 2004 23:51:35 -0000 1.6 +++ src/java/org/apache/commons/httpclient/WireLogOutputStream.java 14 Jun 2004 02:14:36 -0000 @@ -43,15 +43,20 @@ class WireLogOutputStream extends FilterOutputStream { /** Original input stream. */ - private OutputStream out; + private OutputStream out; + + /** The wire log to use. */ + private Wire wire; /** * Create an instance that wraps the specified output stream. * @param out The output stream. + * @param wire The Wire log to use. */ - public WireLogOutputStream(OutputStream out) { + public WireLogOutputStream(OutputStream out, Wire wire) { super(out); this.out = out; + this.wire = wire; } /** @@ -60,7 +65,7 @@ */ public void write(byte[] b, int off, int len) throws IOException { this.out.write(b, off, len); - Wire.output(b, off, len); + wire.output(b, off, len); } /** @@ -69,7 +74,7 @@ */ public void write(int b) throws IOException { this.out.write(b); - Wire.output(b); + wire.output(b); } /** @@ -78,6 +83,6 @@ */ public void write(byte[] b) throws IOException { this.out.write(b); - Wire.output(b); + wire.output(b); } }