MCPcopy Create free account
hub / github.com/FFmpeg/FFmpeg / http_read_header

Function http_read_header

libavformat/http.c:1438–1494  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1436}
1437
1438static int http_read_header(URLContext *h)
1439{
1440 HTTPContext *s = h->priv_data;
1441 char line[MAX_URL_SIZE];
1442 int err = 0, http_err = 0;
1443
1444 av_freep(&s->new_location);
1445 s->expires = 0;
1446 s->chunksize = UINT64_MAX;
1447 s->filesize_from_content_range = UINT64_MAX;
1448
1449 for (;;) {
1450 int parsed_http_code = 0;
1451
1452 if ((err = http_get_line(s, line, sizeof(line))) < 0) {
1453 av_log(h, AV_LOG_ERROR, "Error reading HTTP response: %s\n",
1454 av_err2str(err));
1455 return err;
1456 }
1457
1458 av_log(h, AV_LOG_TRACE, "header='%s'\n", line);
1459
1460 err = process_line(h, line, s->line_count, &parsed_http_code);
1461 if (err < 0) {
1462 if (parsed_http_code) {
1463 http_err = err;
1464 } else {
1465 /* Prefer to return HTTP code error if we've already seen one. */
1466 if (http_err)
1467 return http_err;
1468 else
1469 return err;
1470 }
1471 }
1472 if (err == 0)
1473 break;
1474 s->line_count++;
1475 }
1476 if (http_err)
1477 return http_err;
1478
1479 // filesize from Content-Range can always be used, even if using chunked Transfer-Encoding
1480 if (s->filesize_from_content_range != UINT64_MAX)
1481 s->filesize = s->filesize_from_content_range;
1482
1483 if (s->seekable == -1 && s->is_mediagateway && s->filesize == 2000000000)
1484 h->is_streamed = 1; /* we can in fact _not_ seek */
1485
1486 if (h->is_streamed)
1487 s->initial_requests = 0; /* unable to use partial requests */
1488
1489 // add any new cookies into the existing cookie string
1490 cookie_string(s->cookie_dict, &s->cookies);
1491 av_dict_free(&s->cookie_dict);
1492
1493 return err;
1494}
1495

Callers 4

http_handshakeFunction · 0.85
http_connectFunction · 0.85
http_read_streamFunction · 0.85
http_proxy_openFunction · 0.85

Calls 6

av_freepFunction · 0.85
http_get_lineFunction · 0.85
av_logFunction · 0.85
process_lineFunction · 0.85
cookie_stringFunction · 0.85
av_dict_freeFunction · 0.85

Tested by

no test coverage detected