SE Can't Code

A Tokyo based Software Engineer. Not System Engineer :(

Tips, GET vs POST.

I'm gonna note down a little tips about the difference between GET and POST in REST architecture.

GET

  • parameters in URL
  • used for fetching documents
  • maximum URL length
  • OK to cache
  • shouldn’t change the server
GET /testform?q=aaaaa HTTP/1.1 
Accept:text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8 
Accept-Language: ja,en-US;q=0.8,en;q=0.6 
Content-Type: ; charset="utf-8" 
Content_Length: 0 
Cookie: request_method=GET 
Host: localhost:8080 
Referer: http://localhost:8080/ 
User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.95 Safari/537.36 X-Appengine-Country: ZZ

POST

  • parameters in body
  • used for updating data
  • no max length
  • not ok to cache
  • ok to change the server
POST /testform HTTP/1.1 
Accept:text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8 
Accept-Language: ja,en-US;q=0.8,en;q=0.6
Cache-Control: max-age=0 
Content-Length: 7 
Content-Type: application/x-www-form-urlencoded; charset="utf-8" Content_Length: 7 
Content_Type: application/x-www-form-urlencoded Cookie: request_method=GET 
Host: localhost:8080 
Origin: http://localhost:8080 
Referer: http://localhost:8080/ 
User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.95 Safari/537.36 X-Appengine-Country: ZZ q=aaaaa

If you don’t follow this rules, you can get into a little trouble.

Remove all ads