HTTP Request Examples
The form above contains four controls:
- A text field bearing the name
name - A checkbox bearing the name
married - Another checkbox bearing the name
male - An unnamed Submit button
The precise HTTP request sent out depends on the enctype and method specifications. The data sent out for the four possible combinations are displayed below:
GET /en/html/dummy.php?name=MyName&married=not+single &male=yes HTTP/1.1 Host: www.explainth.at User-Agent: Mozilla/5.0 (Windows;en-GB; rv:1.8.0.11) Gecko/20070312 Firefox/1.5.0.11 Accept: text/xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5 Accept-Language: en-gb,en;q=0.5 Accept-Encoding: gzip,deflate Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7 Keep-Alive: 300 Connection: keep-alive Referer: http://www.explainth.at/en/misc/httpreq.shtml
enctype="application/x-www-form-urlencoded" method="GET"Note how the form data has been appended to the URL.
POST /en/html/dummy.php HTTP/1.1 Host: www.explainth.at User-Agent: Mozilla/5.0 (Windows;en-GB; rv:1.8.0.11) Gecko/20070312 Firefox/1.5.0.11 Accept: text/xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5 Accept-Language: en-gb,en;q=0.5 Accept-Encoding: gzip,deflate Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7 Keep-Alive: 300 Connection: keep-alive Referer: http://www.explainth.at/en/misc/httpreq.shtml Content-Type: application/x-www-form-urlencoded Content-Length: 39 name=MyName&married=not+single&male=yes
enctype="application/x-www-form-urlencoded" method="POST"Points to note
- The URL simply indicates the Internet resource to be accessed.
- The HTTP header specifies
Content-Type: application/x-www-form-urlencoded - The header also specifies
Content-Length: 39 - The HTTP header is followed by a blank line - caused by a pair of CR/LF characters.
- The compacted, URL encoded, form data string follows. It has a length of 39 bytes.
GET /en/html/dummy.php?name=MyName&married=not+single& male=yes HTTP/1.1 Host: www.explainth.at User-Agent: Mozilla/5.0 (Windows;en-GB; rv:1.8.0.11) Gecko/20070312 Firefox/1.5.0.11 Accept: text/xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5 Accept-Language: en-gb,en;q=0.5 Accept-Encoding: gzip,deflate Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7 Keep-Alive: 300 Connection: keep-alive Referer: http://www.explainth.at/en/misc/httpreq.shtml?txt=
enctype="multipart/form-data" method="GET"Note that the multipart/form-data specification was simply ignored by the browser.
POST /en/html/dummy.php HTTP/1.1 Host: www.explainth.at User-Agent: Mozilla/5.0 (Windows;en-GB; rv:1.8.0.11) Gecko/20070312 Firefox/1.5.0.11 Accept: text/xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5 Accept-Language: en-gb,en;q=0.5 Accept-Encoding: gzip,deflate Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7 Keep-Alive: 300 Connection: keep-alive Referer: http://www.explainth.at/en/misc/httpreq.shtml?txt= Content-Type: multipart/form-data; boundary=---------------------------103832778631715 Content-Length: 355 -----------------------------103832778631715 Content-Disposition: form-data; name="name" MyName -----------------------------103832778631715 Content-Disposition: form-data; name="married" not single -----------------------------103832778631715 Content-Disposition: form-data; name="male" yes -----------------------------103832778631715--
enctype="multipart/form-data" method="POST"Points to note
- The URL simply indicates the Internet resource to be accessed.
- The HTTP header specifies
Content-Type: multipart/form-data - Also specified is a sequence of bytes which do not occur anywhere in the data to follow. This is the
---------------------------103832778631715 - The header also specifies
Content-Length: 355 - The HTTP header is followed by a blank line - caused by two pairs of CR/LF characters.
- Following this we have
--boundaryand a CR/LF pair. - Next we have the first item of form data - the text field.
- The other form fields follow in sequence.
- The termination of data is indicated by the sequence
--boundary--
These examples were captured using FireFox. Although they differ in detail, both Opera and IE yield similar results. If you plan to use these examples to capture HTTP requests in your own custom server be aware that the order of entries in the request header may be different.
