HTTP request request body
The HTTP request transmission method is ASCII code transmission, which generally includes three parts:
status line/request header/message body
<method> <request-URL> <version>
<headers>
<entity-body>
For POST requests, the request data is required to be placed in z, and the encoding method is specified in the request header. Generally, there are four common encoding methods
-
application/x-www-form-urlencoded , the request data is submitted in a form, generally specified in the request header as Content-Type: application/x-www-form-urlencoded;charset=utf-8, the request data is followed by a line of spaces , put in the message body with & splicing, for example: the login request is post, and the parameter is user/pwd
POST http://localhost:8080/login Content-Type: application/x-www-form-urlencoded;charset=utf-8 user=root&pwd=123
-
multipart/form-data, the commonly used encoding method for post requests to submit form files, generally used to upload the encoding specified by the Content-Type of the file, for example:
POST http://www.example.com HTTP/1.1 Content-Type:multipart/form-data; boundary=----WebKitFormBoundaryrGKCBY7qhFd3TrwA ------WebKitFormBoundaryrGKCBY7qhFd3TrwAContent-Disposition: form-data; name="text"
-
application/json, the currently popular restful interface style, generally uses json for front-end and back-end data interaction
. For example:
post http//localhost:8080/login HTTP/1.1
Content-Type:application/json;charset=utf-8
{
user: "root",
pws: "123"
}
- text/xml, xml is used as the http remote call specification, a bunch of codes used in remote back-end calls
POST http://www.example.com HTTP/1.1
Content-Type: text/xml
<?xml version="1.0"?>
<methodCall>
<methodName>user.getUserName</methodName>
<params>
<param>
<value><i4>root</i4></value>
</param>
</params>
</methodCall>
```