知识库 知识库
首页
  • Hyperskill - Java

    • Java basic
    • Java OOP
    • 应知
    • 扩展
    • IO & Stream
    • Error & Exception
    • Algorithm & Data structure
    • Design pattern
    • Web
    • Spring boot
  • 练习题

    • 选择题 & 填空题
    • 代码题
  • Frank - Java与生活 (OOP)

    • 参考资料
    • Java基础
    • OOP上半部分
    • OOP下半部分
  • Frank - Java API进阶

    • Base API
    • Unit Test and main function
  • 学习笔记
  • 学习笔记

    • 数据库
  • Frank - MySQL删库跑路

    • 安装、连接、配置
    • 基本操作——数据库
    • 基本操作——表
    • 基本操作——数据
    • 数据类型
    • 列属性完整性
    • 数据库设计思维
    • 单表查询
    • 多表查询
  • 学习笔记

    • 其它
  • Frank - Linux现代方法

    • 必知
    • 命令
    • 技巧
  • 技术文档
  • Git
  • GitHub技巧
  • 前端
  • Khan Academy - 语法
  • Monthly
  • 阅读
  • Others
  • 学习
  • 面试
  • 心情杂货
  • 实用技巧
  • 友情链接
收藏
  • 标签
  • 归档
GitHub (opens new window)

Jim FuckPPT

Java小学生
首页
  • Hyperskill - Java

    • Java basic
    • Java OOP
    • 应知
    • 扩展
    • IO & Stream
    • Error & Exception
    • Algorithm & Data structure
    • Design pattern
    • Web
    • Spring boot
  • 练习题

    • 选择题 & 填空题
    • 代码题
  • Frank - Java与生活 (OOP)

    • 参考资料
    • Java基础
    • OOP上半部分
    • OOP下半部分
  • Frank - Java API进阶

    • Base API
    • Unit Test and main function
  • 学习笔记
  • 学习笔记

    • 数据库
  • Frank - MySQL删库跑路

    • 安装、连接、配置
    • 基本操作——数据库
    • 基本操作——表
    • 基本操作——数据
    • 数据类型
    • 列属性完整性
    • 数据库设计思维
    • 单表查询
    • 多表查询
  • 学习笔记

    • 其它
  • Frank - Linux现代方法

    • 必知
    • 命令
    • 技巧
  • 技术文档
  • Git
  • GitHub技巧
  • 前端
  • Khan Academy - 语法
  • Monthly
  • 阅读
  • Others
  • 学习
  • 面试
  • 心情杂货
  • 实用技巧
  • 友情链接
收藏
  • 标签
  • 归档
GitHub (opens new window)
  • Hyperskill - Java

    • Java basic

    • Java OOP

    • 应知

    • 扩展

    • IO & Stream

    • Error & Exception

    • Algorithm & Data structure

    • Design pattern

    • Web

      • Theory:World Wide Web
      • Theory:HTTP
      • Theory:HTTP URL
        • What is URL?
        • Basic URL Structure
        • Absolute and relative URLs
        • Conclusion
      • Theory:HTTP messages
      • Theory:MVC
      • Theory:Introduction to Spring Web MVC
      • Theory:REST
      • Theory:Postman
      • Theory:Getting data from REST
      • Theory:Posting and deleting data via REST
      • Theory:REST Exception handling
      • Theory:Handling requests with bodies
      • Theory:Domains
      • Theory:HTTP Basic Auth
      • Theory:IP
      • Theory:Authentication and Authorization
      • Theory:OAuth
      • Theory:Java 11 HTTP client
    • Spring boot

  • 练习题

  • Frank - Java与生活

  • Frank - Java API进阶

  • 学习笔记

  • Java
  • Hyperskill - Java
  • Web
Jim
2022-07-10
目录

Theory:HTTP URL

# What is URL?

Imagine all files on the Internet are located in a megalopolis, each of them lucky to be living in their own home. Given the scale of the Internet, in the resulting settlement, there will be an unimaginable number of blocks and streets. For example, an interesting article, which you want to share with your friend, lives in one of the houses. How do you explain where exactly to find the article? That's right, you need to come up with a single standard by which you could name all the addresses in the city, and then give your friend the street name and house number, just like in a real city!

