Re: [PATCH v2 3/3] http: automatically retry some requests
- From
Sean McAllister <smcallis@google.com>
- Date
- Oct 15, 2020, 16:33 UTC
- Message-ID
- <CAM4o00ehgWp6nHi9yN7TyvoNu593OaMWW1f9FA1q9Cw+HdLZeg@mail.gmail.com>
- In-Reply-To
- <20201015162343.GC1104947@coredump.intra.peff.net>
Show 21 quoted lines
>
> I was less concerned with the overhead of the strbuf (http requests are
> pretty heavyweight already) and more that it could simplify your parsing
> if you could just do it left-to-right on a single line:
>
> char *line = xmemdupz(buffer, size);
> const char *p = line;
> if (skip_iprefix(p, "retry-after:", &p)) {
> char *end;
> while (isspace(*p))
> p++;
> opts->retry_after = strtol(p, &end, 10);
> /* if you want to be pedantic */
> if (*end && *end != '\r' && *end != '\n')
> opts->retry_after = 0; /* warn, too? */
> }
>
> If you want to be clever, you could probably avoid the extra allocation,
> but I think being able to parse with simple string functions makes it
> much more obvious that we don't walk off the end of the input.
>The latest code effectively does this per Dosch' suggestion. No more string splitting, it just parses it as a single big string as you mention. It sounds like we're quickly settling on using CURLINFO_RETRY_AFTER when available, and not retrying otherwise, so it might be OBE.