来自 技术 2019-04-17 的文章

HTTP协议学习笔记

八年Java开发的感悟:什么才是程序员的立身之本>>>   

一直使用HTTP,却从未看来过他的协议本身。

这次把这个技术债补上。

HTTP 1.1RFC编号2616,地址:

https://www.ietf.org/rfc/rfc2616.txt

因为HTTP/1.0没有充分考虑到分层代理,缓存的作用以及对稳定连接和虚拟主机的需求。

所有才有了HTTP/1.1的诞生。

(相关 cookies 地址https://www.ietf.org/rfc/rfc6265.txt )

这次阅读记录以下几点:

1.默认编码是 ISO-8859-1

3.7.1 Canonicalization and Text Defaults

The "charset" parameter is used with some media types to define the

character set (section 3.4) of the data. When no explicit charset

parameter is provided by the sender, media subtypes of the "text"

type are defined to have a default charset value of "ISO-8859-1" when

received via HTTP. Data in character sets other than "ISO-8859-1" or

its subsets MUST be labeled with an appropriate charset value. See

section 3.4.1 for compatibility problems.

2.HTTP并非一定是建立在TCP/IP协议上。任何能保证可靠传输的都可以。

HTTP communication usually takes place over TCP/IP connections. The default port is TCP 80 [19], but other ports can be used. This does not preclude HTTP from being implemented on top of any other protocol on the Internet, or on other networks. HTTP only presumes a reliable transport; any protocol that provides such guarantees can be used; the mapping of the HTTP/1.1 request and response structures onto the transport data units of the protocol in question is outside the scope of this specification.

3.HTTP协议本身要求对URI不做长度限制。

The HTTP protocol does not place any a priori limit on the length of a URI. Servers MUST be able to handle the URI of any resource they serve, and SHOULD be able to handle URIs of unbounded length if they provide GET-based forms that could generate such URIs. A server SHOULD return 414 (Request-URI Too Long) status if a URI is longer than the server can handle (see section 10.4.15).

4.只有第2个request事GET或者Head 时,重定向才可以不通过用户。

This class of status code indicates that further action needs to be

taken by the user agent in order to fulfill the request. The action

required MAY be carried out by the user agent without interaction

with the user if and only if the method used in the second request is

GET or HEAD.

5.缓存

缓存是HTTP协议的重要部分,占了协议相当的笔墨

工作里经常遇到改了前端页面,按F5刷新没有效果,需要使用浏览器的清除缓存功能。原因就是浏览器实现了HTTP协议的缓存。

通过2个字段 Expires、Cache-control实现

6.URL太长

10.4.15 414 请求URI太长(Request-URI Too Long)

服务器拒绝为请求服务因为此请求URI太长了以至于服务器不能理解。这种情况是很少的,只发生在当客户端把POST请求不合适地转换为带有大量查询信息的GET请求时。

标签:   人事管理系统      regasm与regsv   
上一篇:利用spring的扫描工具类,扫描自定义的注解
下一篇:没有了