Buy commercial curl support. We
help you work out your issues, debug your libcurl applications, use the API,
port to new platforms, add new features and more. With a team lead by the
curl founder Daniel himself.
RE: how to keep connection open after receiving the last response?
- Contemporary messages sorted: [ by date ] [ by thread ] [ by subject ] [ by author ] [ by messages with attachments ]
From: Adrien Kunysz via curl-users <curl-users_at_lists.haxx.se>
Date: Wed, 15 Oct 2025 12:29:20 +0000
Daniel Stenberg <daniel_at_haxx.se> wrote:
> curl does transfers. When the last transfer is done, it exits back to the shell.
>
> To validate keepalive in a server, just do a second transfer on the same
> command line and ask curl to tell you how many connections it needed. Or just
> read the verbose output that tells if it reuses a connection vs creates a new.
>
> Or make the last transfer just never end so that curl will sit waiting for the
> transfer to complete.
I want to specifically test how long the server waits before it closes the connection
after the last transfer completed.
>> Is there a way to do the same with curl? If not, would that be an acceptable
>> feature request?
>
> What exactly what that be useful for except for your quite particular niche
> use case?
I agree it's a niche use case and if the point of curl is to transfer file (as opposed
to troubleshoot HTTP services; although that's mostly what I use it for), it might not
be a suitable feature.
> And how long would just sit there keeping the connection alive without doing anything?
As long as necessary :) I imagine the relevant commandline option would take an
argument telling it how long to wait. The default would be 0 (current behaviour).
Maybe a negative number would mean "forever". It could also have a different exit
code depending on whether the server or the client closed the connection first. I
have no idea how much that would make sense for protocols other than HTTP/1.1.
Date: Wed, 15 Oct 2025 12:29:20 +0000
Daniel Stenberg <daniel_at_haxx.se> wrote:
> curl does transfers. When the last transfer is done, it exits back to the shell.
>
> To validate keepalive in a server, just do a second transfer on the same
> command line and ask curl to tell you how many connections it needed. Or just
> read the verbose output that tells if it reuses a connection vs creates a new.
>
> Or make the last transfer just never end so that curl will sit waiting for the
> transfer to complete.
I want to specifically test how long the server waits before it closes the connection
after the last transfer completed.
>> Is there a way to do the same with curl? If not, would that be an acceptable
>> feature request?
>
> What exactly what that be useful for except for your quite particular niche
> use case?
I agree it's a niche use case and if the point of curl is to transfer file (as opposed
to troubleshoot HTTP services; although that's mostly what I use it for), it might not
be a suitable feature.
> And how long would just sit there keeping the connection alive without doing anything?
As long as necessary :) I imagine the relevant commandline option would take an
argument telling it how long to wait. The default would be 0 (current behaviour).
Maybe a negative number would mean "forever". It could also have a different exit
code depending on whether the server or the client closed the connection first. I
have no idea how much that would make sense for protocols other than HTTP/1.1.
-- Unsubscribe: https://lists.haxx.se/mailman/listinfo/curl-users Etiquette: https://curl.se/mail/etiquette.htmlReceived on 2025-10-15