Stereotype--reflection, http learning

1. What is the reflection mechanism

First understand two concepts: compile time and run time.

The compilation period is the process of handing over the source code to the compiler and compiling it into a file that can be executed by the computer. It just treats the code as text and operates it.

The runtime is to hand over the compiled file to the computer for execution, knowing that the program runs to save water, and put the code on the disk into the memory

Reflection means that any class can obtain its properties and methods during runtime, and any object can call its properties and methods. This function of dynamically obtaining information and dynamically calling object methods and properties is the reflection mechanism.

2. HTTP protocol

Detailed Explanation of HTTP Protocol Format - City of Luye - Blog Park

1. URI structure

1. Agreement part

URLThe protocol part of this is , http:indicating that the webpage uses HTTPthe protocol, and the latter //is the separator

2. Domain name part

The domain name is www.fishbay.cn, when sending a request, it needs to DNSbe resolved to the server IP. If it is to optimize the request, it can be IPused directly as part of the domain name

3. Port part

The port after the domain name is separated 80from the domain name, and :the port is not a URLnecessary part. If the port is 80, it can also be omitted

4. Virtual directory part

From the first /to the last of the domain name /, it is the part of the virtual directory. Among them, the virtual directory is not URLa necessary part, the virtual directory in this example is/mix/

5. File name part

From the last part of the domain name /to ?the end, it is the file name part; if not ?, it is from the last part of the domain name /to #the end, it is the file name part; if there is no ?sum , then it is the file name from the beginning to the end of #the last part of the domain name /name part. The file name in this example is 76.html, and the file name is not a URLnecessary part. If there is no file name, the default file name will be used

6. Anchor part

From #start to finish, it's the anchor part. The anchor part of this part is firstthat the anchor is not a URLrequired part

7. Parameters section

The part from ?the beginning to #the end is the parameter part, also known as the search part and the query part. The parameter in this example is name=kelvin&password=123456, if there are multiple parameters, each parameter is used &as a separator.

2. Request

An HTTP request consists of four parts: request line, request header, blank line, and request data.

Http request message structure

1. Request line

GETis the request type, /mix/76.html?name=kelvin&password=123456is the resource to be accessed, HTTP/1.1and is the protocol version

2. Request header

Starting from the second line is the request header, Hostindicating the destination of the request (host domain name); User-Agentit is the information of the client, which is important information for detecting the browser type, defined by the browser, and automatically sent in each request.

3. Empty line

There must be a blank line after the request header

4. Request data

The requested data is also called the request body, and any other data can be added. The request body for this example is empty.

Response

Under normal circumstances, after the server receives the client's request, there will be a HTTPresponse message, and the HTTP response is also 4composed of parts, namely: status line, response header, blank line and response body.

http response message format

1. Status line

The status line consists of the protocol version number, status code, and status message

2. Response header

The response header is some information that the client can use, such as: Date(the date when the response was generated), Content-Type(MIME type and encoding format), Connection(the default is a long connection), etc.

3. Empty line

There must be a blank line between the response header and the response body

4. Response body

Response body, in this case key-value pair information

Guess you like

Origin blog.csdn.net/qq_41286356/article/details/121452034