int http_code;
/* Used if "Transfer-Encoding: chunked" otherwise -1. */
uint64_t chunksize;
+ int chunkend;
uint64_t off, end_off, filesize;
char *location;
HTTPAuthState auth_state;
const char *hoststr, const char *auth,
const char *proxyauth, int *new_location);
static int http_read_header(URLContext *h, int *new_location);
+static int http_shutdown(URLContext *h, int flags);
void ff_http_init_auth_state(URLContext *dest, const URLContext *src)
{
AVDictionary *options = NULL;
int ret;
+ ret = http_shutdown(h, h->flags);
+ if (ret < 0)
+ return ret;
+
+ s->end_chunked_post = 0;
+ s->chunkend = 0;
s->off = 0;
s->icy_data_read = 0;
av_free(s->location);
int len;
if (s->chunksize != UINT64_MAX) {
+ if (s->chunkend) {
+ return AVERROR_EOF;
+ }
if (!s->chunksize) {
char line[32];
int err;
s->chunksize = strtoull(line, NULL, 16);
av_log(h, AV_LOG_TRACE,
- "Chunked encoding data size: %"PRIu64"'\n",
+ "Chunked encoding data size: %"PRIu64"\n",
s->chunksize);
- if (!s->chunksize) {
+ if (!s->chunksize && s->multiple_requests) {
+ http_get_line(s, line, sizeof(line)); // read empty chunk
+ s->chunkend = 1;
+ return 0;
+ }
+ else if (!s->chunksize) {
av_log(h, AV_LOG_DEBUG, "Last chunk received, closing conn\n");
ffurl_closep(&s->hd);
return 0;