url_split(NULL, 0, hostname, sizeof(hostname), &port,
url_split(NULL, 0, auth, sizeof(auth), hostname, sizeof(hostname), &port,
static int http_open(URLContext *h, const char *uri, int flags){    const char *path, *proxy_path;    char hostname[1024], hoststr[1024];    char path1[1024];    char buf[1024];    int port, use_proxy, err;    HTTPContext *s;    URLContext *hd = NULL;    h->is_streamed = 1;    s = av_malloc(sizeof(HTTPContext));    if (!s) {        return -ENOMEM;    }    h->priv_data = s;    proxy_path = getenv("http_proxy");    use_proxy = (proxy_path != NULL) && !getenv("no_proxy") &&         strstart(proxy_path, "http://", NULL);    /* fill the dest addr */ redo:    /* needed in any case to build the host string */    url_split(NULL, 0, hostname, sizeof(hostname), &port,               path1, sizeof(path1), uri);    if (port > 0) {        snprintf(hoststr, sizeof(hoststr), "%s:%d", hostname, port);    } else {        pstrcpy(hoststr, sizeof(hoststr), hostname);    }    if (use_proxy) {        url_split(NULL, 0, hostname, sizeof(hostname), &port,                   NULL, 0, proxy_path);        path = uri;    } else {        if (path1[0] == '\0')            path = "/";        else            path = path1;    }    if (port < 0)        port = 80;    snprintf(buf, sizeof(buf), "tcp://%s:%d", hostname, port);    err = url_open(&hd, buf, URL_RDWR);    if (err < 0)        goto fail;    s->hd = hd;    if (http_connect(h, path, hoststr) < 0)        goto fail;    if (s->http_code == 303 && s->location[0] != '\0') {        /* url moved, get next */        uri = s->location;        url_close(hd);        goto redo;    }    return 0; fail:    if (hd)        url_close(hd);    av_free(s);    return AVERROR_IO;}