All documents on the Internet have a personal address. For example, the URL of the JetBrains website looks like this:

https://www.jetbrains.com/
1

Web pages, images, videos, and other documents that can be stored on your computer also have addresses. To make them look the same on the Internet, in 1990 the creators of the World Wide Web developed a special standard that defines what addresses should look like. That standard is called a URL, which stands for Uniform Resource Locator. It represents the standardized way of recording file addresses on the Internet.

The standard has one specific feature: not all characters can be used in URLs. The list of allowed characters includes:

  • Latin alphabet (or English alphabet symbols);
  • Cyrillic alphabet;
  • Numbers;
  • Reserved characters with special meaning !#$&'()*+,/:;=?@[];
  • Unreserved characters: -_.~.

# Basic URL Structure

Here is an example of a URL address:

img

URL address has a certain structure based on the following template:

<protocol>://<login>:<password>@<host>:<port>/<path>?<request parameters>#<anchor>
1

Now let's look at this template in more detail:

  • <protocol> is a way of exchanging data with a resource. You are probably most familiar with HTTP and HTTPS protocols, but there are others;
  • <login> and <password> are prefixes that transmit authentication data for some protocols, if necessary;
  • <host> is the domain name or IP address where the site is located. Domain is the name of the site, IP is its address in a network;
  • <port> is required for connection within the specified host. The official port for HTTP connections is 80, and the alternative is 8080, but it is possible to use any other ports too. The default setting for HTTPS is 443;
  • <path> indicates the exact address of a particular file or page within a domain;
  • <request parameters> are parameters transmitted to the server. Depending on request parameters, the site may slightly change its display. For example, it is possible to sort the items of a list in a different order;
  • <anchor> allows you to connect to a specific part of a web page or document.

This is the general structure of any URL. Most often, when accessing web pages and documents located on a web server, most of the parameters are not mandatory and are set automatically.

When you just want to see a particular page on the Internet with your browser, the URL template looks a lot easier:

<protocol>://<host>
1

For example, it can be recorded in a form:

https://www.google.com
1

This simplification was created to make life easier for ordinary Internet users, but most programmers need to know the complete template, and now you do.

# Absolute and relative URLs

As we know, a URL consists of several parts, and when you're browsing through the same site, some elements of it stay the same. Whichever IDE you want to read about on JetBrains, the protocol and host parts of a URL always match https://www.jetbrains.com (opens new window). For example, let's look at these links:

  • https://www.jetbrains.com/pycharm/ about PyCharm
  • https://www.jetbrains.com/go/ about GoLang
  • https://www.jetbrains.com/idea/ about IntelliJ IDEA

The new information in each link is its <path>. There exists another way to locate resources on the same site by only <path>?<request parameters>#<anchor>. The full URL is known as absolute, and we call relative its shorter counterpart.

You should remember that it would work only on the same site, while you cannot refer to another site by a relative path. Every time you follow the link with a relative URL, it will expand to absolute, where all parts including everything from protocol to port will match the resource you are using this time.

We know that by absolute URLs we can easily find the resource through the Internet, but why do we need relative paths at all since they will be transformed to absolute anyway? Here are the main reasons for that:

  • They are short.
  • We can easily move the site to another host.
  • They are a little bit faster to retrieve by a browser.

# Conclusion

Let's sum up what you have learned about URLs in this topic:

  • We can locate any resources on the Internet through a URL.
  • Each URL consists of several parts, but some of them are optional.
  • We can retrieve resources by an absolute URL and then browse them through relative paths.
编辑 (opens new window)
#Web#HTTP
上次更新: 2022/10/12, 17:01:25
Theory:HTTP
Theory:HTTP messages

← Theory:HTTP Theory:HTTP messages→

最近更新
01
《挪威的森林》
04-14
02
青钢影
04-14
03
Processing strings
02-18
更多文章>
Theme by Vdoing | Copyright © 2022-2023 Jim Frank | MIT License
  • 跟随系统
  • 浅色模式
  • 深色模式
  • 阅读模式