| 525 | } |
| 526 | |
| 527 | int ff_http_do_new_request2(URLContext *h, const char *uri, AVDictionary **opts) |
| 528 | { |
| 529 | HTTPContext *s = h->priv_data; |
| 530 | AVDictionary *options = NULL; |
| 531 | int ret; |
| 532 | char hostname1[1024], hostname2[1024], proto1[10], proto2[10]; |
| 533 | int port1, port2; |
| 534 | |
| 535 | if (!h->prot || |
| 536 | !(!strcmp(h->prot->name, "http") || |
| 537 | !strcmp(h->prot->name, "https"))) |
| 538 | return AVERROR(EINVAL); |
| 539 | |
| 540 | av_url_split(proto1, sizeof(proto1), NULL, 0, |
| 541 | hostname1, sizeof(hostname1), &port1, |
| 542 | NULL, 0, s->location); |
| 543 | av_url_split(proto2, sizeof(proto2), NULL, 0, |
| 544 | hostname2, sizeof(hostname2), &port2, |
| 545 | NULL, 0, uri); |
| 546 | if (strcmp(proto1, proto2) != 0) { |
| 547 | av_log(h, AV_LOG_INFO, "Cannot reuse HTTP connection for different protocol %s vs %s\n", |
| 548 | proto1, proto2); |
| 549 | return AVERROR(EINVAL); |
| 550 | } |
| 551 | if (port1 != port2 || strncmp(hostname1, hostname2, sizeof(hostname2)) != 0) { |
| 552 | av_log(h, AV_LOG_INFO, "Cannot reuse HTTP connection for different host: %s:%d != %s:%d\n", |
| 553 | hostname1, port1, |
| 554 | hostname2, port2 |
| 555 | ); |
| 556 | return AVERROR(EINVAL); |
| 557 | } |
| 558 | |
| 559 | if (!s->end_chunked_post) { |
| 560 | ret = http_shutdown(h, h->flags); |
| 561 | if (ret < 0) |
| 562 | return ret; |
| 563 | } |
| 564 | |
| 565 | if (s->willclose) |
| 566 | return AVERROR_EOF; |
| 567 | |
| 568 | s->end_chunked_post = 0; |
| 569 | s->chunkend = 0; |
| 570 | s->off = 0; |
| 571 | s->icy_data_read = 0; |
| 572 | |
| 573 | av_free(s->location); |
| 574 | s->location = av_strdup(uri); |
| 575 | if (!s->location) |
| 576 | return AVERROR(ENOMEM); |
| 577 | |
| 578 | av_free(s->uri); |
| 579 | s->uri = av_strdup(uri); |
| 580 | if (!s->uri) |
| 581 | return AVERROR(ENOMEM); |
| 582 | |
| 583 | if ((ret = av_opt_set_dict(s, opts)) < 0) |
| 584 | return ret; |
no test coverage detected