source: release-kits/wirk3/ant-scripts/tasks/antelope/docs/manual/bk03ch17.html@ 15023

Last change on this file since 15023 was 15023, checked in by oranfry, 16 years ago

did the bulk of the work on wirk3

File size: 7.8 KB
Line 
1<html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>Chapter 17. HTTP Post</title><meta name="generator" content="DocBook XSL Stylesheets V1.68.1"><link rel="start" href="index.html" title="Antelope Users Guide"><link rel="up" href="bk03.html" title="Additional Ant Tasks"><link rel="prev" href="bk03ch16.html" title="Chapter 16. Hostname"><link rel="next" href="bk03ch18.html" title="Chapter 18. SSH and SCP"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Chapter 17. HTTP Post</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="bk03ch16.html">Prev</a> </td><th width="60%" align="center">Additional Ant Tasks</th><td width="20%" align="right"> <a accesskey="n" href="bk03ch18.html">Next</a></td></tr></table><hr></div><div class="chapter" lang="en"><div class="titlepage"><div><div><h2 class="title"><a name="post"></a>Chapter 17. HTTP Post</h2></div></div></div>
2<STYLE TYPE="text/css"> <!-- @import url(./style.css); --> </STYLE>
3 <p>
4The Post task is a companion to the standard Ant "Get" task. This task does a post and does not necessarily expect anything in return. Almost always, there will be some sort of returned data, this can be logged or written to a file if needed.
5</p><p>
6To use this task in your build files, include a task definition like this:
7</p><pre class="programlisting">
8
9 &lt;taskdef name="post" classname="ise.antelope.tasks.PostTask"/&gt;
10
11</pre><p>
12</p><p>
13Basically, an HTTP POST sends name/value pairs to a web server. A very common usage is for html forms for submitting data. A typical use of this task is to send data to a servlet for updating a web page with the status of a build.
14</p><p>
15This Post task handles cookies and remembers them across calls. This means that you can post to a login form, receive authentication cookies, then subsequent posts will automatically pass the correct cookies. The cookies are stored in memory only, they are not written to disk and will cease to exist upon completion of the build.
16</p><p>
17The Post task has three ways of specifying the data to be posted. Nested "prop" elements can be used. A "prop" element represents a single name/value pair. The second way is to specify a property file as an attribute to the Post. All properties from the file will be sent as part of the Post data. The third way is to just type in some defined Ant properties. Is it allowed to use all three ways at once, that is, read some properties from a file, specify others via "prop" elements, and just type in some Ant properties.
18</p><p>
19</p><div class="table"><a name="id2523989"></a><p class="title"><b>Table 17.1. Post Task Attributes</b></p><table summary="Post Task Attributes" border="1"><colgroup><col><col><col><col></colgroup><thead><tr><th>Attribute</th><th>Description</th><th>Default</th><th>Required</th></tr></thead><tbody><tr><td>to</td><td>The URL of the remote server to send the post.</td><td>None</td><td>Yes</td></tr><tr><td>encoding</td><td>Character encoding for the name/value pairs.</td><td>UTF-8</td><td>No</td></tr><tr><td>logfile</td><td>The name of a file to write any response to. Ignored if wantresponse is set to false.</td><td>None</td><td>No</td></tr><tr><td>append</td><td>Should an existing log file be appended to or overwritten?</td><td>True, append to an existing file.</td><td>No</td></tr><tr><td>file</td><td>A file to read POST data from. All Ant properties contained in this file will be resolved (that is, ${} syntax will be expanded to their values) prior to sending the file contents.</td><td>None</td><td>No</td></tr><tr><td>maxwait</td><td>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.</td><td>180 (3 minutes)</td><td>No</td></tr><tr><td>wantresponse</td><td>Whether to wait for a response from the remote server or not. In many cases this can greatly improve the performance of the build script as the server response may be large and useless to the script. Use this with caution - while the response from the server may not be required for the client, the server may require that the client accept the response prior to processing the post data.</td><td>true</td><td>No</td></tr><tr><td>property</td><td>If set and wantresponse, put the response from the remote server into this property.</td><td>None</td><td>No</td></tr><tr><td>failonerror</td><td>Whether the build should fail if the post fails.</td><td>false</td><td>No</td></tr></tbody></table></div><p>
20</p><p>
21Post supports nested "prop" elements. As an HTTP POST basically sends a list of names and values, the "prop" element represents one name/value pair. A Post may contain any number of "prop" elements.
22</p><p>
23</p><div class="table"><a name="id2524204"></a><p class="title"><b>Table 17.2. Prop Attributes</b></p><table summary="Prop Attributes" border="1"><colgroup><col><col><col><col></colgroup><thead><tr><th>Attribute</th><th>Description</th><th>Default</th><th>Required</th></tr></thead><tbody><tr><td>name</td><td>The name of a property to post.</td><td>None</td><td>Yes</td></tr><tr><td>value</td><td>The value associated with the name.</td><td>None</td><td>No</td></tr></tbody></table></div><p>
24</p><p>
25The "value" attribute is not strictly required. This provides a short-cut method in cases where the property data is an already-defined Ant property. Suppose the build file has this property defined:
26</p><p>
27</p><pre class="programlisting">
28
29 &lt;property name="src.dir" value="/home/user/project/src"/&gt;
30
31</pre><p>
32</p><p>
33Then the following are equivalent:
34</p><p>
35</p><pre class="programlisting">
36
37 &lt;prop name="src.dir"/&gt;
38 &lt;prop name="src.dir" value="${src.dir}"/&gt;
39 &lt;prop name="src.dir" value="/home/user/project/src"/&gt;
40
41</pre><p>
42</p><p>
43Defined Ant properties can be entered directly into the post element. Again, suppose the build file has this property defined:
44</p><p>
45</p><pre class="programlisting">
46
47 &lt;property name="src.dir" value="/home/user/project/src"/&gt;
48
49</pre><p>
50</p><p>
51Then the following are equivalent:
52</p><p>
53</p><pre class="programlisting">
54
55 ${src.dir}
56 &lt;prop name="src.dir"/&gt;
57 &lt;prop name="src.dir" value="${src.dir}"/&gt;
58 &lt;prop name="src.dir" value="/home/user/project/src"/&gt;
59
60</pre><p>
61</p><p>
62I googled for the URL in the following example.
63</p><p>
64</p><pre class="programlisting">
65
66 &lt;property name="test.val" value="here's my test value"/&gt;
67 &lt;property name="test.val2" value="second test value"/&gt;
68 &lt;post to="http://wwwj.cs.unc.edu:8888/tang/servlet/tangGetPostServlet"
69 verbose="true"&gt;
70 &lt;prop name="prop1" value="val1 ${test.val}"/&gt;
71 &lt;prop name="prop2" value="val1 value 2"/&gt;
72 &lt;prop name="prop3" value="val got some spaces %funky ^$* chars"/&gt;
73 &lt;prop name="prop4" value="&amp;amp; do an ampersand like this &amp;amp;amp; or
74 Ant will whine"/&gt;
75 &lt;prop name="thanks" value="dude, thanks for the echo server!"/&gt;
76 &lt;prop name="test.val"/&gt;
77 ${test.val2}
78 &lt;/post&gt;
79
80</pre><p>
81</p><p>
82Also see the <a href="bk03ch22.html" title="Chapter 22. Grep Task">Grep task</a> for additional examples.
83</p></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="bk03ch16.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="bk03.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="bk03ch18.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Chapter 16. Hostname </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> Chapter 18. SSH and SCP</td></tr></table></div></body></html>
Note: See TracBrowser for help on using the repository browser.