Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
2d8e034
Merge pull request #1 from CyC2018/master
wangyang404 Aug 21, 2018
07dff03
Update 数据库系统原理.md
zyt312074545 Sep 11, 2018
3c9580f
Merge pull request #415 from wangyang404/master
CyC2018 Sep 12, 2018
b88cef1
Java 基础 219行笔误
yif-hong Sep 13, 2018
d167aaf
String poll笔误修改 227~272行
yif-hong Sep 13, 2018
2950624
Merge pull request #417 from yif-hong/patch-1
CyC2018 Sep 13, 2018
6977050
Merge pull request #416 from yif-hong/patch-2
CyC2018 Sep 13, 2018
c40a346
Merge pull request #413 from zyt312074545/master
CyC2018 Sep 13, 2018
b751fc8
Java 基础,对final关键字补充构造器相关点
yif-hong Sep 14, 2018
3b6e439
Merge pull request #418 from yif-hong/patch-3
CyC2018 Sep 14, 2018
f2e8961
Java 基础 “隐式类型转换”中++和+=效果一样,也会执行隐式的类型转换
yif-hong Sep 14, 2018
9c124cc
Merge pull request #419 from yif-hong/patch-4
CyC2018 Sep 14, 2018
60ed4f4
auto commit
CyC2018 Sep 14, 2018
4746326
Merge branch 'master' of https://github.com/CyC2018/Interview-Notebook
CyC2018 Sep 14, 2018
325595d
auto commit
CyC2018 Sep 14, 2018
170f0fc
auto commit
CyC2018 Sep 14, 2018
b802b8a
Update 剑指 offer 题解.md
Sep 16, 2018
185d9d1
Merge pull request #421 from thatnight/patch-1
CyC2018 Sep 16, 2018
55f1d4e
Update SUMMARY.md
0xl2oot Sep 17, 2018
e56a806
Java
yif-hong Sep 17, 2018
04d036c
Merge pull request #424 from yif-hong/patch-5
CyC2018 Sep 17, 2018
42d72fd
Merge pull request #423 from 0xl2oot/master
CyC2018 Sep 18, 2018
338d0bf
auto commit
CyC2018 Sep 18, 2018
70cb81d
Merge branch 'master' of https://github.com/CyC2018/Interview-Notebook
CyC2018 Sep 18, 2018
57a7410
auto commit
CyC2018 Sep 18, 2018
f89ef4c
auto commit
CyC2018 Sep 18, 2018
e3c63b6
Simplify House Robber solution
youmark Sep 18, 2018
497812b
Fix a bug in the Minimum Path Sum solution
youmark Sep 18, 2018
177a432
mask计算错误
nefuddos Sep 18, 2018
b37eb4d
Merge pull request #426 from nefuddos/patch-1
CyC2018 Sep 19, 2018
09294c4
Merge pull request #425 from youmark/master
CyC2018 Sep 19, 2018
642411c
auto commit
CyC2018 Sep 19, 2018
27fdb17
Merge branch 'master' of https://github.com/CyC2018/InterviewNotes
CyC2018 Sep 19, 2018
c7ce8a0
[BUG_FIX] 修改名称错误,事务特性为 ACID
fxleyu Sep 19, 2018
d598ece
Merge pull request #427 from fxleyu/patch-1
CyC2018 Sep 19, 2018
9aa4202
Update README.md
CyC2018 Sep 19, 2018
6a24574
auto commit
CyC2018 Sep 19, 2018
fddf428
Merge branch 'master' of https://github.com/CyC2018/Interview-Notebook
CyC2018 Sep 19, 2018
19fb63d
auto commit
CyC2018 Sep 22, 2018
127f755
auto commit
CyC2018 Sep 22, 2018
b57f404
auto commit
CyC2018 Sep 22, 2018
3ab4f89
auto commit
CyC2018 Sep 22, 2018
bb1d703
auto commit
CyC2018 Sep 22, 2018
19211d8
Merge branch 'master' of https://github.com/CyC2018/Interview-Notebook
CyC2018 Sep 22, 2018
5640334
auto commit
CyC2018 Sep 23, 2018
a3b6732
auto commit
CyC2018 Sep 23, 2018
4a9c4a5
auto commit
CyC2018 Sep 23, 2018
e89b0aa
auto commit
CyC2018 Sep 23, 2018
5eaf1da
上升子序列
zhulinn Sep 23, 2018
3a604c2
auto commit
CyC2018 Sep 23, 2018
cd14f64
Merge pull request #435 from zhulinn/patch-2
CyC2018 Sep 23, 2018
02a61d3
auto commit
CyC2018 Sep 24, 2018
97a21c7
Merge branch 'master' of https://github.com/CyC2018/Interview-Notebook
CyC2018 Sep 24, 2018
1c86116
auto commit
CyC2018 Sep 24, 2018
668ee4e
auto commit
CyC2018 Sep 25, 2018
6d51908
auto commit
CyC2018 Sep 29, 2018
af0cf63
auto commit
CyC2018 Sep 29, 2018
abb0eca
Update Group.md
CyC2018 Oct 1, 2018
1183184
auto commit
CyC2018 Oct 1, 2018
a1debab
auto commit
CyC2018 Oct 2, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 15 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
| 算法[:pencil2:](#pencil2-算法) | 操作系统[:computer:](#computer-操作系统)|网络[:cloud:](#cloud-网络) | 面向对象[:couple:](#couple-面向对象) |数据库[:floppy_disk:](#floppy_disk-数据库)| Java [:coffee:](#coffee-java)| 系统设计[:bulb:](#bulb-系统设计)| 工具[:hammer:](#hammer-工具)| 编码实践[:speak_no_evil:](#speak_no_evil-编码实践)| 后记[:memo:](#memo-后记) |

<br>

<div align="center">
<img src="other/LogoMakr_0zpEzN.png" width="150px">
<br>
Expand Down Expand Up @@ -195,38 +196,41 @@

笔者将自己实现文档转换功能提取出来,方便大家在需要将本地 Markdown 上传到 Github,或者制作项目 README 文档时生成目录时使用:[GFM-Converter](https://github.com/CyC2018/GFM-Converter)。

#### Statement

本仓库不参与商业行为,不向读者收取任何费用。(This repository is not engaging in business activities, and does not charge readers any fee.)

#### Logo

Power by [logomakr](https://logomakr.com/).

#### Statement

本仓库不参与商业行为,不向读者收取任何费用。(This repository is not engaging in business activities, and does not charge readers any fee.)

#### Acknowledgements

感谢以下人员对本仓库做出的贡献,当然不仅仅只有这些贡献者,这里就不一一列举了。如果你希望被添加到这个名单中,并且提交过 Issue 或者 PR,请与笔者联系。

<a href="https://github.com/linw7">
<img src="other/21679154.png" width="50px">
<img src="https://avatars3.githubusercontent.com/u/21679154?s=400&v=4" width="50px">
</a>
<a href="https://github.com/g10guang">
<img src="other/18458140.jpg" width="50px">
<img src="https://avatars1.githubusercontent.com/u/18458140?s=400&v=4" width="50px">
</a>
<a href="https://github.com/ResolveWang">
<img src="other/8018776.jpg" width="50px">
<img src="https://avatars1.githubusercontent.com/u/8018776?s=400&v=4" width="50px">
</a>
<a href="https://github.com/crossoverJie">
<img src="other/15684156.jpg" width="50px">
<img src="https://avatars1.githubusercontent.com/u/15684156?s=400&v=4" width="50px">
</a>
<a href="https://github.com/jy03078584">
<img src="other/7719370.png" width="50px">
<img src="https://avatars2.githubusercontent.com/u/7719370?s=400&v=4" width="50px">
</a>
<a href="https://github.com/kwongtailau">
<img src="other/22954582.jpg" width="50px">
<img src="https://avatars0.githubusercontent.com/u/22954582?s=400&v=4" width="50px">
</a>
<a href="https://github.com/xiangflight">
<img src="other/10072416.jpg" width="50px">
​ <img src="https://avatars2.githubusercontent.com/u/10072416?s=400&v=4" width="50px">
</a>
<a href="https://github.com/mafulong">
​ <img src="https://avatars1.githubusercontent.com/u/24795000?s=400&v=4" width="50px">
</a>

#### License
Expand Down
25 changes: 19 additions & 6 deletions SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,23 @@ This file used to generate gitbook catalogue.
* [Java 虚拟机](/notes/Java 虚拟机.md)
* [Java 并发](/notes/Java 并发.md)
* [Java 容器](/notes/Java 容器.md)
* [Java I/O](/notes/Java I/O.md)
* 分布式
* [一致性](/notes/一致性.md)
* [分布式问题分析](/notes/分布式问题分析.md)


* [Java I/O](/notes/Java IO.md)
* 系统设计
* [系统设计基础](/notes/系统设计基础.md)
* [分布式](/notes/分布式.md)
* [集群](/notes/集群.md)
* [攻击技术](/notes/攻击技术.md)
* [缓存](/notes/缓存.md)
* [消息队列](/notes/消息队列.md)
* 工具
* [Git](/notes/Git.md)
* [Docker](/notes/Docker.md)
* [正则表达式](/notes/正则表达式.md)
* [构建工具](/notes/构建工具.md)
* 编码实践
* [重构](/notes/重构.md)
* [代码可读性](/notes/代码可读性.md)
* [代码风格规范](/notes/代码风格规范.md)
* 参考书目
* [BOOKLIST](/BOOKLIST.md)

95 changes: 48 additions & 47 deletions notes/HTTP.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@
* [响应首部字段](#响应首部字段)
* [实体首部字段](#实体首部字段)
* [五、具体应用](#五具体应用)
* [连接管理](#连接管理)
* [Cookie](#cookie)
* [缓存](#缓存)
* [连接管理](#连接管理)
* [内容协商](#内容协商)
* [内容编码](#内容编码)
* [范围请求](#范围请求)
Expand All @@ -44,14 +44,14 @@
* [二进制分帧层](#二进制分帧层)
* [服务端推送](#服务端推送)
* [首部压缩](#首部压缩)
* [八、GET 和 POST 比较](#八get-和-post-比较)
* [八、HTTP/1.1 新特性](#八http11-新特性)
* [九、GET 和 POST 比较](#九get-和-post-比较)
* [作用](#作用)
* [参数](#参数)
* [安全](#安全)
* [幂等性](#幂等性)
* [可缓存](#可缓存)
* [XMLHttpRequest](#xmlhttprequest)
* [九、HTTP/1.0 与 HTTP/1.1 的区别](#九http10-与-http11-的区别)
* [参考资料](#参考资料)
<!-- GFM-TOC -->

Expand Down Expand Up @@ -102,7 +102,7 @@ URI 包含 URL 和 URN,目前 WEB 只有 URL 比较流行,所以见到的基

POST 主要用来传输数据,而 GET 主要用来获取资源。

更多 POST 与 GET 的比较请见第八章
更多 POST 与 GET 的比较请见第九章

## PUT

Expand Down Expand Up @@ -303,6 +303,25 @@ CONNECT www.example.com:443 HTTP/1.1

# 五、具体应用

## 连接管理

<div align="center"> <img src="../pics//HTTP1_x_Connections.png" width="800"/> </div><br>

### 1. 短连接与长连接

当浏览器访问一个包含多张图片的 HTML 页面时,除了请求访问 HTML 页面资源,还会请求图片资源。如果每进行一次 HTTP 通信就要新建一个 TCP 连接,那么开销会很大。

长连接只需要建立一次 TCP 连接就能进行多次 HTTP 通信。

- 从 HTTP/1.1 开始默认是长连接的,如果要断开连接,需要由客户端或者服务器端提出断开,使用 `Connection : close`;
- 在 HTTP/1.1 之前默认是短连接的,如果需要使用长连接,则使用 `Connection : Keep-Alive`。

### 2. 流水线

默认情况下,HTTP 请求是按顺序发出的,下一个请求只有在当前请求收到响应之后才会被发出。由于会受到网络延迟和带宽的限制,在下一个请求被发送到服务器之前,可能需要等待很长时间。

流水线是在同一条长连接上发出连续的请求,而不用等待响应返回,这样可以避免连接延迟。

## Cookie

HTTP 协议是无状态的,主要是为了让 HTTP 协议尽可能简单,使得它能够处理大量事务。HTTP/1.1 引入 Cookie 来保存状态信息。
Expand Down Expand Up @@ -420,23 +439,23 @@ Session 可以存储在服务器上的文件、数据库或者内存中。也可

HTTP/1.1 通过 Cache-Control 首部字段来控制缓存。

**(一)禁止进行缓存**
**3.1 禁止进行缓存**

no-store 指令规定不能对请求或响应的任何一部分进行缓存。

```html
Cache-Control: no-store
```

**(二)强制确认缓存**
**3.2 强制确认缓存**

no-cache 指令规定缓存服务器需要先向源服务器验证缓存资源的有效性,只有当缓存资源有效才将能使用该缓存对客户端的请求进行响应。

```html
Cache-Control: no-cache
```

**(三)私有缓存和公共缓存**
**3.3 私有缓存和公共缓存**

private 指令规定了将资源作为私有缓存,只能被单独用户所使用,一般存储在用户浏览器中。

Expand All @@ -450,7 +469,7 @@ public 指令规定了将资源作为公共缓存,可以被多个用户所使
Cache-Control: public
```

**(四)缓存过期机制**
**3.4 缓存过期机制**

max-age 指令出现在请求报文中,并且缓存资源的缓存时间小于该指令指定的时间,那么就能接受该缓存。

Expand Down Expand Up @@ -493,32 +512,13 @@ Last-Modified: Wed, 21 Oct 2015 07:28:00 GMT
If-Modified-Since: Wed, 21 Oct 2015 07:28:00 GMT
```

## 连接管理

<div align="center"> <img src="../pics//HTTP1_x_Connections.png" width="800"/> </div><br>

### 1. 短连接与长连接

当浏览器访问一个包含多张图片的 HTML 页面时,除了请求访问 HTML 页面资源,还会请求图片资源。如果每进行一次 HTTP 通信就要新建一个 TCP 连接,那么开销会很大。

长连接只需要建立一次 TCP 连接就能进行多次 HTTP 通信。

- 从 HTTP/1.1 开始默认是长连接的,如果要断开连接,需要由客户端或者服务器端提出断开,使用 `Connection : close`;
- 在 HTTP/1.1 之前默认是短连接的,如果需要使用长连接,则使用 `Connection : Keep-Alive`。

### 2. 流水线

默认情况下,HTTP 请求是按顺序发出的,下一个请求只有在当前请求收到响应之后才会被发出。由于会受到网络延迟和带宽的限制,在下一个请求被发送到服务器之前,可能需要等待很长时间。

流水线是在同一条长连接上发出连续的请求,而不用等待响应返回,这样可以避免连接延迟。

## 内容协商

通过内容协商返回最合适的内容,例如根据浏览器的默认语言选择返回中文界面还是英文界面。

### 1. 类型

**(一)服务端驱动型**
**1.1 服务端驱动型**

客户端设置特定的 HTTP 首部字段,例如 Accept、Accept-Charset、Accept-Encoding、Accept-Language、Content-Languag,服务器根据这些字段返回特定的资源。

Expand All @@ -528,7 +528,7 @@ If-Modified-Since: Wed, 21 Oct 2015 07:28:00 GMT
- 客户端提供的信息相当冗长(HTTP/2 协议的首部压缩机制缓解了这个问题),并且存在隐私风险(HTTP 指纹识别技术);
- 给定的资源需要返回不同的展现形式,共享缓存的效率会降低,而服务器端的实现会越来越复杂。

**(二)代理驱动型**
**1.2 代理驱动型**

服务器返回 300 Multiple Choices 或者 406 Not Acceptable,客户端从中选出最合适的那个资源。

Expand Down Expand Up @@ -758,7 +758,25 @@ HTTP/2.0 要求客户端和服务器同时维护和更新一个包含之前见

<div align="center"> <img src="../pics//_u4E0B_u8F7D.png" width="600"/> </div><br>

# 八、GET 和 POST 比较
# 八、HTTP/1.1 新特性

详细内容请见上文

- 默认是长连接

- 支持管线化处理

- 支持同时打开多个 TCP 连接

- 支持虚拟主机

- 新增状态码 100

- 支持分块传输编码

- 新增缓存处理指令 max-age

# 九、GET 和 POST 比较

## 作用

Expand Down Expand Up @@ -840,23 +858,6 @@ DELETE /idX/delete HTTP/1.1 -> Returns 404
- 在使用 XMLHttpRequest 的 POST 方法时,浏览器会先发送 Header 再发送 Data。但并不是所有浏览器会这么做,例如火狐就不会。
- 而 GET 方法 Header 和 Data 会一起发送。

# 九、HTTP/1.0 与 HTTP/1.1 的区别

详细内容请见上文

- HTTP/1.1 默认是长连接

- HTTP/1.1 支持管线化处理

- HTTP/1.1 支持同时打开多个 TCP 连接

- HTTP/1.1 支持虚拟主机

- HTTP/1.1 新增状态码 100

- HTTP/1.1 支持分块传输编码

- HTTP/1.1 新增缓存处理指令 max-age


# 参考资料
Expand Down
8 changes: 3 additions & 5 deletions notes/Java IO.md
Original file line number Diff line number Diff line change
Expand Up @@ -284,10 +284,6 @@ public static void main(String[] args) throws IOException {

# 七、NIO

- [Java NIO Tutorial](http://tutorials.jenkov.com/java-nio/index.html)
- [Java NIO 浅析](https://tech.meituan.com/nio.html)
- [IBM: NIO 入门](https://www.ibm.com/developerworks/cn/education/java/j-nio/j-nio.html)

新的输入/输出 (NIO) 库是在 JDK 1.4 中引入的,弥补了原来的 I/O 的不足,提供了高速的、面向块的 I/O。

## 流与块
Expand Down Expand Up @@ -343,7 +339,7 @@ I/O 包和 NIO 已经很好地集成了,java.io.\* 已经以 NIO 为基础重

<div align="center"> <img src="../pics//1bea398f-17a7-4f67-a90b-9e2d243eaa9a.png"/> </div><br>

② 从输入通道中读取 5 个字节数据写入缓冲区中,此时 position 移动设置为 5,limit 保持不变。
② 从输入通道中读取 5 个字节数据写入缓冲区中,此时 position 5,limit 保持不变。

<div align="center"> <img src="../pics//80804f52-8815-4096-b506-48eef3eed5c6.png"/> </div><br>

Expand Down Expand Up @@ -612,6 +608,8 @@ NIO 与普通 I/O 的区别主要有以下两点:

- Eckel B, 埃克尔, 昊鹏, 等. Java 编程思想 [M]. 机械工业出版社, 2002.
- [IBM: NIO 入门](https://www.ibm.com/developerworks/cn/education/java/j-nio/j-nio.html)
- [Java NIO Tutorial](http://tutorials.jenkov.com/java-nio/index.html)
- [Java NIO 浅析](https://tech.meituan.com/nio.html)
- [IBM: 深入分析 Java I/O 的工作机制](https://www.ibm.com/developerworks/cn/java/j-lo-javaio/index.html)
- [IBM: 深入分析 Java 中的中文编码问题](https://www.ibm.com/developerworks/cn/java/j-lo-chinesecoding/index.htm)
- [IBM: Java 序列化的高级认识](https://www.ibm.com/developerworks/cn/java/j-lo-serial/index.html)
Expand Down
Loading