Index: PostTask.java =================================================================== RCS file: /cvsroot/ant-contrib/ant-contrib/src/net/sf/antcontrib/net/PostTask.java,v retrieving revision 1.6 diff -u -r1.6 PostTask.java --- PostTask.java 13 Apr 2004 06:19:24 -0000 1.6 +++ PostTask.java 19 May 2004 08:25:01 -0000 @@ -67,6 +67,10 @@ private URLConnection connection = null; /** for thread handling */ private Thread currentRunner = null; + /** is file raw? */ + private boolean rawFile = false; + /** when file is raw, don't do the http-encoding prior to sending ?*/ + private boolean rawFileNoEncode = false; /** @@ -169,6 +173,23 @@ failOnError = fail; } + /** + * The file contains the raw data (not properties) + * + * @param rawFile true = treat file as raw, default is false + */ + public void setRawfile(boolean rawFile ) { + this.rawFile = rawFile; + } + + /** + * When file is raw, do/don't do the http-encoding prior to sending + * + * @param rawFileNoEncode true = don't http-encode, default is false + */ + public void setRawfilenoencode(boolean rawFileNoEncode ) { + this.rawFileNoEncode = rawFileNoEncode; + } /** * Adds a name/value pair to post. Optional. @@ -350,6 +371,13 @@ * @return the message to send to the server, UTF-8 encoded. */ private String getContent() { + if (rawFile) { + String content = loadRawFile(propsFile); + if (!rawFileNoEncode) { + content = encode(content); + } + return content; + } if ( propsFile != null ) { loadFile( propsFile ); } @@ -379,7 +407,47 @@ } - /** + /** + * @return String having the content of the file + */ +private String loadRawFile(File file) { + try { + if ( file.exists() ) { + FileReader r = new FileReader(file); + try { + StringBuffer sb = new StringBuffer( ); + + final int bulksize = 1024; + + char[] b = new char[bulksize]; + int n; + // Read a block. If it gets any chars, append them. + while ((n = r.read(b)) > 0) { + sb.append(b, 0, n); + } + return sb.toString(); + } + finally { + if ( r != null ) { + r.close(); + } + } + } + else { + log( "Unable to find property file: " + file.getAbsolutePath(), + Project.MSG_VERBOSE ); + } + } + catch ( IOException ex ) { + if ( failOnError ) { + throw new BuildException( ex, location ); + } + } + return ""; +} + + +/** * Borrowed from Property -- load variables from a file * * @param file file to load Index: post_task.html =================================================================== RCS file: /cvsroot/ant-contrib/ant-contrib/manual/tasks/post_task.html,v retrieving revision 1.3 diff -u -r1.3 post_task.html --- post_task.html 13 Oct 2003 15:29:00 -0000 1.3 +++ post_task.html 19 May 2004 08:25:33 -0000 @@ -118,6 +118,29 @@ +rawFile + +Should the file be trated as raw file instead of property-like file. True - send the content of the file directly to http-post, all properties set by 'property' are ignored!
+Has only impact when the property 'file' is specified. + +False, treat file as property-like + +No + + + + +rawFileNoEncoding + +Don't encode the raw file prior to sending http post request.
+Has only impact when the property 'rawFile' is specified. + +False, http-encode the content of the file + +No + + + maxwait The maximum amount of time in seconds to wait for the data to be sent or for a response from the remote server. Setting this to zero means wait forever.