IDEA HTTP Client Editor 工具使用教程
本教程针对 IDEA 使用者,主要是用来进行 api 接口测试,省去另外开 postman 或者相同工具的麻烦,
编写好的文件可以直接发给测试人员使用。也可以使用 IDEA 插件 restfulToolkit 或者直接写单元测试。
示个人请款以及喜好来选择。
官方文档:HTTP client in IntelliJ IDEA code editor
引用官方文档对 HTTP client 工具的功能、特性进行说明
功能:When testing a web service, you can create, edit, and execute HTTP Requests directly in the IntelliJ IDEA code editor.
IDEA 对 http files 提供的特性:
Code highlighting
Code completion
for hosts, method types, and header fieldsCode folding
for requests, their parts, and response handler scriptsInline documentation
for request header fields and doc tagsViewing a structure
of HTTP requestsLanguage injections
inside the request message bodyMove refactorings
Live templates
使用方法:
快捷指令
IDEA 对 .http/.rest 文件生成请求提供了一下几种缩写
fptr
快速生成文件上传请求
POST http://localhost:80/api/item
Content-Type: multipart/form-data; boundary=WebAppBoundary
--WebAppBoundary
Content-Disposition: form-data; name="field-name" filename="file.txt"
< ./relative/path/to/local_file.txt
--WebAppBoundary--
gtr
快速生成 GET 请求
GET http://localhost:80/api/