Description
I did this
curl -v httpbin.org/post --data foobar -C 3
I expected the following
Not sure what to expect (POST data "bar", maybe?), but surely not the current behavior:
$ curl -v httpbin.org/post --data foobar -C3
* Trying 34.235.32.249:80...
* Connected to httpbin.org (34.235.32.249) port 80 (#0)
and now it blocks forever, because it tries to read from stdin, seen from the strace
log
lseek(0, 3, SEEK_SET) = -1 ESPIPE (Illegal seek)
read(0,
Now if I feed some data into stdin, say yes | curl -v httpbin.org/post --data foobar -C 3
, curl will POST the string "foo"
, not "bar"
or "y\ny"
.
$ yes|curl -v httpbin.org/post --data foobar -C3
* Trying 34.235.32.249:80...
* Connected to httpbin.org (34.235.32.249) port 80 (#0)
> POST /post HTTP/1.1
> Host: httpbin.org
> Content-Range: bytes 3-5/6
> User-Agent: curl/8.0.1
> Accept: */*
> Content-Length: 3
> Content-Type: application/x-www-form-urlencoded
>
< HTTP/1.1 200 OK
< Date: Sun, 07 May 2023 17:05:37 GMT
< Content-Type: application/json
< Content-Length: 458
< Connection: keep-alive
< Server: gunicorn/19.9.0
< Access-Control-Allow-Origin: *
< Access-Control-Allow-Credentials: true
<
{
"args": {},
"data": "",
"files": {},
"form": {
"foo": ""
},
"headers": {
"Accept": "*/*",
"Content-Length": "3",
"Content-Range": "bytes 3-5/6",
"Content-Type": "application/x-www-form-urlencoded",
"Host": "httpbin.org",
"User-Agent": "curl/8.0.1",
"X-Amzn-Trace-Id": "Root=1-XXX"
},
"json": null,
"origin": "XXX",
"url": "http://httpbin.org/post"
}
* Connection #0 to host httpbin.org left intact
curl/libcurl version
curl 8.0.1 (x86_64-pc-linux-gnu) libcurl/8.0.1 OpenSSL/3.0.7 zlib/1.2.13 brotli/1.0.9 zstd/1.5.2 libidn2/2.3.4 libpsl/0.21.2 (+libidn2/2.3.4) libssh2/1.10.0 nghttp2/1.51.0
Release-Date: [unreleased]
Protocols: dict file ftp ftps gopher gophers http https imap imaps mqtt pop3 pop3s rtsp scp sftp smb smbs smtp smtps telnet tftp
Features: alt-svc AsynchDNS brotli GSS-API HSTS HTTP2 HTTPS-proxy IDN IPv6 Kerberos Largefile libz NTLM NTLM_WB PSL SPNEGO SSL threadsafe TLS-SRP UnixSockets zstd
operating system
Linux arch 5.15.86-1-lts #1 SMP Sun, 01 Jan 2023 16:03:00 +0000 x86_64 GNU/Linux