首页 > 解决方案 > bash中的循环覆盖

问题描述

这里发生了什么?

content=$(curl -s http://localhost:3000 -I | grep -Fi Content-Type | awk '{print $2}')
echo "${content}1234"

资源:

1234ication/x-protobuf

curl -I回应是

HTTP/1.1 200 OK
X-Powered-By: Express
Content-Type: application/x-protobuf
Content-Encoding: gzip
Content-Length: 10013
Date: Tue, 14 Aug 2018 18:00:06 GMT
Connection: keep-alive

如您所见,网络服务器是一个普通的 express 应用程序,没有中间件,所有样板,没什么特别的

此外,检查

if [ "$content" == "application/x-protobuf" ] 

总是错误的(我也尝试过其他的条件变体)

  1. 什么是循环覆盖业务
  2. 为什么屏幕上打印的内容不是内容?

标签: bashhttpcurlawkline-endings

解决方案


推荐阅读