Hello World

吞风吻雨葬落日 欺山赶海踏雪径

0%

intellij idea 内置 HttpClient 使用

intellij idea 内置 HttpClient 使用笔记

格式

### 作为分隔符,# 作为注释。

1
2
GET http://localhost:80/api/item?id=99
Accept: application/json

Get 请求

普通Get

1
2
3
4
5
6
7
8
9
10
11
12
13
GET http://my-web.cn/aaa/bbb.json?id=11&instanceId=11
Connection: keep-alive
sec-ch-ua: " Not A;Brand";v="99", "Chromium";v="99", "Google Chrome";v="99"
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.84 Safari/537.36
sec-ch-ua-platform: "macOS"
Accept: */*
Origin: http://my-web.cn
Sec-Fetch-Site: same-site
Sec-Fetch-Mode: cors
Sec-Fetch-Dest: empty
Referer: http://my-web.cn/
Accept-Language: zh-CN,zh;q=0.9
Cookie: X-XSRF-TOKEN=xxxx-xxxx-xxxx-xxxx-xxxxxx;

Post 请求

普通Post x-www-form-urlencoded 格式

1
2
3
4
5
6
7
8
POST http://my-web.cn/aaa/save
xsrf-token: xxxx-xxxx-xxxx-xxxx-xxxxxx
user-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.83 Safari/537.36
accept-language: zh-CN,zh;q=0.9,en
cookie: X-XSRF-TOKEN=xxxx-xxxx-xxxx-xxxx-xxxxxx;
Content-Type: application/x-www-form-urlencoded

id=3

普通Post application/json 格式

1
2
3
4
POST http://www.example.com HTTP/1.1 
Content-Type: application/json;charset=utf-8

{"title":"test","sub":[1,2,3]}

Post上传文件

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
POST http://my-web.cn/aaa/upload
xsrf-token: xxxx-xxxx-xxxx-xxxx-xxxxxx
user-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.83 Safari/537.36
accept-language: zh-CN,zh;q=0.9,en
cookie: X-XSRF-TOKEN=xxxx-xxxx-xxxx-xxxx-xxxxxx;
Content-Type: multipart/form-data; boundary=WebAppBoundary

--WebAppBoundary
Content-Disposition: form-data; name="id"
Content-Type: text/plain

660
--WebAppBoundary
Content-Disposition: form-data; name="file"; filename="template.png"
Content-Type: image/png

< /Users/xxx/Downloads/template.png
--WebAppBoundary--