Sockets 如何将socat与heredoc一起使用?

Sockets 如何将socat与heredoc一起使用?,sockets,socat,Sockets,Socat,如果我从终端输入文本,我可以用这种方式运行socat $ socat -d -d - TCP4:httpbin.org:80 2021/04/02 15:12:43 socat[22364] N reading from and writing to stdio 2021/04/02 15:12:43 socat[22364] N opening connection to LEN=16 AF=2 34.199.75.4:80 2021/04/02 15:12:43 socat[22364] N

如果我从终端输入文本,我可以用这种方式运行socat

$ socat -d -d - TCP4:httpbin.org:80
2021/04/02 15:12:43 socat[22364] N reading from and writing to stdio
2021/04/02 15:12:43 socat[22364] N opening connection to LEN=16 AF=2 34.199.75.4:80
2021/04/02 15:12:43 socat[22364] N successfully connected from local address LEN=16 AF=2 10.1.186.126:57360
2021/04/02 15:12:43 socat[22364] N starting data transfer loop with FDs [0,1] and [7,7]
GET /get HTTP/1.1
Host: myhost

HTTP/1.1 200 OK
Date: Fri, 02 Apr 2021 20:12:59 GMT
Content-Type: application/json
Content-Length: 190
Connection: keep-alive
Server: gunicorn/19.9.0
Access-Control-Allow-Origin: *
Access-Control-Allow-Credentials: true

{
  "args": {},
  "headers": {
    "Host": "myhost",
    "X-Amzn-Trace-Id": "Root=1-60677acb-1e2c974a0fb9bee97b8072dd"
  },
  "origin": "XXX.XXX.XXX.XXX",
  "url": "http://myhost/get"
}
但是当我使用heredoc时,我没有得到相同的输出。有人知道如何让它与Herdeoc合作吗

$ socat -d -d - TCP4:httpbin.org:80 <<EOF
GET /get HTTP/1.1
Host: httpbin.org

EOF
2021/04/02 15:16:42 socat[22870] N reading from and writing to stdio
2021/04/02 15:16:42 socat[22870] N opening connection to LEN=16 AF=2 54.166.163.67:80
2021/04/02 15:16:42 socat[22870] N successfully connected from local address LEN=16 AF=2 10.1.186.126:58356
2021/04/02 15:16:42 socat[22870] N starting data transfer loop with FDs [0,1] and [7,7]
2021/04/02 15:16:42 socat[22870] N socket 1 (fd 0) is at EOF
2021/04/02 15:16:42 socat[22870] N socket 2 (fd 7) is at EOF
2021/04/02 15:16:42 socat[22870] N exiting with status 0

$socat-d-d-TCP4:httpbin.org:80我觉得我不完全理解发生了什么,但我认为herdoc的结尾是在HTTP请求返回之前发出关闭流的信号。解决这个问题的一种方法是使用FD选项shutnone

socat -d -d - TCP4:httpbin.org:80,shut-none <<EOF
GET /get HTTP/1.1
Host: httpbin.org

EOF
socat-d-d-TCP4:httpbin.org:80,关闭无