curl / Mailing Lists / curl-users / Single Mail
Buy commercial curl support from WolfSSL. 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 himself.

Re: Why curl does not send `Connection: Keep-Alive` in the header by default?

From: Ray Satiro via curl-users <curl-users_at_cool.haxx.se>
Date: Sat, 2 Nov 2019 00:45:22 -0400

On 11/2/2019 12:18 AM, Peng Yu via curl-users wrote:
> Here is the netcat output of curl.
>
> ```
> $ nc -l -p 9000
> HEAD / HTTP/1.1
> Host: localhost:9000
> User-Agent: curl/7.66.0
> Accept: */*
>
> $ curl -ss -iLIhttp://localhost:9000
> ```
>
> Here is the netcat output of wget. Does anybody know why curl does not
> use the same request header as the wget? Is there an option to make
> curl behave the same as wget in this aspect? Thanks.
>
> ```
> $ nc -l -p 9000
> HEAD / HTTP/1.1
> User-Agent: Wget/1.20.3 (darwin18.6.0)
> Accept: */*
> Accept-Encoding: identity
> Host: localhost:9000
> Connection: Keep-Alive
>
> $ wget -q --spider -S -o-http://localhost:9000

HTTP 1.1 connections are considered persistent by default, the client
does not need to send keep-alive and if you enable verbose mode you'll
see curl keeps the connection open. However if for some reason you are
using HTTP 1.0 then you can use -H "Connection: Keep-Alive" to signal to
the server.

-----------------------------------------------------------
Unsubscribe: https://cool.haxx.se/list/listinfo/curl-users
Etiquette: https://curl.haxx.se/mail/etiquette.html
Received on 2019-11-02