1, HTTP Introduction:
HTTP (Hypertext Transfer Protocol) is a stateless, application-level protocol based on request-response mode
2, the URL detailed:
Baidu search for a URL address:
Https://www.baidu.com/s?wd=%E4%B8%8A%E6%B5%B7%E6%82%A0%E6%82%A0%E5%8D%9A%E5%AE%A2&rsv_spt=1&rsv_iqid= 0x91baaabd00070ba2&issp=1&f=8&rsv_bp=1&rsv_idx=2
1.HTTP/HTTPS: protocol type
2.host: Host address or domain name
--192.168.x.xx:8080 Address + port number
--www.xxx.com Domain Name
--localhost:8080 localhost is a native address
3.port: Port number (default port is 80 can be omitted)
4.path: The requested path (after host, question mark?) Before
5.? : Question mark is a split symbol
6. Parameter: Name=value
7.&: Multiple parameters separated by &
3. Get and Post:
1.Get No request body
2.Post has request body (request body can be empty)
4. Request Method:
HTTP requests can use a variety of request methods, depending on the HTTP standard.
HTTP1.0 defines three methods of request: GET, POST, and head.
HTTP1.1 has five new request methods: Options, PUT, DELETE, TRACE, and CONNECT methods.
The GET request specifies the page information and returns the entity principal.
HEAD is similar to a GET request, except that there is no specific content in the returned response, which is used to get the header POST to submit data to the specified resource for processing requests (such as submitting a form or uploading a file). The data is included in the request body. A POST request may result in the creation of new resources and/or modification of existing resources. PUT replaces the contents of the specified document with the data that the client transmits to the server.
The delete request server deletes the specified page.
The Connect http/1.1 protocol is reserved for proxy servers that can change connections to pipelines. The OPTIONS allows clients to view server performance.
TRACE echoes the requests received by the server, primarily for testing or diagnostics.
5. Request Composition:
The client sends an HTTP request to the server for a request message that includes the following format:
Request line, request header (header), blank line, and four parts of request data.
1. Request Line
2. Request Header
3. Middle Empty Line
4. Request Body
6. Request Header:
Client
Accept: Media types acceptable to the browser
Accept-language: Language
Accept-encoding: Encoding Format
User-agent: Client Type
Cookies:
Entity:
Contet-type: When sending the post, the body data type declaration
7. Get Request Parameters:
Get request parameters are in the request line-can be viewed in WebForms querystring
8. Post Request parameters:
The request parameter can be a parameter of the request line Querystring+body
--querystring can be empty
--body can also be empty
9, the body of the post:
There are four common data types for the body of Post:
1. The first type: Application/json: {"input1": "xxx", "Input2": "Ooo", "Remember": false}
2. Second type: Application/x-www-form-urlencoded:input1=xxx&input2=ooo&remember=false
3. Third type: Multipart/form-data: This is a form format
4. Fourth type: Text/xml
<!--? XML version= "1.0"?-->
<methodcall>
<methodname>examples.getStateName</methodname>
10. Respose Results:
In general, the server will return an HTTP response message after receiving and processing a request from the client.
The HTTP response is also made up of four parts: the status line, the message header, the blank line, and the response body.
11. Status Code:
The status code consists of three digits, and the first number defines the category of the response, divided into five categories:
1XX: Indication information--Indicates that the request has been received and continues processing
2XX: Success-Indicates that the request has been successfully received, understood, accepted
3XX: Redirect--further action is required to complete the request
4XX: Client Error--Request syntax error or request not implemented
5XX: Server-side error-the server failed to implement a legitimate request
Common Status Codes:
$ OK//client request succeeded
Bad Request//client requests have syntax errors and cannot be understood by the server
401 Unauthorized//request unauthorized, this status code must be used with the Www-authenticate header field
403 Forbidden//server receives request, but refuses to provide service
404 Not Found//request resource not present, eg: Wrong URL entered
Internal Server error//server unexpected errors
503 Server Unavailable//server is currently unable to process client requests and may return to normal after some time
Python interface Automation Test one: HTTP protocol