Send/POST file contents with newlines to a web server
Posted on 2016-09-21
Using command line bash on Linux, trying to find a solution which allows sending a file and it's contents, intact with newlines, etc, to another host. Am finding countless examples and suggestions but not one that works for me at least, so far.
I won't bother posting all of the variations I've tried but here is the last I've tried.
curl -s --cacert /etc/ssl/certs/ca-certificates.crt -u "1234:4321" --data "@/tmp/testfile" https://domain.com/
> POST / HTTP/1.1
> Authorization: Basic MDgfYhfsDBfgfvfgOSgTssU0wam12V245b1daeGFrYVRBbmpSeW1EN2tNcVlXVXZrbUU=
> User-Agent: curl/7.38.0
> Host: domain.com
> Accept: */*
> Content-Length: 5603
> Content-Type: application/x-www-form-urlencoded
> Expect: 100-continue
< HTTP/1.1 100 Continue
< HTTP/1.1 204 No Content
< Date: Tue, 20 Sep 2016 17:53:50 GMT
< Server: Apache
< Cache-Control: no-cache
< Content-Length: 0
< Content-Type: text/html; charset=UTF-8
I've also read that you need to use -o for output which I've tried, etc etc. There must be way of doing this.
The resulting file on the remote host should contain the user name being used to send it.
So, in this case, 1234-testfile