Is there a way of getting curl (command line tool) to keep a http connection open? I am trying to test/debug a server application, which has a client that opens a http connection, makes a PUT request and leaves it open until some further action, and have been trying to use curl to simulate this.
However, according to the curl website:
The curl command-line tool can, however, only keep connections alive for as long as it runs, so as soon as it exits back to your command line it has to close down all currently open connections.
That much is fine, but is there a way of forcing it not to exit back to the command line (until I press any key or Ctrl-C or whatever it prefers), and therefore hold the connection open while I do the testing?
I have tried the "Connection: keep-alive"
header but this doesn't do the trick, the process still ends as soon as it's made the request, and the connection is closed.
If not, is there an alternative tool that can do this?
You can "trick" curl to keep the connection open. For example like this:
nc
to listen to a local port, say 8080 (nc -l -p 8080
on some versions of nc)This will make curl hold the first connection in its pool when it gets the second URL, and you make that second transfer just hang "indefinitely" which will make curl just leave the first connection open and alive until you control-c that or your nc process.