English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

HTML Reference Manual

HTML Tag Reference

HTTP Methods GET and POST

The two most commonly used HTTP methods are: GET and POST.

What is HTTP?

The design purpose of Hypertext Transfer Protocol (HTTP) is to ensure communication between client and server.

The way HTTP works is the request between client and server-Response protocol.

Web browsers may be clients, and network applications on computers may also act as server-side.

For example, the client (browser) submits an HTTP request to the server; the server returns a response to the client. The response contains status information about the request and possibly the content requested.

Two HTTP request methods: GET and POST

Request between client and server-The two most commonly used methods for responding are: GET and POST.

  • GET - Request data from the specified resource.

  • POST - Submit the data to be processed to the specified resource.

GET method

Please note, the query string (name/Pairs of values) are sent in the URL of the GET request:

/run/demo-form.php?name1=value1&name2=value2

Some other comments about GET requests:

  • GET requests can be cached

  • GET requests are retained in the browser history

  • GET requests can be bookmarked

  • GET requests should not be used when handling sensitive data

  • GET requests have length limits

  • GET requests should only be used to retrieve data

POST method

Please note, the query string (name/Pairs of values) are sent in the body of the HTTP message in POST requests:

POST /run/demo-form.php HTTP/1.1
Host: oldtoolbag.com
name1=value1&name2=value2

Some other comments about POST requests:

  • POST requests will not be cached

  • POST requests will not be retained in the browser history

  • POST cannot be bookmarked

  • There is no requirement for data length in POST requests

Comparison of GET and POST

The following table compares the two HTTP methods: GET and POST.

 GETPOST
Back button/RefreshHarmlessThe data will be resubmitted (the browser should inform the user that the data will be resubmitted).
BookmarkCan be bookmarkedCannot be bookmarked
CacheCan be cachedCannot be cached
Encoding typeapplication/x-www-form-urlencodedapplication/x-www-form-urlencoded or multipart/form-data. Use multiple encodings for binary data.
HistoryThe parameters are retained in the browser history.The parameters will not be saved in the browser history.
Limitation on data lengthYes. When sending data, the GET method adds data to the URL; the length of the URL is limited (the maximum length of the URL is 2048 characters).Unrestricted.
Restrictions on data typesOnly allows ASCII characters.No restrictions. Also allows binary data.
SecurityCompared to POST, GET has poorer security because the data sent is part of the URL.
Never use GET when sending passwords or other sensitive information!
POST is safer than GET because parameters are not saved in the browser history or web server logs.
VisibilityData in the URL is visible to everyone.Data will not be displayed in the URL.

Other HTTP Request Methods

The following table lists some other HTTP request methods:

MethodDescription
HEADSame as GET, but only returns HTTP headers, not the document body.
PUTUpload the specified URI representation.
DELETEDelete the specified resource.
OPTIONSReturn the HTTP methods supported by the server.
CONNECTConvert the request connection to a transparent TCP/IP Channel.