可能是golang的框架导致 curl -I 与 curl -i 返回的头部信息不一致,声明调用的方式为GET就正常了
如下图:
curl -I -X GET "http://localhost:8080/home/hi"
30/11/2022 14:49.48 /home/mobaxterm curl -i http://localhost:8080/home/hi
HTTP/1.1 200 OK
Date: Wed, 30 Nov 2022 06:50:52 GMT
Content-Length: 5
Content-Type: text/plain; charset=utf-8✔
world
30/11/2022 14:49.48 /home/mobaxterm curl -I http://localhost:8080/home/hi
HTTP/1.1 404 Not Found
Date: Wed, 30 Nov 2022 06:49:52 GMT
Content-Length: 9
Content-Type: text/plain; charset=utf-8✔
30/11/2022 14:49.52 /home/mobaxterm curl -I "http://localhost:8080/home/hi"
HTTP/1.1 404 Not Found
Date: Wed, 30 Nov 2022 06:50:09 GMT
Content-Length: 9
Content-Type: text/plain; charset=utf-8✔
30/11/2022 14:50.09 /home/mobaxterm curl -I -X GET "http://localhost:8080/home/hi"
HTTP/1.1 200 OK
Date: Wed, 30 Nov 2022 06:50:52 GMT
Content-Length: 5
Content-Type: text/plain; charset=utf-8✔
30/11/2022 14:50.52 /home/mobaxterm curl -I -X HEAD "http://localhost:8080/home/hi"
HTTP/1.1 404 Not Found
Date: Wed, 30 Nov 2022 06:51:02 GMT
Content-Length: 9
Content-Type: text/plain; charset=utf-8
标签:返回,2022,30,Content,头部,home,curl,localhost
From: https://www.cnblogs.com/linuxshare/p/16938501.html