CVS update: sierra/src/java/org/openprivacy/sierra/test

From: cvs@openprivacy.org
Date: Sat Jan 06 2001 - 01:36:12 PST


Date: Saturday January 6, 19101 @ 1:36
Author: burton
CVSWEB Options: -------------------

Main CVSWeb: http://openprivacy.org/cgi-bin/cvsweb/cvsweb.cgi

View this module: http://openprivacy.org/cgi-bin/cvsweb/cvsweb.cgi/sierra/src/java/org/openprivacy/sierra/test

-----------------------------------

Update of /usr/local/cvsroot/sierra/src/java/org/openprivacy/sierra/test
In directory openprivacy.org:/tmp/cvs-serv22499/src/java/org/openprivacy/sierra/test

Modified Files:
        HttpPostUtil.java
Log Message:
reworked everything so tests are MUCH easier.

*****************************************************************
File: sierra/src/java/org/openprivacy/sierra/test/HttpPostUtil.java

CVSWEB Options: -------------------

CVSWeb: Annotate this file: http://openprivacy.org/cgi-bin/cvsweb/cvsweb.cgi/sierra/src/java/org/openprivacy/sierra/test/HttpPostUtil.java?annotate=1.4

CVSWeb: View this file: http://openprivacy.org/cgi-bin/cvsweb/cvsweb.cgi/sierra/src/java/org/openprivacy/sierra/test/HttpPostUtil.java?rev=1.4&content-type=text/x-cvsweb-markup

CVSWeb: Diff to previous version: http://openprivacy.org/cgi-bin/cvsweb/cvsweb.cgi/sierra/src/java/org/openprivacy/sierra/test/HttpPostUtil.java.diff?r1=1.4&r2=1.3

-----------------------------------

Index: sierra/src/java/org/openprivacy/sierra/test/HttpPostUtil.java
diff -u sierra/src/java/org/openprivacy/sierra/test/HttpPostUtil.java:1.3 sierra/src/java/org/openprivacy/sierra/test/HttpPostUtil.java:1.4
--- sierra/src/java/org/openprivacy/sierra/test/HttpPostUtil.java:1.3 Sat Jan 6 01:11:56 2001
+++ sierra/src/java/org/openprivacy/sierra/test/HttpPostUtil.java Sat Jan 6 01:36:12 2001
@@ -26,7 +26,7 @@
  * document and the given document to the server and add the necessary parameters.
  *
  * @author <a href="mailto:burton@relativity.yi.org">Kevin A. Burton</a>
- * @version $Id: HttpPostUtil.java,v 1.3 2001/01/06 09:11:56 burton Exp $
+ * @version $Id: HttpPostUtil.java,v 1.4 2001/01/06 09:36:12 burton Exp $
  */
 public class HttpPostUtil
 {
@@ -74,7 +74,7 @@
        Do this post
        
        @author <a href="mailto:burton@relativity.yi.org">Kevin A. Burton</a>
- @version $Id: HttpPostUtil.java,v 1.3 2001/01/06 09:11:56 burton Exp $
+ @version $Id: HttpPostUtil.java,v 1.4 2001/01/06 09:36:12 burton Exp $
        
      */
     public void execute() throws Exception
@@ -94,13 +94,58 @@
 
         ps.println( "Content-Type: " + this.contentType );
 
- //fetch document to post as a String.
-
         //post the new Content-Length..
-
+
+ ps.println( "Content-Length: " + this.file.length() );
+
         //dump params to HTTP stream
+
+ Enumeration keys = params.keys();
+
+ while( keys.hasMoreElements() ) {
+
+ String key = (String )keys.nextElement();
+ ps.println( key + ": " + params.get( key ) );
+
+ }
+
+
+ try {
+ //fetch document to post as a String and send it.
+
+ ps.print( "\n\n" );
+
+ ps.print( this.getData() );
+
+ //should be everything we need. server should accept the data and the
+ // socket should close itself.
+ } catch ( Exception e ) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ Get the data needed byte this socket.
+
+ @author <a href="mailto:burton@relativity.yi.org">Kevin A. Burton</a>
+ @version $Id: HttpPostUtil.java,v 1.4 2001/01/06 09:36:12 burton Exp $
+ */
+ public String getData() throws IOException {
+
+ InputStream is = new FileInputStream( file );
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+
+ //now process the InputStream...
+ byte bytes[] = new byte[200];
+
+ int readCount = 0;
+ while( ( readCount = is.read( bytes )) > 0 ) {
+ bos.write(bytes, 0, readCount);
+ }
+
+ is.close();
         
- ps.print( "\n\n" );
+ return bos.toString();
         
     }
     
@@ -152,13 +197,13 @@
     public void println( String data )
     {
         super.println( data );
- System.out.println( data );
+ //System.out.println( data );
     }
 
     public void print( String data )
     {
         super.print( data );
- System.out.print( data );
+ System.out.print( data + "\n");
     }
 
 }



This archive was generated by hypermail 2b30 : Mon Jan 22 2001 - 15:52:14 PST