marcsaeg 02/02/22 11:14:43 Modified: httpclient/src/java/org/apache/commons/httpclient HttpConnection.java Log: Added support for HttpRecoverableException. Revision Changes Path 1.8 +45 -16 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.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- HttpConnection.java 12 Feb 2002 02:11:43 -0000 1.7 +++ HttpConnection.java 22 Feb 2002 19:14:43 -0000 1.8 @@ -1,7 +1,7 @@ /* - * $Header: /home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/HttpConnection.java,v 1.7 2002/02/12 02:11:43 dion Exp $ - * $Revision: 1.7 $ - * $Date: 2002/02/12 02:11:43 $ + * $Header: /home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/HttpConnection.java,v 1.8 2002/02/22 19:14:43 marcsaeg Exp $ + * $Revision: 1.8 $ + * $Date: 2002/02/22 19:14:43 $ * ==================================================================== * * The Apache Software License, Version 1.1 @@ -79,7 +79,7 @@ * </p> * @author Rod Waldhoff * @author Sean C. Sullivan - * @version $Revision: 1.7 $ $Date: 2002/02/12 02:11:43 $ + * @version $Revision: 1.8 $ $Date: 2002/02/22 19:14:43 $ */ public class HttpConnection { // ----------------------------------------------------------- Constructors @@ -346,14 +346,21 @@ * @throws IllegalStateException if I am not connected * @throws IOException if an I/O problem occurs */ - public void write(byte[] data) throws IOException, IllegalStateException { - log.debug("HttpConnection.write(byte[])"); + public void write(byte[] data) throws IOException, IllegalStateException, HttpRecoverableException { + if(log.isDebugEnabled()){ + log.debug("HttpConnection.write(byte[])"); + } assertOpen(); if(wireLog.isInfoEnabled() && (data.length > 0)) { wireLog.info(">> \"" + new String(data) + "\""); } try { _output.write(data); + } catch(SocketException e){ + if(log.isDebugEnabled()) { + log.debug("HttpConnection: Socket exception while writing data",e); + } + throw new HttpRecoverableException(e.toString()); } catch(IOException e) { if(log.isDebugEnabled()) { log.debug("HttpConnection: Exception while writing data",e); @@ -369,14 +376,25 @@ * @throws IllegalStateException if I am not connected * @throws IOException if an I/O problem occurs */ - public void writeLine(byte[] data) throws IOException, IllegalStateException { - log.debug("HttpConnection.writeLine(byte[])"); + public void writeLine(byte[] data) throws IOException, IllegalStateException, HttpRecoverableException { + if(log.isDebugEnabled()){ + log.debug("HttpConnection.writeLine(byte[])"); + } assertOpen(); if(wireLog.isInfoEnabled() && (data.length > 0)) { wireLog.info(">> \"" + new String(data) + "\""); } - _output.write(data); - writeLine(); + try{ + _output.write(data); + writeLine(); + } catch(SocketException e){ + if(log.isDebugEnabled()) { + log.debug("HttpConnection: Socket exception while writing data",e); + } + throw new HttpRecoverableException(e.toString()); + } catch(IOException e){ + throw e; + } } /** @@ -384,10 +402,21 @@ * @throws IllegalStateException if I am not connected * @throws IOException if an I/O problem occurs */ - public void writeLine() throws IOException, IllegalStateException { - log.debug("HttpConnection.writeLine()"); + public void writeLine() throws IOException, IllegalStateException, HttpRecoverableException { + if(log.isDebugEnabled()){ + log.debug("HttpConnection.writeLine()"); + } wireLog.info(">> \\r\\n"); - _output.write(CRLF); + try{ + _output.write(CRLF); + } catch(SocketException e){ + if(log.isDebugEnabled()) { + log.debug("HttpConnection: Socket exception while writing data",e); + } + throw new HttpRecoverableException(e.toString()); + } catch(IOException e){ + throw e; + } } /** @@ -395,7 +424,7 @@ * @throws IllegalStateException if I am not connected * @throws IOException if an I/O problem occurs */ - public void print(String data) throws IOException, IllegalStateException { + public void print(String data) throws IOException, IllegalStateException, HttpRecoverableException { write(data.getBytes()); } @@ -405,7 +434,7 @@ * @throws IllegalStateException if I am not connected * @throws IOException if an I/O problem occurs */ - public void printLine(String data) throws IOException, IllegalStateException { + public void printLine(String data) throws IOException, IllegalStateException, HttpRecoverableException { writeLine(data.getBytes()); } @@ -414,7 +443,7 @@ * @throws IllegalStateException if I am not connected * @throws IOException if an I/O problem occurs */ - public void printLine() throws IOException, IllegalStateException { + public void printLine() throws IOException, IllegalStateException, HttpRecoverableException { writeLine(); }
-- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>