http请求解析

最近经常使用HTTP请求,但对HTTP请求的格式名称还有些不清楚的地方。主要是:

URI

URL

QueryString

HOST

PORT

Schema

这四个的区别,下面分别进行详细讲解。

  • URI

   URI表示资源标识符,代表一个资源的路径。官方解释为:the part of this request’s URL from the protocol name up to the query string in the first line of the HTTP request。简单来说就是Port和QueryString中间的部分

  • URL

   URL表示统一资源定位器,代表资源在互联网中的位置。官方解释为:The URL contains a protocol, server name, port number, and server path, but it does not include query string parameters。简单来说就是QueryString之前的部分。

  • QueryString

QueryString从名字看是查询字符串,在请求里面是问号后面的一部分(不考虑)。

  • HOST

HOST一般来说是一个域名,但也可以是ip+port

  • PORT

端口指的是服务器上提供服务的端口,一般服务器会监听该端口进行接收请求。默认是80

  • Schema

表示使用的协议,常见的有http  https  ftp。在http中,Schema指http

举例:http://www.baidu.com/a/b?k=10

Schema: http

HOST: www.baidu.com

PORT: 无

URL:www.baidu.com/a/b

URI:: /a/b

QueryString:k=10

猜你喜欢

转载自kaixiansheng.iteye.com/blog/2366884