我正在尝试使用SSE从服务器尾随日志,使用curl和SSE一起工作正常,但是当使用管道传输时,curl将不会输出任何内容。
# This is ok
curl localhost:8080/logging/tail
输出
data:2017-06-14 11:57:21.345 WARN 56999 --- [nio-8080-exec-4] a.b.c : ABC
data:2017-06-14 11:57:21.353 INFO 56999 --- [nio-8080-exec-4] a.b.c : DEF
使用管道
# Nothing show up, with -s or not
# Without -s, the process show's curl do receive data
curl -s localhost:8080/logging/tail | sed '/^\s*$/d'
curl -s localhost:8080/logging/tail | cat
如何使curl sse与管道配合工作? 我想要去掉sse输出中的
data:
前缀和空行。$ curl --version
curl 7.51.0 (x86_64-apple-darwin16.0) libcurl/7.51.0 SecureTransport zlib/1.2.8
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtsp smb smbs smtp smtps telnet tftp
Features: AsynchDNS IPv6 Largefile GSS-API Kerberos SPNEGO NTLM NTLM_WB SSL libz UnixSockets
服务器是Spring的SseEmitter。