what is the meaning of "body" in a POST request?

8,389

HTTP POST is a method of sending data as an arbitrary package. This is done in the http protocol, the POST data is sent in the "body", not the URL.

HTTP GET is different, and it's GET that sends the data (restricted) in the URL.

Therefore, in your example, the request will look (in a very simplified way) something like this:

POST /Login HTTP/1.1
Host: localhost
Content-Length: 42
username=admin&password=admin&submit=Login

The last line of this example is the body, whose length is specified in the HTTP header "Content-Length".

Here is an easy reference to show you the difference of POST and GET:
http://www.w3schools.com/tags/ref_httpmethods.asp

Share:
8,389

Related videos on Youtube

user618156
Author by

user618156

Updated on September 18, 2022

Comments

  • user618156
    user618156 over 1 year

    I am new to PHP. I have a stupid question and need your explanation.
    When I make a POST request with the cURL command-line:

    curl -d "username=admin&password=admin&submit=Login" --dump-header headers http://localhost/Login
    

    Please kindly let me know what is the purpose of this command-line. I just wonder whether data "username=admin&password=admin&submit=Login" will be attached to url http://localhost/Login. Then, we have:

    http://localhost/Login/username=admin&password=admin&submit=Login
    

    Is it correct?