Interface Basics

1. What is an interface?

The network connects all aspects of our lives, and the connection point that carries these connections is the network interface. The interface is the entrance and bridge for the connection, interaction and interaction between different network applications.

 

2. Interface test

Interface testing is a type of testing that tests the interface between system components. Interface testing is mainly used to detect the interaction points between the external system and the system and between the various internal subsystems. The focus of the test is to check the data exchange, transfer and control management process, as well as the mutual logical dependencies between systems.

Three, http protocol basics

HTTP, the HyperText Transfer Protocol (HyperText Transfer Protocol), is the most widely used network protocol on the Internet. Currently, version 1.1 is mainly used. It transmits data (HTML, file, data, API interface) based on the TCP/IP communication protocol. message, etc.).

There are four parts : request line, request header, blank line and request data .

 

The following is an example of Baidu request:

GET https://www.baidu.com/ HTTP/1.1 #Request method URL HTTP protocol version Host: www.baidu.com #Request server address #The following is the content of the message header Connection: keep-alive #Connection method: long connection Cache -Control: max-age=0 #Request cache control, you need to confirm whether the request content has been modified Upgrade-Insecure-Requests: 1 #Support https protocol User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36 #Request client, browser version Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng, */*;q=0.8 #Supported response content types Accept-Encoding: gzip, deflate, br #Supported encoding types Accept-Language: zh-CN,zh;q=0.9,en;q=0.8 #Supported languages Cookie: BAIDUID=C0A2... #Cookie information carried #The request message body is not carried, and the body is empty

Fourth, the HTTP method

The HTTP method is the key information carried in the request message, which informs the server of the desired operation type for this request. The following methods are currently common in the HTTP1.1 version:

No.

method

describe

1

GET

Request the specified page information and return the entity body.

2

HEAD

Similar to the get request, except that there is no specific content in the returned response, which is used to get the header

3

POST

Submit data to the specified resource for processing requests (such as submitting a form or uploading a file). Data is included in the request body. POST requests may result in the creation of new resources and/or the modification of existing resources.

4

PUT

Data transferred from the client to the server replaces the contents of the specified document.

5

DELETE

Requests the server to delete the specified page.

6

CONNECT

The HTTP/1.1 protocol is reserved for proxy servers that can change connections to pipes.

7

TRACE

Echo the request received by the server, mainly for testing or diagnostics.

8

PATCH

Transfer data from the client to the server, replacing part of the specified document

HTTP status codes

The HTTP status code defines the result information of the server-side processing of the HTTP request, which mainly includes the following five categories:

status code

describe

1XX

received, pending

2XX

Request processed successfully

3XX

Redirect, resource location changes

4XX

Client request information error

5XX

Server-side processing error

1xx messages

This type of status code indicates that the request has been accepted and needs to continue processing. This type of response is a provisional response, containing only the status line and some optional response header information, and terminated by a blank line. Since no 1xx status codes are defined in the HTTP/1.0 protocol, the server MUST NOT send 1xx responses to such clients except under certain experimental conditions. The responses represented by these status codes are informational and indicate additional actions that the client should take.

2xx success

This type of status code indicates that the request was successfully received, understood, and accepted by the server.

3xx redirect

This type of status code indicates that further action from the client is required to complete the request. Usually, these status codes are used for redirection, and the subsequent request address (redirect target) is indicated in the Location field of this response.

4xx client error

This type of status code represents what appears to be an error on the client side, preventing the server from processing it. Unless responding to a HEAD request, the server SHOULD return an entity explaining the current error condition and whether this is a temporary or permanent condition. These status codes apply to any request method. The browser should display to the user any physical content contained in such error responses

5xx server error

Indicates that the server was unable to complete an apparently valid request. This type of status code represents that the server has an error or an abnormal state in the process of processing the request, or it may be that the server realizes that the processing of the request cannot be completed with the current software and hardware resources. Unless this is a HEAD request, the server SHOULD contain an informational entity explaining the current error status and whether the status is temporary or permanent. The browser SHOULD present to the user any entities included in the current response. These status codes apply to any response method.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324327943&siteId=291194637