HTTP learning Note (1) ULR syntax

Source: Internet
Author: User
Tags ftp protocol

1, overview

When you open a browser will go to a homepage, maybe you would like to just open the browser, but the browser silently send this page default URL, you just do not know, you just did not input it. Let's do an experiment.

1, double-click to open

2, you can see

Note the URL of the input URL will show Baidu's homepage.

Actually, look at this.

See the regular this column has my default home page set.

So when you open a browser, it sends a request to the server based on the URL of the default home page you set.

So what exactly is this URL we're talking about? Actually called URLs in computer science terminology.

ULR (Uniform Resource Locator): Uniform Resource Locator. Its function is to locate the resources on the Internet, and can use different protocols to access. In general, a URL itself only represents the location of a resource on the server, and can not get resources, when you use the browser to enter a ULR, the browser will send a request for us to the server, the request is exactly the ULR location of the resources, if everything is normal, The server will return to us the results we need, just as you enter https://www.baidu.com/then you will see the server back to you a Baidu first page.

Let me give you an example to illustrate. If you have a phone book with many phone numbers in it, will these phone numbers be different people? In fact, the URL can also be analogous to the telephone number here. Because URLs are actually targeting a lot of resources.

Phone number------URL

1, the phone number can locate a person, and a URL can locate a resource.

2, the phone number is not dialed out of the words of no one else's answer; URLs that are not sent through the browser will naturally get no results. So the two have an important feature is that only identify a person or resource, you must call or send a request to notify the other party.

3, by the second we want to send these send numbers or URLs need a medium, that is, telephone and browser.

4, when the phone call if the number is written off (previously used), the analogy to the URL is now located in the resource does not exist (previously existed), then the phone will not reach the natural, the use of browser access to the resources are not accessible.

5, the fourth is just a simple example, but actually call and access to a resource process is very different, in general, there is a situation in which there is no phone call, there will be no access to a resource, this is a send URL is unsuccessful example.

6, most of the situation the phone is open, you and that phone number to locate the person to establish a connection, naturally, if normal, you use the browser to send a URL to reach the server, that is where the resource exists, then you and the server has established a connection.

7, when the two sides established a connection, natural double can call, you can also access resources on the server.

The syntax of 2,url

The above describes the use of URLs to get resources on the server, then what is the process? This requires knowing the syntax of the URL.

<scheme>://<user>:<password>@

Above the content of the URL is more, in fact, generally will not be used, you see Baidu home? https://www.baidu.com/is just a protocol and a host.

Description

Scheme: scenario, maybe everyone is wondering what this scheme is, in fact, like the HTTP protocol we often see. It provides for the use of only certain protocols.

https://www.baidu.com/such as this HTTPS is a scheme, he is the HTTPS protocol, one thing to note is that the protocol name is not case-sensitive.

User name and password: Some protocols require the use of a user name and password. such as the FTP protocol. For example, if you do not enter a user name and password, there will be a prompt to enter the window.

In fact, you can also follow the format of the URL: there is no input port number, in fact, the FTP protocol has its own default port number 21, so you can not enter.

When all inputs are completed, you can send a request to the Web page, at which point we focus on:

Host and Port: The host is a flag that can identify a server, can be a host name (for example, Baidu home url:https://www.baidu.com/ The host is www.baidu.com), can also be an IP, in fact, this www.baidu.com and some IP is the corresponding, in the sending of this URL will be www.baidu.com resolution to IP. The host and port locate the general location of a resource, the port monitors a service on the server, and the outside world can only communicate with the server through this port. For example, a server has two services, each with one port, and each service has some resources. How do I access resource 2 in service 2 to the server? First of all to access to the server, with IP, how to access to service 2? Using port 2, how do I find resource 2? In fact, the resources are stored in a path, which requires the use of the following format:<scheme>://

Parameters: Through the above analysis, we can already access a resource, in fact, there are many problems, such as a protocol access to a resource using a different way, it can lead to errors. Compared to the chip in the server using binary storage, and FTP protocol transport resources if the use of text form, it will be wrong, this time to explain that we want to use binary form of the resources, this time the parameters are very important.

The Type=d in this ftp://prep.ai.mit.edu/pub/gnu;type=d is the parameter, which consists of the parameter name and the corresponding value. Which uses a semicolon ";" Separate from the previous path area.

Query string: The main function is to query a resource, you can use a special way to reduce the scope of the search, such as resources are the contents of the database, you can query the string to make the judgment range smaller.

http://www.joes-hardware.com/inventory-check.cgi?item=12731 This item=12731 is the query string, which consists of a name and a corresponding value. Which uses the question mark "? "is separated from the previous content area. Multiple name value pairs are used & separated.

Fragment: In fact, the effect of this fragment is to reduce the content of the display. If a resource is larger, say, an HTML page has a lot of content, we just have to show some of the specified content, which requires the use of fragments. However, it is important to note that the HTML resources sent from the server are complete and only displayed on the browser as specified.

HTTP learning Note (1) ULR syntax

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.