Better never to be born than to waste your life doing nothing — Napoleon

concise

  1. URL: Uniform Resource Locator
  2. The browser is one withMultiple client functionsthecomprehensiveClient software
  3. The browser’s first job is to parse the URL
  4. The request message contains two parts: what to do and what to do
  5. Message headers are classified by purposeFour categories:

    1. General head: Header fields that apply to requests and responses

    2. Request header: A header field used to represent additional information about the request message

    3. Response headers: Header field used to represent additional information about the response message

    4. Entity head: Header field for additional information in the message body
  6. The first digit of the status code indicates the status type, and the second and third digits indicate the specific situation
  7. Only one URI can be written to a request message. If you need to fetch multiple files, you must send a separate request for each file.

The article summary

  1. What is a URL?
  2. Browser parsing URL
  3. Omitting the file name
  4. The basic idea of HTTP
  5. Generate an HTTP request message
  6. The request is sent and the response is received

1. What is a URL?

URL: Uniform Resource Locator (URL) is the address of a standard Resource on the Internet.

Every file on the Internet has a unique URL that contains information about where the file is and what the browser should do with it.

The basic URL contains: mode (or protocol), server name (or IP address/URL), path, and file name.

The protocol part is delimited with //, for example, Protocol: // Authorization/path? The query “.

The general syntax format is protocol :// hostname[:port] / path / [;parameters][? Query]#fragmen

The reason for the variety of urls is that although we usually use a browser to access a Web server, there is more to the browser than that.

Browser is a comprehensive client software with a variety of client functions

The text at the beginning of the URL, namely “HTTP:” “FTP:” “file:” “mailto:”, indicates the access method that the browser should use.


2. The browser parses the URL

The first step for the browser is to parse the URL to generate a request message to the Web server.

The split result contains the Web server name www.lab.glasscom.com and the path name of the file /dir1/file1.html.

Therefore, we know that the URL means to access the file named /dir/file1.html on the Web server www.lab.glasscom.com, which is the file file1.html in directory D under /dir/.


3. Omit the file name

Sometimes we see different urls, such as this one that ends with a “/”.

http://www.wl.com/dir/
Copy the code

The ‘/’ ending indicates that /dir/ should have been followed by a file name that has been omitted. According to URL rules, the file name can be omitted as above.

Set the default file name on the server to access when the file name is omitted. In most cases, the file name is index.html or default.html.

Some urls are Web server-only domain names like the following

http://www.wl.com/
Copy the code

It represents access to a directory named /. Also, since the file name is omitted, the result is to access files like /index.html or /default.html.

The browser’s first job is to parse the URL


4. The basic idea of HTTP

The HTTP protocol defines the message content and steps for interaction between a client and a server

The client sends a request message to the server

The request message contains two parts: what to do and what to do

1. To what (URI)

The “to what” part of this is called the URI. Generally, the content of a URI is the file name of a web page data or the file name of a CGI program, such as /dir1/file1.html /dir1/program1.cgi.

In other words, various access targets can be written, and these access targets are collectively called URIs

URI: Uniform Resource Identifier

2. What kind of operation (method)

The “what to do” part is called a method. Methods represent what needs to be done by the Web server. Typical examples include reading data represented by the URI, sending data entered by the client to the program represented by the URI, and so on.


5. Generate HTTP request messages

After the URL is parsed, the browser determines the Web server and file name, and it is up to the browser to generate the HTTP request message from this information.

1. The request

The first line of the request message is called the request line.

The focus here is on the initial method, which tells the Web server what it should do.

There are many ways, and we have to decide which one we should choose. The key to solving this problem lies in the working state of the browser.

A scenario in which a browser sends a request message to a Web server.

  • Enter the url (Get status) in the address bar at the top of your browser
  • Click on the hyperlink in the page (Get state)
  • After filling in the form, click “Submit” button (Post/Get status)
  • .

After writing the method, add a space and write the URI

The FORMAT of the URI part is as follows, usually the path names of files and programs.

/< directory name >/... /< file name >

The pathname is usually already included in the URL, so just extract it from the URL and write it in.

The HTTP version number needs to be written at the end of the first line to indicate which version of the HTTP specification the message was written based on. That’s it. That’s the end of the first line.

2. The message header

In some cases, additional details are required, and the function of the header is to store this information.

Message headers can be divided into four categories according to their usage. 1. Generic headers: header fields applicable to requests and responses 2. Request header: a header field used to represent additional information about the request message 3. Response header: a header field used to represent additional information about the response message 4. Entity header: Header field for additional information in the message body

3. The body of the message

After writing the header, you need to add an empty line with no content at all, followed by the data you want to send. This part is called the message body, which is the body of the message.


6. The system receives a response after sending a request

In the response message, the first line contains the status code and the response phrase, which indicate whether the request was executed successfully or in error.

A status code is a number used to inform the program of the result of execution.

A response phrase is a piece of text that informs the person of the result of the execution.

The first digit of the status code indicates the status type, and the second and third digits indicate the specific situation

Only one URI can be written to a request message. If you need to fetch multiple files, you must send a separate request for each file.

After the response message is returned, the browser extracts the content-Type and displays it on the screen.

For the rest of the process, see how the page is generated (macro perspective)

Afterword.

Sharing is an attitude. This article, mainly from How the Internet Is Connected, can be regarded as a record and summary of a self-learning process. Basically, it’s a list of what you think is important. At the same time, but also for everyone to save the time of mine clearance and trample pits. Of course, some points may not be well expressed due to the limitations of their own cognitive ability. If you want to see the original, “wall crack recommended” to see the original.

References:

  1. What does URL mean
  2. How is the network connected

See all see here, that bother, move a little hand, a key three even wow