HTTP 权威解析之URLs and Resources

原创 2018年04月15日 11:40:33

1. 定义

  • Uniform resource locators (URLs) are the standardized names for the Internet’s resources. URLs point to pieces of electronic information, telling you where they are located and how to interact with them.
  • URLs are the usual human access point to HTTP and other protocols: a person points a browser at a URL and, behind the scenes, the browser sends the appropriate protocol messages to get the resource that the person wants.
  • URLs actually are a subset of a more general class of resource identifier called a uniform resource identifier, or URI.
    • URIs are a general concept comprised of two main subsets, URLs and URNs.
      • URLs identify resources by describing where resources are located, whereas URNs identify resources by name, regardless of where they currently reside.
  • URLs provide a way to uniformly name resources. Most URLs have the same “scheme://server location/path” structure. So, for every resource out there and every way to get those resources, you have a single way to name each resource so that anyone can use that name to find it.
  • The HTTP specification uses the more general concept of URIs as its resource identifiers; in practice, however, HTTP applications deal only with the URL subset of URIs.

  上面从URL的多个方面给出了定义,其实很多地方是重复的,只要记住HTTP仅仅使用URL,且URL确定了网络资源的位置,而非网络资源的名字。
这里写图片描述

2. URL Syntax

  • Most URL schemes base their URL syntax on this nine-part general format:
    <scheme>://<user>:<password>@<host>:<port>/<path>;<params>?<query>#<frag>
  • Almost no URLs contain all these components. The three most important parts of a
    URL are the scheme, the host, and the path.最主要的也就是scheme, host,有时候path也可以省略,此时由浏览器补全path:index.html

这里写图片描述

  上图给了URL所有部分的含义,下面着重强调上面几个部分:

  • Hosts and Ports:
    • The host component identifies the host machine on the Internet that has access to the resource. The name can be provided as a hostname, as above (“www.joes-hardware.com”) or as an IP address.
    • The port component identifies the network port on which the server is listening. For
      HTTP, which uses the underlying TCP protocol, the default port is 80.
  • Paths:
    • The path component of the URL specifies where on the server machine the resource lives. The path often resembles a hierarchical filesystem path.
    • The path component for HTTP URLs can be divided into path segments separated by “/” characters (again, as in a file path on a Unix filesystem). Each path segment can have its own params component.
  • Parameters:
    • the path component for HTTP URLs can be broken into path segments. Each segment can have its own params. For example:
      http://www.joes-hardware.com/hammers;sale=false/index.html;graphics=true
  • Query Strings:
    • The query component of the URL is passed along to a gateway resource, with the
      path component of the URL identifying the gateway resource. Basically, gateways
      can be thought of as access points to other applications.
    • By convention, many gateways expect the query string to be formatted as a series of “name=value” pairs, separated by “&” characters.
    • 如下图是一种gateway情况
      这里写图片描述
  • Fragments
    • To allow referencing of parts or fragments of a resource, URLs support a frag component to identify pieces within a resource.
      • Some resource types, such as HTML, can be divided further than just the resource level.
    • A fragment dangles off the right-hand side of a URL, preceded by a # character.
    • Because HTTP servers generally deal only with entire objects,* not with fragments of objects, clients don’t pass fragments along to servers. After your browser gets the entire resource from the server, it then uses the fragment to display the part of the resource in which you are interested.
      加个图

3. A Sea of Schemes

这里写图片描述
  这里简单的介绍了httpshttp的升级版,因为https开启了SSL

4. 回顾

  • URL为URI的子集,未来将着重于URN,一种基于资源名字而非位置的方式。
  • 对于HTTP协议来说,URL中最为重要的几个部分:scheme, host, port, path, query string
  • fragment还是由server传递完整的html文件给client,但是由client选择该fragment呈现给用户。
  • query string中的gatewary是从其他应用(如数据库)获取资源的中介,可能本身是程序或者脚本。

修正之前Tinyhttp中说query string是参数的不准确说法。

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/LoveStackover/article/details/79947866

获取视频解图(优酷,酷六,土豆,新浪,乐视,腾讯视频)

  • 2013年06月04日 10:53
  • 21KB
  • 下载

YumRepo Error: All mirror URLs are not using ftp, http[s] or file. Eg. </HTML>/

sudo yum update Loaded plugins: fastestmirror, refresh-packagekit, security Loading mirror speeds ...
  • w1242245
  • w1242245
  • 2014-05-26 17:01:31
  • 11552

YumRepo Error: All mirror URLs are not using问题解决

YumRepo Error: All mirror URLs are not using问题解决 (2013-01-24 02:55:57) 转载▼ 标签: yumrepo...
  • yu132563
  • yu132563
  • 2015-11-25 00:21:34
  • 1105

YumRepo Error: All mirror URLs are not using ftp, http[s] or file. Eg. </HTML>/ 标签: yum 2014-05-26

YumRepo Error: All mirror URLs are not using ftp, http[s] or file. Eg. / 标签: yum 2014-05-26...
  • yu132563
  • yu132563
  • 2015-11-25 00:22:19
  • 2669

Apple trailers resources urls

Apple trailers: http://trailers.apple.com/trailers/home/xml/newest.xmlhttp://trailers.apple.com/trai...
  • flycar
  • flycar
  • 2011-01-14 16:03:00
  • 129

无法分析从服务器收到的消息。之所以出现此错误,常见的原因是: 在通过调用 Response.Write() 修改响应时,将启用响应筛选器、HttpModule 或服务器跟踪。

  无法分析从服务器收到的信息。之所以出现此错误,常见的原因是:在通过调用Response.Write()修改响应时,将启动响应筛选器、HttpModule或服务器跟踪。错误截图如下:      解决...
  • lovely20085901
  • lovely20085901
  • 2010-07-24 10:49:00
  • 2064

DNS扫盲系列之八:关于域名解析的授权

首先是两个相关的概念: 域名授权: 指定谁是该域名的权威DNS,即由谁负责解析该域名(由NS记录操作完成)。 权威DNS: 特指对特定域名具有权威发布能力的DNS;互联网上域名(域名记录)...
  • charleslei
  • charleslei
  • 2014-11-15 22:53:17
  • 2499

关于SpringMVC中找不到<mvc:resources/>标签的解决办法

关于SpringMVC中找不到标签的解决办法 在springMVC中我们经常会用到标签,但是有些编辑器中的schema过于陈旧。导致找不到标签。 经过试验,有两个解决办法: 1....
  • yucaifu1989
  • yucaifu1989
  • 2014-09-24 09:52:01
  • 1129

web.py之url映射

URL完全匹配(具体的url) /index URL模糊匹配(你根本就不知道index后面是什么,它根本不会返回参数) /index/\d URL带组匹配(主要有个’()’,它的作用主要是返回参数...
  • guofeng93
  • guofeng93
  • 2017-01-07 10:05:03
  • 1208

VuGen中录制选项(Recording Options)介绍

General>Script: 提供对于脚本的基本设置,包括脚本语言(不同协议下,所使用的语言不同)、脚本最大允许行数等。   General>Protocols: 协议列表,列出了录制前选中...
  • cassie_gao
  • cassie_gao
  • 2012-01-31 15:36:14
  • 3881
收藏助手
不良信息举报
您举报文章:HTTP 权威解析之URLs and Resources
举报原因:
原因补充:

(最多只允许输入30个字)