houdq / blog

java 学习笔记
0 stars 0 forks source link

深入分析 java web 技术内幕-读书笔记 #92

Open houdq opened 1 year ago

houdq commented 1 year ago

读书笔记 image

houdq commented 1 year ago

深入web 请求过程

B/S 架构网络论述

image

◎ 互联网上所有资源都要用一个URL来表示 ◎ 必须基于HTTP协议与服务端交互 ◎ 数据展示必须在浏览器中进行

houdq commented 1 year ago

如何发起一个 http 请求

一句话,发起一个HTTP请求的过程就是建立一个Socket通信的过程。java 使用Httpclient 创建链接。

public class HttpClientDemo {
    public static void main(String[] args) {
        // Create an HttpClient instance
        HttpClient httpClient = HttpClients.createDefault();

        // Define the URL you want to send the GET request to
        String url = "https://baidu.com"; // Replace with your URL

        // Create an HttpGet request
        HttpGet httpGet = new HttpGet(url);

        try {
            // Execute the request and get the response
            HttpResponse response = httpClient.execute(httpGet);

            // Read and display the response
            BufferedReader reader = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
            String line;
            while ((line = reader.readLine()) != null) {
                System.out.println(line);
            }

            // Ensure the response entity is fully consumed and the connection is released
            response.getEntity().getContent().close();

        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
houdq commented 1 year ago

http协议解析

常见的HTTP请求头

image

请求响应

image

http 状态码

image

更多状态码参见 #93

houdq commented 1 year ago

查看 http 信息工具

houdq commented 1 year ago

浏览器缓存机制

浏览器工具查看:Cache-Control:状态若没有缓存则是no-cache

字段 描述
Cache-Control no-cache
Pragma no-cache
Etag: 是让服务端给每个页面分配一个唯一的编号,然后通过这个编号来区分当前这个页面是否是最新的 "FkzAS3zbQlpxiu4RLdsxZfuILBYP"
Last-Modified: 告诉浏览器这个页面的最后修改时间 Fri, 25 Aug 2023 04:20:59 GMT
houdq commented 1 year ago

java IO 工作机制

houdq commented 1 year ago

javaweb 中文编码问题

houdq commented 1 year ago

javac 编译原理

houdq commented 1 year ago

class 结构

houdq commented 1 year ago

深入分析 classloader 工作机制

houdq commented 1 year ago

jvm 体系结构与工程

houdq commented 1 year ago

jvm内存管理

houdq commented 1 year ago

session 和 cookie