HTTP METHODS
HTTP
(HYPERTEXT designed to enable
TRANSFER
communications between clients
and servers.
PROTOCOL)
TWO HTTP REQUEST METHODS: GET AND POST
GET - Requests POST - Submits
data from a data to be
specified resource processed to a
specified resource
THE GET METHOD
• Note that the query string (name/value pairs) is sent
in the URL of a GET request:
/test/demo_form.php?name1=value1&name2=val
ue2
THE POST METHOD
• Note that the query string (name/value pairs) is sent in
the HTTP message body of a POST request:
POST /test/demo_form.php HTTP/1.1
Host: [Link]
name1=value1&name2=value2
GET POST
BACK button/Reload Harmless Data will be re-submitted (the
browser should alert the user
that the data are about to be
re-submitted)
Bookmarked Can be bookmarked Cannot be bookmarked
Cached Can be cached Not cached
Encoding type application/x-www-form- application/x-www-form-
urlencoded urlencoded or multipart/form-
data. Use multipart encoding
for binary data
History Parameters remain in browser Parameters are not saved in
history browser history
GET POST
Restrictions on data length Yes, when sending data, the GET No restrictions
method adds the data to the URL;
and the length of a URL is limited
(maximum URL length is 2048
characters)
Restrictions on data type Only ASCII characters allowed No restrictions. Binary data is also
allowed
Security GET is less secure compared to POST is a little safer than GET
POST because data sent is part because the parameters are not
of the URL stored in browser history or in
web server logs
Never use GET when sending
passwords or other sensitive
information!
Visibility Data is visible to everyone in the Data is not displayed in the URL
URL
GET USER INPUT
ACTIVITY
Compute the 2 numbers for:
Sum:
Difference:
Product
Quotient
Mod: