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

Function http_connect

libavformat/http.c:1527–1708  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1525}
1526
1527static int http_connect(URLContext *h, const char *path, const char *local_path,
1528 const char *hoststr, const char *auth,
1529 const char *proxyauth)
1530{
1531 HTTPContext *s = h->priv_data;
1532 int post, err;
1533 AVBPrint request;
1534 char *authstr = NULL, *proxyauthstr = NULL;
1535 uint64_t off = s->off;
1536 const char *method;
1537 int send_expect_100 = 0;
1538
1539 av_bprint_init_for_buffer(&request, s->buffer, sizeof(s->buffer));
1540
1541 /* send http header */
1542 post = h->flags & AVIO_FLAG_WRITE;
1543
1544 if (s->post_data) {
1545 /* force POST method and disable chunked encoding when
1546 * custom HTTP post data is set */
1547 post = 1;
1548 s->chunked_post = 0;
1549 }
1550
1551 if (s->method)
1552 method = s->method;
1553 else
1554 method = post ? "POST" : "GET";
1555
1556 authstr = ff_http_auth_create_response(&s->auth_state, auth,
1557 local_path, method);
1558 proxyauthstr = ff_http_auth_create_response(&s->proxy_auth_state, proxyauth,
1559 local_path, method);
1560
1561 if (post && !s->post_data) {
1562 if (s->send_expect_100 != -1) {
1563 send_expect_100 = s->send_expect_100;
1564 } else {
1565 send_expect_100 = 0;
1566 /* The user has supplied authentication but we don't know the auth type,
1567 * send Expect: 100-continue to get the 401 response including the
1568 * WWW-Authenticate header, or an 100 continue if no auth actually
1569 * is needed. */
1570 if (auth && *auth &&
1571 s->auth_state.auth_type == HTTP_AUTH_NONE &&
1572 s->http_code != 401)
1573 send_expect_100 = 1;
1574 }
1575 }
1576
1577 av_bprintf(&request, "%s ", method);
1578 bprint_escaped_path(&request, path);
1579 av_bprintf(&request, " HTTP/1.1\r\n");
1580
1581 if (post && s->chunked_post)
1582 av_bprintf(&request, "Transfer-Encoding: chunked\r\n");
1583 /* set default headers if needed */
1584 if (!has_header(s->headers, "\r\nUser-Agent: "))

Callers 1

http_open_cnx_internalFunction · 0.85

Calls 13

av_bprintfFunction · 0.85
bprint_escaped_pathFunction · 0.85
has_headerFunction · 0.85
get_cookiesFunction · 0.85
av_logFunction · 0.85
av_bprint_is_completeFunction · 0.85
ffurl_writeFunction · 0.85
av_gettimeFunction · 0.85
http_read_headerFunction · 0.85
av_freepFunction · 0.85

Tested by

no test coverage detected