[Httpunit-commit] CVS: httpunit/src/com/meterware/httpunit MessageBodyWebRequest.java,1.7,1.8 WebCli
Brought to you by:
russgold
|
From: Russell G. <rus...@us...> - 2002-01-25 19:09:11
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/httpunit
In directory usw-pr-cvs1:/tmp/cvs-serv10169/src/com/meterware/httpunit
Modified Files:
MessageBodyWebRequest.java WebClient.java WebRequest.java
Log Message:
Added writeMessageBody to WebClient
Index: MessageBodyWebRequest.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/MessageBodyWebRequest.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- MessageBodyWebRequest.java 2002/01/22 20:00:37 1.7
+++ MessageBodyWebRequest.java 2002/01/25 19:09:08 1.8
@@ -4,12 +4,12 @@
*
* Copyright (c) 2001-2002, Russell Gold
*
-* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
-* documentation files (the "Software"), to deal in the Software without restriction, including without limitation
+* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
+* documentation files (the "Software"), to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and
* to permit persons to whom the Software is furnished to do so, subject to the following conditions:
*
-* The above copyright notice and this permission notice shall be included in all copies or substantial portions
+* The above copyright notice and this permission notice shall be included in all copies or substantial portions
* of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
@@ -64,7 +64,7 @@
/**
* Subclasses must override this method to provide a message body for the
* request.
- **/
+ **/
abstract
protected MessageBody getMessageBody();
@@ -72,6 +72,11 @@
//---------------------------------- WebRequest methods --------------------------------
+ protected void writeMessageBody( OutputStream stream ) throws IOException {
+ getMessageBody().writeTo( stream );
+ }
+
+
/**
* Performs any additional processing necessary to complete the request.
**/
@@ -81,7 +86,7 @@
connection.setDoOutput( true );
OutputStream stream = connection.getOutputStream();
- getMessageBody().writeTo( stream );
+ writeMessageBody( stream );
stream.flush();
stream.close();
}
@@ -98,15 +103,15 @@
* A method request message body read directly from an input stream.
**/
public static class InputStreamMessageBody extends MessageBody {
-
-
+
+
public InputStreamMessageBody( MessageBodyWebRequest request, InputStream source, String contentType ) {
super( request );
_source = source;
_contentType = contentType;
}
-
-
+
+
/**
* Returns the content type of this message body.
**/
@@ -125,11 +130,11 @@
outputStream.write( buffer, 0, count );
count = _source.read( buffer, 0, buffer.length );
} while (count != -1);
-
+
_source.close();
}
-
-
+
+
private InputStream _source;
private String _contentType;
}
Index: WebClient.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebClient.java,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- WebClient.java 2002/01/24 17:59:45 1.15
+++ WebClient.java 2002/01/25 19:09:08 1.16
@@ -20,6 +20,7 @@
*
*******************************************************************************************************************/
import java.io.IOException;
+import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
@@ -171,6 +172,14 @@
**/
abstract
protected WebResponse newResponse( WebRequest request ) throws MalformedURLException, IOException;
+
+
+ /**
+ * Writes the message body for the request.
+ **/
+ final protected void writeMessageBody( WebRequest request, OutputStream stream ) throws IOException {
+ request.writeMessageBody( stream );
+ }
/**
Index: WebRequest.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebRequest.java,v
retrieving revision 1.37
retrieving revision 1.38
diff -u -r1.37 -r1.38
--- WebRequest.java 2002/01/17 19:38:09 1.37
+++ WebRequest.java 2002/01/25 19:09:08 1.38
@@ -23,6 +23,7 @@
import java.io.FileInputStream;
import java.io.InputStream;
import java.io.IOException;
+import java.io.OutputStream;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
@@ -331,6 +332,13 @@
* Performs any additional processing necessary to complete the request.
**/
protected void completeRequest( URLConnection connection ) throws IOException {
+ }
+
+
+ /**
+ * Writes the contents of the message body to the specified stream.
+ */
+ protected void writeMessageBody( OutputStream stream ) throws IOException {
}
|