一、ABNF
1.什么是 ABNF?(了解)

2. ABNF 的格式如何?(理解即可)



3. URL 中如果出现特殊字符(中文字符或空格)
,要怎么处理?浏览器的默认处理是什么?(重要)

4. 使用 Xshell + telnet 可以面向报文观察 HTTP。(了解)

二、请求头字段
1. GET、POST、HEAD 请求各自的特点和适用场景?(重要)

2. 什么是盗链?什么是防盗链?通过那个请求头可以防盗链?(重要、待实践)
盗链:
就是在自己的网站上,盗用其他服务器的图片资源,展示到自己的网站上。
防盗链:
就是防止非自己的网站,访问自己服务器的公开图片资源。
请求头字段:
可以通过 Referer
请求头字段来防盗链
3. 如果我们需要下载一个大文件,需要实现多线程下载和断点下载
,需要依靠请求头的哪个字段?

4. 常见请求头字段(要认识,以及知道作用)



三、响应头字段
1. 常见响应头字段?(要认识,以及知道作用)


2. Content-Type 的作用?(实践 + 重要)
response.setContentType("text/html;charset=utf-8");
- ①可以设定服务器返回的编码
charset=utf-8
,这样防止乱码 - ②告诉客户端,服务器返回的是格式
text/html
3. Content-Disposition 的作用?(实践 + 重要)
@WebServlet("/download")
public class DownloadServlet extends HttpServlet {
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setContentType("text/plain; charset=UTF8");
response.setHeader("Content-Disposition","attachment; filename=\"download.txt\"");
response.getWriter().write("这是我的大文件");
}
}
-
response.setHeader("Content-Disposition","attachment; filename=\"download.txt\"");
可以让浏览器以下载的方式,去下载服务端返回的数据。
网友评论