Home  >  Article  >  Web Front-end  >  Front-end, HTT, computers and networks

Front-end, HTT, computers and networks

php中世界最好的语言
php中世界最好的语言Original
2018-05-25 11:52:212439browse

This time I will bring you the front-end, HTT, computer and network, what are the precautions for the front-end, HTT, computer and network. The following is a practical case, let's take a look.

Computer network knowledge that full-end engineers need to know

1. Network - Detailed explanation of http messages

1. Classification

  1. Request message

  2. Response message

2. Message structure

(1) Request Message

An HTTP request message consists of request line (request line), request header (header), blank line and request data;
  1. The request line

  • consists of three fields: the request method field, the URL field and the HTTP protocol field. They are composed of Space separated;

  • For example, GET /index.html HTTP/1.1.

  • The request methods of HTTP protocol include GET, POST, HEAD, PUT, DELETE, OPTIONS, TRACE, and CONNECT.

  1. Request header

  • Request header consists of key It consists of word/value pairs, one pair per line, and the keywords and values ​​are separated by English colon ":".

  • The request header informs the server about the client's request;

  • Commonly used request headers:

  1. Accept sets the accepted content typeAccept: text/plain;

  2. Accept-Charset sets the accepted characters Encoding:Accept-Charset: utf-8;

  3. Accept-Encoding Set the accepted encoding format:Accept-Encoding: gzip, deflate ;

  4. Accept-Language Set the accepted language:Accept-Language: en-US;

  5. Cache-Control Set the instructions that all caching mechanisms in the request response chain must comply with: Cache-Control: no-cache;

  6. Connection Set the current connection and hop-by-hop Control options for the protocol request field list:Connection: keep-alive;

  7. Content-Length Set the byte length of the request body:Content-Length: 348;

  8. Content-Type Set the MIME type of the request body (applicable to POST and PUT requests): Content-Type: application/x-www-form-urlencoded ;

  9. Cookie sets the http cookie sent by the server using Set-Cookie:Cookie: $Version=1; Skin=new;;

  10. Host sets the server domain name and TCP port number. If the service request standard port number is used, the port number can be omitted: Host: en.wikipedia.org:8080;

  11. Origin identifies cross-domain resource requests (requesting the server to set the Access-Control-Allow-Origin response field): Origin: http://www.example-social-network.com ;

  12. Expires Set the expiration time of the response body:Expires: Thu, 01 Dec 1994 16:00:00 GMT;

  13. ETag Identifier of a specific version resource, usually a message digest: ETag: "737060cd8c284d8af7ad3082f209582d";

  14. Last-Modified sets the last request object Last-Modified date: Last-Modified: Tue, 15 Nov 1994 12:45:26 GMT;

  1. Empty line

  • The last request header is followed by an empty line, sending carriage return and line feed characters to notify the server that there are no more request headers below. .

  1. Request body (data)

  • The request data is not available used in the GET method, but used in the POST method. The POST method is suitable for situations where customers are required to fill out a form. The most commonly used request headers related to request data are Content-Type and Content-Length.

(2) Response message

HTTP response also consists of four parts, namely: status line, message header, blank line, and response body.
  1. The only real difference in the response is that status information replaces the request information in the first line. The status line describes the requested resource by providing a status code.

  2. Status Line

  • Format: Version of the server HTTP protocol response status code status code Text description;

  • The status code consists of three digits. The first digit defines the category of the response and has five possible values:

    • 1xx: Indication information--indicates that the request has been received and processing continues.

    • 2xx: Success--Indicates that the request has been successfully received, understood, and accepted.

    • 3xx: Redirect--Further operations must be performed to complete the request.

    • 4xx: Client error--The request has a syntax error or the request cannot be fulfilled.

    • 5xx: Server-side error -- The server failed to fulfill a legitimate request.

  • Common status codes:

    • 200 OK: Indicates that the request is successful and everything is normal

    • 301 Moved Permanently: Redirect, the document requested by the customer is elsewhere, new URL Given in the Location header, the browser should automatically access the new URL

    • 302 Found: Temporary redirect, similar to 301, but the new URL should be treated as temporary Replacement, not permanent.

    • 304 Not Modified: The client has a buffered document and issued a conditional request. The server tells the client that the original buffered document can continue to be used.

    • 400 Bad Request: There is a syntax error in the request.

    • 403 Forbidden: The resource is unavailable.

    • 404 Not Found: The resource at the specified location cannot be found.

    • 405 Method Not Allowed: The request method (GET, POST, HEAD, Delete, PUT, TRACE, etc.) is not applicable to the specified resource.

    • 500 Internal Server Error: The server encountered an unexpected situation and was unable to complete the client's request.

    • 501 Not Implemented: The server does not support the functions required to implement the request

(3) About requesting post and get Difference

  1. GET submission, the requested data will be appended to the URL (that is, the data is placed in the HTTP protocol header );

  2. POST submission: Place the submitted data in the body of the HTTP package;

  3. Size of transmitted data:

  • The HTTP protocol does not limit the size of transmitted data, and the HTTP protocol specification does not limit the length of the URL.

  • The limitations that exist in actual development mainly include:

    • GET: Specific browsers and servers have restrictions on URL length. , for example, IE's limit on URL length is 2083 bytes (2K 35). For other browsers, such as Netscape, FireFox, etc., there is theoretically no length limit, and the limit depends on the support of the operating system. Therefore, when submitting GET, the transmitted data will be limited by the length of the URL.

    • POST: Since the value is not passed through the URL, the data is theoretically unlimited. However, each WEB server actually stipulates limits on the size of post submission data. Apache and IIS6 have their own configurations.

