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: Confusing output when using `--retry-connrefused`

From: Dave Reisner via curl-users <curl-users_at_cool.haxx.se>
Date: Thu, 19 Mar 2020 08:30:48 -0400

On Thu, Mar 19, 2020 at 8:17 AM Matthias Endler via curl-users <
curl-users_at_cool.haxx.se> wrote:

> Something is odd when I try to use `--retry-connrefused`.
>
> Consider this request:
>
> ```
>
> curl --write-out '%{http_code}' --output /dev/null --silent http://example.com
>
> 200
>
> ```
>
> Adding --retry-connrefused 1, I get the following output:
>
> ```
>
> curl --write-out '%{http_code}' --output /dev/null --silent --retry-connrefused 1 http://example.com
>
> --retry-connrefused doesn't expect a value, so your commandline is the
equivalent of writing:

curl --write-out '%{http_code}' --output /dev/null --silent
--retry-connrefused http://0.0.0.1 http://example.com

curl writes out:

1) the empty response body from http://0.0.0.1 to /dev/null (that's what
you asked it to do)
2) "000" as the response code from the failed request to http://0.0.0.1
3) the output of http://example.com to stdout (because there's no other
instructions for where to write the body).
4) "200" as the response code from the successful request to
http://example.com

>
> 000<!doctype html>
> <html>
> <head>
> <title>Example Domain</title>
> <meta charset="utf-8" />
> <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
> <meta name="viewport" content="width=device-width, initial-scale=1" />
> <style type="text/css">
> body {
> background-color: #f0f0f2;
> margin: 0;
> padding: 0;
> font-family: -apple-system, system-ui, BlinkMacSystemFont, "Segoe UI", "Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif;
> }
> div {
> width: 600px;
> margin: 5em auto;
> padding: 2em;
> background-color: #fdfdff;
> border-radius: 0.5em;
> box-shadow: 2px 3px 7px 2px rgba(0,0,0,0.02);
> }
> a:link, a:visited {
> color: #38488f;
> text-decoration: none;
> }
> @media (max-width: 700px) {
> div {
> margin: 0 auto;
> width: auto;
> }
> }
> </style>
> </head>
> <body>
> <div>
> <h1>Example Domain</h1>
> <p>This domain is for use in illustrative examples in documents. You may use this
> domain in literature without prior coordination or asking for permission.</p>
> <p>More information...</p>
> </div>
> </body>
> </html>
> 200%
>
> ```
>
> Is that expected behavior or did I trigger a bug?
>
> Cheers,
>
> Matthias
>
>
>
>
> -----------------------------------------------------------
> Unsubscribe: https://cool.haxx.se/list/listinfo/curl-users
> Etiquette: https://curl.haxx.se/mail/etiquette.html
>

-----------------------------------------------------------
Unsubscribe: https://cool.haxx.se/list/listinfo/curl-users
Etiquette: https://curl.haxx.se/mail/etiquette.html
Received on 2020-03-19