一个小小的API测试

在根目录下,编辑一个测试用的api小文件,然后通过浏览器(safari和chrome,地址为本地电脑地址)、终端curl(分别从vps和本地进行)的方式获取该文件。

vi /var/log/nginx/access.log

来查看刚才的api文档的获取记录

139.XXXXX - - [13/Nov/2021:14:34:22 +0800] "GET /api.json HTTP/1.1" 200 22 "-" "curl/7.68.0"(VPS方式)
223.XXXXX - - [13/Nov/2021:14:35:19 +0800] "GET /api.json HTTP/1.1" 200 22 "-" "curl/7.77.0"(本机方式)
223.XXXXX - - [13/Nov/2021:14:36:28 +0800] "GET /api.json HTTP/1.1" 200 22 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.69 Safari/537.36"(本机方式)
223.XXXXX - - [13/Nov/2021:14:36:28 +0800] "GET /favicon.ico HTTP/1.1" 404 188 "http://madapapa.com/api.json" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.69 Safari/537.36"(本机方式)

下面是刚刚发布了这篇blog后的日志变化情况,可以看到从本机进行了post操作

223.XXXXX - - [13/Nov/2021:14:59:24 +0800] "POST /wordpress/xmlrpc.php HTTP/1.1" 200 3493 "-" "MWeb%20Pro/917 CFNetwork/1325.0.1 Darwin/21.1.0"

Leave a Reply

Your email address will not be published. Required fields are marked *