Debian Codegraph @

docs/manual/tasks/post_task.html

raw symbols SCIP
1 <html>
2 <head>
3 <META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
4 <title>
5 HTTP Post</title>
6 <meta content="DocBook XSL Stylesheets V1.60.1" name="generator">
7 <link rel="home" href="index.html" title="Antelope Users Guide">
8 <link rel="up" href="bk03.html" title="Additional Ant Tasks">
9 <link rel="previous" href="bk03ch11.html" title="Chapter&nbsp;11.&nbsp;Math">
10 <link rel="next" href="bk03ch13.html" title="Chapter&nbsp;13.&nbsp;SSH and SCP">
11 </head>
12 <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
13 <div class="chapter" lang="en">
14 <div class="titlepage">
15 <div>
16 <div>
17 <h2 class="title">
18 <a name="post">
19 </a>
20 HTTP Post</h2>
21 </div>
22 </div>
23 <div>
24 </div>
25 </div>
26 <p>
27 The 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.
28 </p>
29 <p>
30 Basically, 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.
31 </p>
32 <p>
33 This task handles cookies correctly, which is useful for websites that set a session id to track logins or whatever. This means that if you do several posts in a row, cookies gathered from the first post will be returned with subsequent posts.
34 </p>
35 <p>
36 The 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.
37 </p>
38 <p>
39
40 <div class="table">
41 <a name="N10A61">
42 </a>
43 <p class="title">
44 <b>
45 Table&nbsp;12.1.&nbsp;Post Task Attributes</b>
46 </p>
47 <table summary="Post Task Attributes" border="1">
48 <colgroup>
49 <col>
50 <col>
51 <col>
52 <col>
53 </colgroup>
54 <thead>
55 <tr>
56 <th>
57 Attribute</th>
58 <th>
59 Description</th>
60 <th>
61 Default</th>
62 <th>
63 Required</th>
64 </tr>
65 </thead>
66 <tbody>
67 <tr>
68 <td>
69 to</td>
70 <td>
71 The URL of the remote server to send the post.</td>
72 <td>
73 None</td>
74 <td>
75 Yes</td>
76 </tr>
77 <tr>
78 <td>
79 encoding</td>
80 <td>
81 Character encoding for the name/value pairs.</td>
82 <td>
83 UTF-8</td>
84 <td>
85 No</td>
86 </tr>
87 <tr>
88 <td>
89 logfile</td>
90 <td>
91 The name of a file to write any response to. Ignored if wantresponse is set to false.</td>
92 <td>
93 None</td>
94 <td>
95 No</td>
96 </tr>
97 <tr>
98 <td>
99 property</td>
100 <td>
101 The name of a property to write any response to. Ignored if wantresponse is set to false.
102 </td>
103 <td>
104 None</td>
105 <td>
106 No</td>
107 </tr>
108 <tr>
109 <td>
110 append</td>
111 <td>
112 Should an existing log file be appended to or overwritten?</td>
113 <td>
114 True, append to an existing file.</td>
115 <td>
116 No</td>
117 </tr>
118 <tr>
119 <td>
120 file</td>
121 <td>
122 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>
123 <td>
124 None</td>
125 <td>
126 No</td>
127 </tr>
128 <tr>
129 <td>
130 rawFile</td>
131 <td>
132 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!<br/>
133 Has only impact when the property 'file' is specified.</td>
134 <td>
135 False, treat file as property-like</td>
136 <td>
137 No</td>
138 </tr>
139 <tr>
140 <tr>
141 <td>
142 rawFileNoEncoding</td>
143 <td>
144 Don't encode the raw file prior to sending http post request.<br/>
145 Has only impact when the property 'rawFile' is specified.</td>
146 <td>
147 False, http-encode the content of the file</td>
148 <td>
149 No</td>
150 </tr>
151 <tr>
152 <td>
153 maxwait</td>
154 <td>
155 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>
156 <td>
157 180 (3 minutes)</td>
158 <td>
159 No</td>
160 </tr>
161 <tr>
162 <td>
163 wantresponse</td>
164 <td>
165 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>
166 <td>
167 true</td>
168 <td>
169 No</td>
170 </tr>
171 <tr>
172 <td>
173 failonerror</td>
174 <td>
175 Whether the build should fail if the post fails.</td>
176 <td>
177 false</td>
178 <td>
179 No</td>
180 </tr>
181 </tbody>
182 </table>
183 </div>
184
185 </p>
186 <p>
187
188 Post 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.
189 </p>
190 <p>
191
192 <div class="table">
193 <a name="N10ABF">
194 </a>
195 <p class="title">
196 <b>
197 Table&nbsp;12.2.&nbsp;Prop Attributes</b>
198 </p>
199 <table summary="Prop Attributes" border="1">
200 <colgroup>
201 <col>
202 <col>
203 <col>
204 <col>
205 </colgroup>
206 <thead>
207 <tr>
208 <th>
209 Attribute</th>
210 <th>
211 Description</th>
212 <th>
213 Default</th>
214 <th>
215 Required</th>
216 </tr>
217 </thead>
218 <tbody>
219 <tr>
220 <td>
221 name</td>
222 <td>
223 The name of a property to post.</td>
224 <td>
225 None</td>
226 <td>
227 Yes</td>
228 </tr>
229 <tr>
230 <td>
231 value</td>
232 <td>
233 The value associated with the name.</td>
234 <td>
235 None</td>
236 <td>
237 No</td>
238 </tr>
239 </tbody>
240 </table>
241 </div>
242
243 </p>
244 <p>
245
246 The "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:
247 </p>
248 <p>
249
250 <table border="0" bgcolor="#E0E0E0">
251 <tr>
252 <td>
253 <pre class="programlisting">
254
255
256 &lt;property name="src.dir" value="/home/user/project/src"/&gt;
257
258 </pre>
259 </td>
260 </tr>
261 </table>
262
263 </p>
264 <p>
265
266 Then the following are equivalent:
267 </p>
268 <p>
269
270 <table border="0" bgcolor="#E0E0E0">
271 <tr>
272 <td>
273 <pre class="programlisting">
274
275
276 &lt;prop name="src.dir"/&gt;
277 &lt;prop name="src.dir" value="${src.dir}"/&gt;
278 &lt;prop name="src.dir" value="/home/user/project/src"/&gt;
279
280 </pre>
281 </td>
282 </tr>
283 </table>
284
285 </p>
286 <p>
287
288 Defined Ant properties can be entered directly into the post element. Again, suppose the build file has this property defined:
289 </p>
290 <p>
291
292 <table border="0" bgcolor="#E0E0E0">
293 <tr>
294 <td>
295 <pre class="programlisting">
296
297
298 &lt;property name="src.dir" value="/home/user/project/src"/&gt;
299
300 </pre>
301 </td>
302 </tr>
303 </table>
304
305 </p>
306 <p>
307
308 Then the following are equivalent:
309 </p>
310 <p>
311
312 <table border="0" bgcolor="#E0E0E0">
313 <tr>
314 <td>
315 <pre class="programlisting">
316
317
318 ${src.dir}
319 &lt;prop name="src.dir"/&gt;
320 &lt;prop name="src.dir" value="${src.dir}"/&gt;
321 &lt;prop name="src.dir" value="/home/user/project/src"/&gt;
322
323 </pre>
324 </td>
325 </tr>
326 </table>
327
328 </p>
329 <p>
330
331 I googled for the URL in the following example.
332 </p>
333 <p>
334
335 <table border="0" bgcolor="#E0E0E0">
336 <tr>
337 <td>
338 <pre class="programlisting">
339
340
341 &lt;property name="test.val" value="here's my test value"/&gt;
342 &lt;property name="test.val2" value="second test value"/&gt;
343 &lt;post to="http://wwwj.cs.unc.edu:8888/tang/servlet/tangGetPostServlet"
344 verbose="true"&gt;
345 &lt;prop name="prop1" value="val1 ${test.val}"/&gt;
346 &lt;prop name="prop2" value="val1 value 2"/&gt;
347 &lt;prop name="prop3" value="val got some spaces %funky ^$* chars"/&gt;
348 &lt;prop name="prop4" value="&amp;amp; do an ampersand like this &amp;amp;amp; or
349 Ant will whine"/&gt;
350 &lt;prop name="thanks" value="dude, thanks for the echo server!"/&gt;
351 &lt;prop name="test.val"/&gt;
352 ${test.val2}
353 &lt;/post&gt;
354
355 </pre>
356 </td>
357 </tr>
358 </table>
359
360 </p>
361 </div>
362 <hr>
363 <p align="center">Copyright &copy; 2003 Ant-Contrib Project. All
364 rights Reserved.</p>
365 </body>
366 </html>