[Httpunit-commit] CVS: httpunit/src/com/meterware/httpunit HttpWebResponse.java,1.8,1.9
Brought to you by:
russgold
|
From: Russell G. <rus...@us...> - 2001-05-31 16:44:18
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/httpunit
In directory usw-pr-cvs1:/tmp/cvs-serv26912/src/com/meterware/httpunit
Modified Files:
HttpWebResponse.java
Log Message:
Corrected exceptions when failing to connect
Index: HttpWebResponse.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/HttpWebResponse.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- HttpWebResponse.java 2001/05/22 22:18:55 1.8
+++ HttpWebResponse.java 2001/05/31 16:44:15 1.9
@@ -87,7 +87,7 @@
private Hashtable _headers = new Hashtable();
- private void loadResponseText( URL url, URLConnection connection ) throws FileNotFoundException {
+ private void loadResponseText( URL url, URLConnection connection ) throws IOException {
StringBuffer sb = new StringBuffer();
try {
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
@@ -111,13 +111,13 @@
e.fillInStackTrace();
throw e;
}
- } catch (IOException e) {
- throw new RuntimeException( "Unable to retrieve data from URL: " + url.toExternalForm() + " (" + e + ")" );
}
}
- private int getResponseCode( String statusHeader ) {
+ private int getResponseCode( URLConnection connection, String statusHeader ) {
+ if (statusHeader == null) throw new HttpNotFoundException( connection.getURL().toExternalForm() );
+
StringTokenizer st = new StringTokenizer( statusHeader );
st.nextToken();
if (!st.hasMoreTokens()) {
@@ -159,7 +159,7 @@
private void readHeaders( URLConnection connection ) {
loadHeaders( connection );
if (connection instanceof HttpURLConnection) {
- _responseCode = getResponseCode( connection.getHeaderField(0) );
+ _responseCode = getResponseCode( connection, connection.getHeaderField(0) );
} else {
_responseCode = HttpURLConnection.HTTP_OK;
if (getContentType().startsWith( "text" )) {
|