Thread (16 messages) 16 messages, 4 authors, 2020-10-15

Re: [PATCH v2 3/3] http: automatically retry some requests

flat view

From: Sean McAllister <hidden>
Date: 2020-10-15 16:34:10

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.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help