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

0

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?

user618156

Posted 2016-07-17T09:48:44.827

Reputation: 1

Answers

1

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

jehad

Posted 2016-07-17T09:48:44.827

Reputation: 1 376