| 767 | } |
| 768 | |
| 769 | static int http_open(URLContext *h, const char *uri, int flags, |
| 770 | AVDictionary **options) |
| 771 | { |
| 772 | HTTPContext *s = h->priv_data; |
| 773 | int ret; |
| 774 | |
| 775 | if( s->seekable == 1 ) |
| 776 | h->is_streamed = 0; |
| 777 | else |
| 778 | h->is_streamed = 1; |
| 779 | |
| 780 | s->initial_requests = s->seekable != 0 && s->initial_request_size > 0; |
| 781 | s->filesize = UINT64_MAX; |
| 782 | |
| 783 | s->location = av_strdup(uri); |
| 784 | if (!s->location) |
| 785 | return AVERROR(ENOMEM); |
| 786 | |
| 787 | s->uri = av_strdup(uri); |
| 788 | if (!s->uri) |
| 789 | return AVERROR(ENOMEM); |
| 790 | |
| 791 | if (options) |
| 792 | av_dict_copy(&s->chained_options, *options, 0); |
| 793 | |
| 794 | if (s->headers) { |
| 795 | int len = strlen(s->headers); |
| 796 | if (len < 2 || strcmp("\r\n", s->headers + len - 2)) { |
| 797 | av_log(h, AV_LOG_WARNING, |
| 798 | "No trailing CRLF found in HTTP header. Adding it.\n"); |
| 799 | ret = av_reallocp(&s->headers, len + 3); |
| 800 | if (ret < 0) |
| 801 | goto bail_out; |
| 802 | s->headers[len] = '\r'; |
| 803 | s->headers[len + 1] = '\n'; |
| 804 | s->headers[len + 2] = '\0'; |
| 805 | } |
| 806 | } |
| 807 | |
| 808 | if (s->listen) { |
| 809 | return http_listen(h, uri, flags, options); |
| 810 | } |
| 811 | ret = http_open_cnx(h, options); |
| 812 | bail_out: |
| 813 | if (ret < 0) { |
| 814 | av_dict_free(&s->chained_options); |
| 815 | av_dict_free(&s->cookie_dict); |
| 816 | av_dict_free(&s->redirect_cache); |
| 817 | av_freep(&s->new_location); |
| 818 | av_freep(&s->uri); |
| 819 | } |
| 820 | return ret; |
| 821 | } |
| 822 | |
| 823 | static int http_accept(URLContext *s, URLContext **c) |
| 824 | { |
nothing calls this directly
no test coverage detected