1.8. Element post

<post
  url = anyURI
  encoding = any ASCII compatible encoding : "ISO-8859-1"
  readResponse = boolean : false
>
  Content: [ field ]+
</post>

<field
  name = Form field name (US-ASCII only)
>
  Content: value | file
</field>

<value>
  Content: xs:string
</value>

<file
  name = Path
  contentType = Content type
/>

Emulates an HTML form possibly containing input type="file" elements. More precisely, the post element implements HTML5 — Form submission — Multipart form data using emulated input type="text" and input type="file" form fields.

The body of the POST request is encoded as "multipart/form-data" if the post element contains at least one file descendant element. Otherwise this body is encoded as "application/x-www-form-urlencoded".

Optional attribute encoding specifies the character encoding used by the form submission algorithms.

[Important]

Always specify the name of an ASCII compatible encoding (ISO-8859-1, UTF-8, Windows-1252, etc) in the encoding attribute.

An emulated form field has a name specified by required attribute name. There are two type of fields:

value

Emulates input type="text" or input type="hidden" elements found in an HTML form. The content of this element, a possibly empty string, specifies the value of the field.

file

Emulates input type="file" elements found in an HTML form. The name attribute of this element specifies the filename of the file to be uploaded.

Unless specified, the content type of the file is guessed using the extension of the filename. If the filename ends with:

.zip

the content type is supposed to be application/zip;

.jar

the content type is supposed to be application/x-java-archive;

.xml

the content type is supposed to be text/xml.

Otherwise, the content type is supposed to be application/octet-stream.

If attribute readResponse is specified with value true, this element returns the response of the server. Otherwise, this element returns no result at all.

Moreover, for this element to return a result, the server must respond to the post request with a success code different from "No Content" (204) and must send "text/*" data (e.g. "text/plain", "text/html", etc). If the content type of the sent data has no charset, the data is read as a string using charset "ISO-8859-1".

Examples:

<post url="http://localhost:8080/measure/archive">
  <field name="op">
    <value>add</value>
  </field>
  <field name="user">
    <value>%U</value>
  </field>
  <field name="data">
    <file name="/tmp/1052_3_CO_3.1R" />
  </field>
</post>

<post url="http://localhost:8080/measure/archive" 
      readResponse="true">
  <field name="op">
    <value>add</value>
  </field>
  <field name="user">
    <value>%U</value>
  </field>
  <field name="interactive">
    <value>false</value>
  </field>
  <field name="data">
    <file name="1052_3_CO_3.1R" 
          contentType="text/xml; charset=ISO-8859-1" />
  </field>
</post>

<post url="http://www.acme.com/login" 
      encoding="UTF-8" readResponse="true">
  <field name="username">
    <value>admin</value>
  </field>
  <field name="password">
    <value>changeit</value>
  </field>
</post>