int port, use_proxy, err, location_changed = 0, redirects = 0, attempts = 0;
HTTPAuthType cur_auth_type, cur_proxy_auth_type;
HTTPContext *s = h->priv_data;
- URLContext *hd = NULL;
proxy_path = getenv("http_proxy");
use_proxy = (proxy_path != NULL) && !getenv("no_proxy") &&
ff_url_join(buf, sizeof(buf), lower_proto, NULL, hostname, port, NULL);
if (!s->hd) {
- err = ffurl_open(&hd, buf, AVIO_FLAG_READ_WRITE,
+ err = ffurl_open(&s->hd, buf, AVIO_FLAG_READ_WRITE,
&h->interrupt_callback, NULL);
if (err < 0)
goto fail;
-
- s->hd = hd;
}
cur_auth_type = s->auth_state.auth_type;
if (s->http_code == 401) {
if ((cur_auth_type == HTTP_AUTH_NONE || s->auth_state.stale) &&
s->auth_state.auth_type != HTTP_AUTH_NONE && attempts < 4) {
- ffurl_close(hd);
- s->hd = hd = NULL;
+ ffurl_close(s->hd);
+ s->hd = NULL;
goto redo;
} else
goto fail;
if (s->http_code == 407) {
if ((cur_proxy_auth_type == HTTP_AUTH_NONE || s->proxy_auth_state.stale) &&
s->proxy_auth_state.auth_type != HTTP_AUTH_NONE && attempts < 4) {
- ffurl_close(hd);
- s->hd = hd = NULL;
+ ffurl_close(s->hd);
+ s->hd = NULL;
goto redo;
} else
goto fail;
if ((s->http_code == 301 || s->http_code == 302 || s->http_code == 303 || s->http_code == 307)
&& location_changed == 1) {
/* url moved, get next */
- ffurl_close(hd);
- s->hd = hd = NULL;
+ ffurl_close(s->hd);
+ s->hd = NULL;
if (redirects++ >= MAX_REDIRECTS)
return AVERROR(EIO);
/* Restart the authentication process with the new target, which
}
return 0;
fail:
- if (hd)
- ffurl_close(hd);
+ if (s->hd)
+ ffurl_close(s->hd);
s->hd = NULL;
return AVERROR(EIO);
}