+ if (!h->prot ||
+ !(!strcmp(h->prot->name, "http") ||
+ !strcmp(h->prot->name, "https")))
+ return AVERROR(EINVAL);
+
+ av_url_split(proto1, sizeof(proto1), NULL, 0,
+ hostname1, sizeof(hostname1), &port1,
+ NULL, 0, s->location);
+ av_url_split(proto2, sizeof(proto2), NULL, 0,
+ hostname2, sizeof(hostname2), &port2,
+ NULL, 0, uri);
+ if (port1 != port2 || strncmp(hostname1, hostname2, sizeof(hostname2)) != 0) {
+ av_log(h, AV_LOG_ERROR, "Cannot reuse HTTP connection for different host: %s:%d != %s:%d\n",
+ hostname1, port1,
+ hostname2, port2
+ );
+ return AVERROR(EINVAL);
+ }
+
+ if (!s->end_chunked_post) {
+ ret = http_shutdown(h, h->flags);
+ if (ret < 0)
+ return ret;
+ }
+
+ if (s->willclose)
+ return AVERROR_EOF;