jsdever 2003/02/08 11:22:50 Modified: httpclient/src/java/org/apache/commons/httpclient ChunkedOutputStream.java HttpConnection.java HttpConstants.java HttpMethodBase.java RequestOutputStream.java httpclient/src/java/org/apache/commons/httpclient/methods EntityEnclosingMethod.java Log: Formatting and style fixes. Revision Changes Path 1.8 +28 -28 jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/ChunkedOutputStream.java Index: ChunkedOutputStream.java =================================================================== RCS file: /home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/ChunkedOutputStream.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- ChunkedOutputStream.java 28 Jan 2003 04:40:20 -0000 1.7 +++ ChunkedOutputStream.java 8 Feb 2003 19:22:49 -0000 1.8 @@ -86,22 +86,19 @@ */ public class ChunkedOutputStream extends OutputStream { - // ----------------------------------------------------------- Constructors + // ------------------------------------------------------- Static Variables - /** - * Construct an output stream wrapping the given stream. - * The stream will not use chunking. - * - * @param stream wrapped output stream. Must be non-null. - */ - public ChunkedOutputStream(OutputStream stream) { - if (stream == null) { - throw new NullPointerException("stream parameter is null"); - } - this.stream = stream; - } + /** <tt>"\r\n"</tt>, as bytes. */ + private static final byte CRLF[] = new byte[] {(byte) 13, (byte) 10}; - // ------------------------------------------------------- Static Variables + /** End chunk */ + private static final byte ENDCHUNK[] = CRLF; + + /** 0 */ + private static final byte ZERO[] = new byte[] {(byte) '0'}; + + /** 1 */ + private static final byte ONE[] = new byte[] {(byte) '1'}; /** Log object for this class. */ private static final Log LOG = LogFactory.getLog(ChunkedOutputStream.class); @@ -120,17 +117,20 @@ /** True if printing a chunk */ private boolean writingChunk = false; - /** End chunk */ - private static final byte ENDCHUNK[] = new byte[] {(byte) 13, (byte) 10}; - - /** CRLF */ - private static final byte CRLF[] = new byte[] {(byte) 13, (byte) 10}; - - /** 0 */ - private static final byte ZERO[] = new byte[] {(byte) '0'}; + // ----------------------------------------------------------- Constructors - /** 1 */ - private static final byte ONE[] = new byte[] {(byte) '1'}; + /** + * Construct an output stream wrapping the given stream. + * The stream will not use chunking. + * + * @param stream wrapped output stream. Must be non-null. + */ + public ChunkedOutputStream(OutputStream stream) { + if (stream == null) { + throw new NullPointerException("stream parameter is null"); + } + this.stream = stream; + } // --------------------------------------------------------- Public Methods 1.42 +32 -56 jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/HttpConnection.java Index: HttpConnection.java =================================================================== RCS file: /home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/HttpConnection.java,v retrieving revision 1.41 retrieving revision 1.42 diff -u -r1.41 -r1.42 --- HttpConnection.java 8 Feb 2003 01:12:15 -0000 1.41 +++ HttpConnection.java 8 Feb 2003 19:22:49 -0000 1.42 @@ -108,6 +108,7 @@ * @version $Revision$ $Date$ */ public class HttpConnection { + // ----------------------------------------------------------- Constructors /** @@ -183,11 +184,7 @@ String host, int port, boolean secure) { - this( - proxyHost, - proxyPort, - host, - port, + this(proxyHost, proxyPort, host, port, Protocol.getProtocol(secure ? "https" : "http")); } @@ -197,12 +194,11 @@ * @param hostConfiguration the host/proxy/protocol to use */ public HttpConnection(HostConfiguration hostConfiguration) { - this( - hostConfiguration.getProxyHost(), - hostConfiguration.getProxyPort(), - hostConfiguration.getHost(), - hostConfiguration.getPort(), - hostConfiguration.getProtocol()); + this(hostConfiguration.getProxyHost(), + hostConfiguration.getProxyPort(), + hostConfiguration.getHost(), + hostConfiguration.getPort(), + hostConfiguration.getProtocol()); } /** @@ -222,18 +218,9 @@ Protocol protocol) { if (LOG.isDebugEnabled()) { - LOG.debug( - "HttpConnectionManager.getConnection: creating " - + " connection for " - + host - + ":" - + port - + " via " - + proxyHost - + ":" - + proxyPort - + " using protocol: " - + protocol); + LOG.debug("HttpConnectionManager.getConnection: creating connection for " + + host + ":" + port + " via " + proxyHost + ":" + proxyPort + + " using protocol: " + protocol); } if (host == null) { @@ -374,10 +361,9 @@ */ public void setSecure(boolean secure) throws IllegalStateException { assertNotOpen(); - protocolInUse = - (secure - ? Protocol.getProtocol("https") - : Protocol.getProtocol("http")); + protocolInUse = secure + ? Protocol.getProtocol("https") + : Protocol.getProtocol("http"); } /** @@ -543,19 +529,10 @@ throw e; } catch (TimeoutController.TimeoutException e) { if (LOG.isWarnEnabled()) { - LOG.warn( - "The host " - + hostName - + ":" - + portNumber - + " (or proxy " - + proxyHostName - + ":" - + proxyPortNumber - + ") did not accept the connection " - + "within timeout of " - + connectTimeout - + " milliseconds"); + LOG.warn( "The host " + hostName + ":" + portNumber + + " (or proxy " + proxyHostName + ":" + proxyPortNumber + + ") did not accept the connection within timeout of " + + connectTimeout + " milliseconds"); } throw new ConnectionTimeoutException(); } @@ -740,14 +717,9 @@ LOG.trace("enter HttpConnection.write(byte[], int, int)"); if (offset + length > data.length) { - throw new HttpRecoverableException( - "Unable to write:" - + " offset=" - + offset - + " length=" - + length - + " data.length=" - + data.length); + throw new HttpRecoverableException( "Unable to write:" + + " offset=" + offset + " length=" + length + + " data.length=" + data.length); } else if (data.length <= 0) { throw new HttpRecoverableException( "Unable to write:" + " data.length=" + data.length); @@ -1038,10 +1010,12 @@ } } + /** * Helper class for wrapping socket based tasks. */ private abstract class SocketTask implements Runnable { + /** The socket */ private Socket socket; /** The exception */ @@ -1054,6 +1028,7 @@ protected void setSocket(final Socket newSocket) { socket = newSocket; } + /** * Return the socket. * @return Socket The socket. @@ -1077,7 +1052,10 @@ } } - // ------------------------------------------------------------- Attributes + // ------------------------------------------------------- Static Variable + + /** <tt>"\r\n"</tt>, as bytes. */ + private static final byte[] CRLF = new byte[] {(byte) 13, (byte) 10}; /** Log object for this class. */ private static final Log LOG = LogFactory.getLog(HttpConnection.class); @@ -1085,6 +1063,7 @@ /** Log for any wire messages. */ private static final Log WIRE_LOG = LogFactory.getLog("httpclient.wire"); + // ----------------------------------------------------- Instance Variables /** My host. */ private String hostName = null; @@ -1114,9 +1093,6 @@ /** the protocol being used */ private Protocol protocolInUse; - - /** <tt>"\r\n"</tt>, as bytes. */ - private static final byte[] CRLF = HttpConstants.getBytes("\r\n"); /** SO_TIMEOUT socket value */ private int soTimeout = 0; 1.6 +5 -5 jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/HttpConstants.java Index: HttpConstants.java =================================================================== RCS file: /home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/HttpConstants.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- HttpConstants.java 3 Feb 2003 21:21:15 -0000 1.5 +++ HttpConstants.java 8 Feb 2003 19:22:49 -0000 1.6 @@ -270,7 +270,7 @@ try { return data.getBytes("US-ASCII"); } catch (UnsupportedEncodingException e) { - throw new RuntimeException("HTTP client requires ASCII support"); + throw new RuntimeException("HttpClient requires ASCII support"); } } @@ -291,7 +291,7 @@ try { return new String(data, "US-ASCII"); } catch (UnsupportedEncodingException e) { - throw new RuntimeException("HTTP client requires ASCII support"); + throw new RuntimeException("HttpClient requires ASCII support"); } } } 1.110 +6 -8 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.109 retrieving revision 1.110 diff -u -r1.109 -r1.110 --- HttpMethodBase.java 8 Feb 2003 01:12:15 -0000 1.109 +++ HttpMethodBase.java 8 Feb 2003 19:22:49 -0000 1.110 @@ -2349,8 +2349,7 @@ if (connection.waitForResponse(RESPONSE_WAIT_TIME_MS)) { responseExpected = true; LOG.debug("Response available"); - } - else { + } else { responseExpected = false; // Something is wrong. if (getRequestHeader("Expect") != null) { @@ -2400,8 +2399,7 @@ boolean continueReceived = false; if (statusLine == null) { writeRemaining = true; - } - else { + } else { if (statusLine.getStatusCode() == HttpStatus.SC_CONTINUE) { writeRemaining = true; continueReceived = true; 1.19 +8 -8 jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/RequestOutputStream.java Index: RequestOutputStream.java =================================================================== RCS file: /home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/RequestOutputStream.java,v retrieving revision 1.18 retrieving revision 1.19 diff -u -r1.18 -r1.19 --- RequestOutputStream.java 30 Jan 2003 05:01:54 -0000 1.18 +++ RequestOutputStream.java 8 Feb 2003 19:22:49 -0000 1.19 @@ -135,11 +135,11 @@ /** True if printing a chunk */ private boolean writingChunk = false; - /** End chunk */ - private static final byte ENDCHUNK[] = new byte[] {(byte) 13, (byte) 10}; - - /** CRLF */ + /** <tt>"\r\n"</tt>, as bytes. */ private static final byte CRLF[] = new byte[] {(byte) 13, (byte) 10}; + + /** End chunk */ + private static final byte ENDCHUNK[] = CRLF; /** 0 */ private static final byte ZERO[] = new byte[] {(byte) '0'}; 1.8 +7 -8 jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/methods/EntityEnclosingMethod.java Index: EntityEnclosingMethod.java =================================================================== RCS file: /home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/methods/EntityEnclosingMethod.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- EntityEnclosingMethod.java 6 Feb 2003 16:08:05 -0000 1.7 +++ EntityEnclosingMethod.java 8 Feb 2003 19:22:49 -0000 1.8 @@ -363,13 +363,12 @@ // See if the expect header should be sent // = HTTP/1.1 or higher // = request body present - if (getUseExpectHeader() && isHttp11() && - ((this.requestBodyStream != null) || this.buffer != null)) { + if (getUseExpectHeader() && isHttp11() + && ((this.requestBodyStream != null) || this.buffer != null)) { if (!headerPresent) { setRequestHeader("Expect", "100-continue"); } - } - else { + } else { if (headerPresent) { removeRequestHeader("Expect"); }
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]