HTTP POST

HTTP POST

HTTP POST is a request made by a client to submit data or update resources on a web server via the HTTP protocol. In a web browser, it is commonly performed when submitting a form on a web page. POST is an action verb of the HTTP protocol that used instead of GET when the request is expected to alter resources on the server or cause side effects.

Structured data and multiple files can sent to the server as part of the request. For submitting data alone via HTTP POST, the same encoding format as used for query strings may be used in the body of the request. This is called URL encoding, and recognized by server by the Content-Type header value of application/x-www-form-urlencoded. Name/value variables are separated by an ampersand, and any special characters are encoded by using a percent sign followed by the hexadecimal ASCII code for the character. This procedure is defined in RFC 1738; JavaScript provides the function encodeURIComponent to assist with this process, and PHP provides the function urlencode.

For sending binary data or multiple files using HTTP POST, another encoding format called multipart/form-data exists. It follows the rules of multipart MIME streams and is described briefly in the HTML spec.

Let's say there is a script at http://example.com/order.php which expects to be passed two variables by the names "fruit" and "size". Then a POST request to the server would look like the following:

POST /order.php HTTP/1.1
Host: example.com
Content-Length: 21
Content-Type: application/x-www-form-urlencoded

fruit=kiwi&size=large

Certain VoiceXML tags will construct and perform a POST request. Note the use of the method attribute:

<submit next="http://example.com/order.php" namelist="fruit size" method="post"/>
<subdialog src="http://example.com/order.php" namelist="fruit size" method="post"/>

Say there is an audio recording in the variable rec that should be submitted to the server instead. Because a recording is binary data, the default encoding type of application/x-www-form-urlencoded will not work. In this case we would want the encoding type to be multipart/form-data, so we change the above by adding an enctype attribute:

<submit next="http://example.com/order.php" namelist="rec" method="post" 
    enctype="multipart/form-data"/>
<subdialog src="http://example.com/order.php" namelist="rec" method="post" 
    enctype="multipart/form-data"/>

The server will receive the recording as if it were a file uploaded from a web browser.

For more information, see the Plum developer documentation, chapter 5, on "Data Exchange."

Related terms

for "HTTP POST"

Search Glossary

Term of the Day

Within telecommunications, fault tolerance is an operational design that enables some components of a system to remain functional, even after others fail.