4. Security:

  • The security of POST is higher than that of GET.

  • Submit data through GET, the username and password will appear in clear text on the URL, because

  • (1) The login page may be blocked by the browser Cache,

  • (2) If other people view the history of the browser, then others can get your account number and password

(4) http and https

1. HTTP and HTTPS

  • HTTP protocol is usually carried on top of TCP protocol. Add a security protocol layer (SSL or TSL) between them. At this time, it becomes what we often call HTTPS

  • The default port number of HTTP is 80 and the port number of HTTPS is 443

2. Why HTTPS is secure

  • Because network requests require forwarding by many server routers in the middle. Intermediate nodes may tamper with information, and if you use HTTPS, the key is only between you and the end station. The reason why https is more secure than http is that it uses the SSL/TLS protocol for transmission. It includes certificates, offloading, traffic forwarding, load balancing, page adaptation, browser adaptation, refer delivery, etc. Ensures the security of the transmission process

3. About HTTP 2.0

  • ##HTTP/2 introduces the "server side" The concept of "server push" allows the server to proactively send data to the client cache before the client needs the data, thereby improving performance.

  • HTTP/2 provides more encryption support

  • HTTP/2 uses multiplexing technology, allowing multiple messages to be sent simultaneously on one connection Crossover.

  • It adds header compression, so even for very small requests, the request and response headers will only occupy a small proportion of the bandwidth

4. http Disadvantages:

  • Communication uses plain text and is not encrypted, and the content may be stolen;

  • If the identity of the communicating party is not verified, it may be disguised;

  • The integrity of the message cannot be verified and it may be tampered with.

https is encrypted (usually SSL secure communication line) authentication integrity protection

5. HTTP/2 and HTTP/1.x The key difference

  • The binary protocol replaces the text protocol, which is more concise and efficient

  • Uses only one multiplexer for each domain Connection

  • Compress header information to reduce overhead

  • Allow the server to actively push responses to the client's cache

(5), http status code

 简单版
    [
        100  Continue   继续,一般在发送post请求时,已发送了http header之后服务端将返回此信息,表示确认,之后发送具体参数信息
        200  OK         正常返回信息
        201  Created    请求成功并且服务器创建了新的资源
        202  Accepted   服务器已接受请求,但尚未处理
        301  Moved Permanently  请求的网页已永久移动到新位置。
        302 Found       临时性重定向。
        303 See Other   临时性重定向,且总是使用 GET 请求新的 URI。
        304  Not Modified 自从上次请求后,请求的网页未修改过。

        400 Bad Request  服务器无法理解请求的格式,客户端不应当尝试再次使用相同的内容发起请求。
        401 Unauthorized 请求未授权。
        403 Forbidden   禁止访问。
        404 Not Found   找不到如何与 URI 相匹配的资源。

        500 Internal Server Error  最常见的服务器端错误。
        503 Service Unavailable 服务器端暂时无法处理请求(可能是过载或维护)。
    ]

2. Network - Others

1. A page is completed from entering the URL to the page loading display , what happened in this process? (The more detailed the process, the better)
What happens in the process from inputting the URL to the completion of page loading and display on a page

2. Let’s talk about network layering What are the seven layers of the seven-layer model

  • Application layer: application layer, presentation layer, session layer (from top to bottom) (HTTP, FTP, SMTP, DNS)

  • Transport layer (TCP and UDP)

  • Network layer (IP)

  • Physical and data link Road layer (Ethernet)

  • The functions of each layer are as follows:

  • Physical layer: transmits bits through the medium and determines mechanical and electrical specifications (Bit) Data link layer: Assembling bits into frames and point-to-point transmission (Frame)

    • Network layer: Responsible for the transmission of data packets from source to sink Delivery and Internet interconnection (Packet)

    • Transport layer: Provides end-to-end reliable message delivery and error recovery (Segment)

    • Session layer: Establish, manage and terminate sessions (Session Protocol Data Unit SPDU)

    • Presentation layer: Translate, encrypt and compress data (Representation Protocol Data Unit PPDU)

    • Application layer: means to allow access to the OSI environment (Application Protocol Data Unit APDU)

3. Principle of 304 cache

  • The server first generates the ETag, which the server can use later to determine whether the page has been modified. Essentially, the client asks the server to verify its (client) cache by passing this token back to the server.

  • 304 is an HTTP status code that the server uses to indicate that the file has not been modified and will not return Content, after receiving a status code, the browser will use the file

  • that the browser has cached to request a page (A). The server returns page A and adds an ETag to A. The client renders the page and caches the page along with the ETag. The client requests page A again and passes it to the server together with the ETag returned by the server during the last request. The server checks the ETag and determines that the page has not been modified since the last client request, and directly returns response 304 (Not Modified) and an empty response body

  • Know more--Browser cache article

I believe you have mastered the method after reading the case in this article. For more exciting information, please pay attention to other related matters on the php Chinese website article!

Recommended reading:

Oday privilege escalation and detailed steps to obtain root permissions of the mall server in batches

Used in HTML Summary of JS methods

The above is the detailed content of Front-end, HTT, computers and networks. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn