Skip to content

Commit

Permalink
http: Retry request (once) on error receiving response
Browse files Browse the repository at this point in the history
A Juniper server has been encountered in the wild which sends an initial
302 redirect without Connection:close, but then just closes the connection
when it receives the next request.

This happens only for the first redirect to /dana-na/auth/… and not for
subsequent redirects through cookie-check and realm stuff. So instead of
a preemptive hack to avoid connection reuse for *all* redirects in NC,
just cope with it when it happens.

Since rq_retry is only set when the connection is already open, it won't
get set again the second time round, thus avoiding endless retries.

Fixes: #96

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
  • Loading branch information
dwmw2 committed Jan 15, 2020
1 parent 1da8ab7 commit 01ef9ea
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions http.c
Expand Up @@ -1085,6 +1085,15 @@ int do_https_request(struct openconnect_info *vpninfo, const char *method,

result = process_http_response(vpninfo, 0, http_auth_hdrs, buf);
if (result < 0) {
if (rq_retry) {
openconnect_close_https(vpninfo, 0);
vpn_progress(vpninfo, PRG_INFO,
_("Retrying failed %s request on new connection\n"),
method);
/* All the way back to 'redirected' since we need to rebuild
* the request in 'buf' from scratch. */
goto redirected;
}
goto out;
}
if (vpninfo->dump_http_traffic && buf->pos)
Expand Down

0 comments on commit 01ef9ea

Please sign in to comment.