• Home
  • Raw
  • Download

Lines Matching +full:stale +full:- +full:issue +full:- +full:message

19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
68 /* Used if "Transfer-Encoding: chunked" otherwise -1. */
85 int seekable; /**< Control seekability, 0 = disable, 1 = enable, -1 = probe. */
97 …okies; ///< holds newline (\n) delimited Set-Cookie header field values (without the "Set
114 /* -1 = try to send if applicable, 0 = always disabled, 1 = always enabled */
137 …"control seekability of connection", OFFSET(seekable), AV_OPT_TYPE_BOOL, { .i64 = -1 }, -1, 1, D },
138 …{ "chunked_post", "use chunked transfer-encoding for posts", OFFSET(chunked_post), AV_OPT_TYPE_BOO…
142 …{ "user_agent", "override User-Agent header", OFFSET(user_agent), AV_OPT_TYPE_STRING, { .str = DEF…
145 …{ "user-agent", "use the \"user_agent\" option instead", OFFSET(user_agent), AV_OPT_TYPE_STRING, {…
151 …{ "cookies", "set cookies to be sent in applicable future requests, use newline delimited Set-Cook…
159 …0", "Force sending an Expect: 100-continue header for POST", OFFSET(send_expect_100), AV_OPT_TYPE_…
184 memcpy(&((HTTPContext *)dest->priv_data)->auth_state, in ff_http_init_auth_state()
185 &((HTTPContext *)src->priv_data)->auth_state, in ff_http_init_auth_state()
187 memcpy(&((HTTPContext *)dest->priv_data)->proxy_auth_state, in ff_http_init_auth_state()
188 &((HTTPContext *)src->priv_data)->proxy_auth_state, in ff_http_init_auth_state()
201 HTTPContext *s = h->priv_data; in http_open_cnx_internal()
205 path1, sizeof(path1), s->location); in http_open_cnx_internal()
208 proxy_path = s->http_proxy ? s->http_proxy : getenv("http_proxy"); in http_open_cnx_internal()
218 if (s->http_proxy) { in http_open_cnx_internal()
219 err = av_dict_set(options, "http_proxy", s->http_proxy, 0); in http_open_cnx_internal()
241 /* Reassemble the request URL without auth string - we don't in http_open_cnx_internal()
252 if (!s->hd) { in http_open_cnx_internal()
253 err = ffurl_open_whitelist(&s->hd, buf, AVIO_FLAG_READ_WRITE, in http_open_cnx_internal()
254 &h->interrupt_callback, options, in http_open_cnx_internal()
255 h->protocol_whitelist, h->protocol_blacklist, h); in http_open_cnx_internal()
287 return s->reconnect_on_network_error; in http_should_reconnect()
290 if (!s->reconnect_on_http_error) in http_should_reconnect()
293 if (av_match_list(status_group, s->reconnect_on_http_error, ',') > 0) in http_should_reconnect()
296 snprintf(http_code, sizeof(http_code), "%d", s->http_code); in http_should_reconnect()
298 return av_match_list(http_code, s->reconnect_on_http_error, ',') > 0; in http_should_reconnect()
305 HTTPContext *s = h->priv_data; in http_open_cnx()
311 av_dict_copy(options, s->chained_options, 0); in http_open_cnx()
313 cur_auth_type = s->auth_state.auth_type; in http_open_cnx()
314 cur_proxy_auth_type = s->auth_state.auth_type; in http_open_cnx()
316 off = s->off; in http_open_cnx()
320 reconnect_delay > s->reconnect_delay_max) in http_open_cnx()
324 …location_changed = ff_network_sleep_interruptible(1000U * 1000 * reconnect_delay, &h->interrupt_ca… in http_open_cnx()
330 s->off = off; in http_open_cnx()
332 ffurl_closep(&s->hd); in http_open_cnx()
337 if (s->http_code == 401) { in http_open_cnx()
338 if ((cur_auth_type == HTTP_AUTH_NONE || s->auth_state.stale) && in http_open_cnx()
339 s->auth_state.auth_type != HTTP_AUTH_NONE && attempts < 4) { in http_open_cnx()
340 ffurl_closep(&s->hd); in http_open_cnx()
345 if (s->http_code == 407) { in http_open_cnx()
346 if ((cur_proxy_auth_type == HTTP_AUTH_NONE || s->proxy_auth_state.stale) && in http_open_cnx()
347 s->proxy_auth_state.auth_type != HTTP_AUTH_NONE && attempts < 4) { in http_open_cnx()
348 ffurl_closep(&s->hd); in http_open_cnx()
353 if ((s->http_code == 301 || s->http_code == 302 || in http_open_cnx()
354 s->http_code == 303 || s->http_code == 307 || s->http_code == 308) && in http_open_cnx()
357 ffurl_closep(&s->hd); in http_open_cnx()
362 memset(&s->auth_state, 0, sizeof(s->auth_state)); in http_open_cnx()
370 if (s->hd) in http_open_cnx()
371 ffurl_closep(&s->hd); in http_open_cnx()
374 return ff_http_averror(s->http_code, AVERROR(EIO)); in http_open_cnx()
379 HTTPContext *s = h->priv_data; in ff_http_get_shutdown_status()
384 read_ret = ffurl_read(s->hd, buf, sizeof(buf)); in ff_http_get_shutdown_status()
398 HTTPContext *s = h->priv_data; in ff_http_do_new_request2()
404 if (!h->prot || in ff_http_do_new_request2()
405 !(!strcmp(h->prot->name, "http") || in ff_http_do_new_request2()
406 !strcmp(h->prot->name, "https"))) in ff_http_do_new_request2()
411 NULL, 0, s->location); in ff_http_do_new_request2()
423 if (!s->end_chunked_post) { in ff_http_do_new_request2()
424 ret = http_shutdown(h, h->flags); in ff_http_do_new_request2()
429 if (s->willclose) in ff_http_do_new_request2()
432 s->end_chunked_post = 0; in ff_http_do_new_request2()
433 s->chunkend = 0; in ff_http_do_new_request2()
434 s->off = 0; in ff_http_do_new_request2()
435 s->icy_data_read = 0; in ff_http_do_new_request2()
436 av_free(s->location); in ff_http_do_new_request2()
437 s->location = av_strdup(uri); in ff_http_do_new_request2()
438 if (!s->location) in ff_http_do_new_request2()
444 …av_log(s, AV_LOG_INFO, "Opening \'%s\' for %s\n", uri, h->flags & AVIO_FLAG_WRITE ? "writing" : "r… in ff_http_do_new_request2()
471 HTTPContext *s = h->priv_data; in http_write_reply()
472 char message[BUFFER_SIZE]; in http_write_reply() local
496 content_type = s->content_type ? s->content_type : "application/octet-stream"; in http_write_reply()
507 s->chunked_post = 0; in http_write_reply()
508 message_len = snprintf(message, sizeof(message), in http_write_reply()
510 "Content-Type: %s\r\n" in http_write_reply()
511 "Content-Length: %"SIZE_SPECIFIER"\r\n" in http_write_reply()
519 s->headers ? s->headers : "", in http_write_reply()
523 s->chunked_post = 1; in http_write_reply()
524 message_len = snprintf(message, sizeof(message), in http_write_reply()
526 "Content-Type: %s\r\n" in http_write_reply()
527 "Transfer-Encoding: chunked\r\n" in http_write_reply()
533 s->headers ? s->headers : ""); in http_write_reply()
535 av_log(h, AV_LOG_TRACE, "HTTP reply header: \n%s----\n", message); in http_write_reply()
536 if ((ret = ffurl_write(s->hd, message, message_len)) < 0) in http_write_reply()
550 HTTPContext *ch = c->priv_data; in http_handshake()
551 URLContext *cl = ch->hd; in http_handshake()
552 switch (ch->handshake_step) { in http_handshake()
559 ch->handshake_step = READ_HEADERS; in http_handshake()
560 ch->is_connected_server = 1; in http_handshake()
568 ch->handshake_step = WRITE_REPLY_HEADERS; in http_handshake()
571 av_log(c, AV_LOG_TRACE, "Reply code: %d\n", ch->reply_code); in http_handshake()
572 if ((err = http_write_reply(c, ch->reply_code)) < 0) in http_handshake()
574 ch->handshake_step = FINISH; in http_handshake()
585 HTTPContext *s = h->priv_data; in http_listen()
597 if ((ret = av_dict_set_int(options, "listen", s->listen, 0)) < 0) in http_listen()
599 if ((ret = ffurl_open_whitelist(&s->hd, lower_url, AVIO_FLAG_READ_WRITE, in http_listen()
600 &h->interrupt_callback, options, in http_listen()
601 h->protocol_whitelist, h->protocol_blacklist, h in http_listen()
604 s->handshake_step = LOWER_PROTO; in http_listen()
605 if (s->listen == HTTP_SINGLE) { /* single client */ in http_listen()
606 s->reply_code = 200; in http_listen()
610 av_dict_free(&s->chained_options); in http_listen()
617 HTTPContext *s = h->priv_data; in http_open()
620 if( s->seekable == 1 ) in http_open()
621 h->is_streamed = 0; in http_open()
623 h->is_streamed = 1; in http_open()
625 s->filesize = UINT64_MAX; in http_open()
626 s->location = av_strdup(uri); in http_open()
627 if (!s->location) in http_open()
630 av_dict_copy(&s->chained_options, *options, 0); in http_open()
632 if (s->headers) { in http_open()
633 int len = strlen(s->headers); in http_open()
634 if (len < 2 || strcmp("\r\n", s->headers + len - 2)) { in http_open()
637 ret = av_reallocp(&s->headers, len + 3); in http_open()
640 s->headers[len] = '\r'; in http_open()
641 s->headers[len + 1] = '\n'; in http_open()
642 s->headers[len + 2] = '\0'; in http_open()
646 if (s->listen) { in http_open()
652 av_dict_free(&s->chained_options); in http_open()
659 HTTPContext *sc = s->priv_data; in http_accept()
661 URLContext *sl = sc->hd; in http_accept()
664 av_assert0(sc->listen); in http_accept()
665 if ((ret = ffurl_alloc(c, s->filename, s->flags, &sl->interrupt_callback)) < 0) in http_accept()
667 cc = (*c)->priv_data; in http_accept()
670 cc->hd = cl; in http_accept()
671 cc->is_multi_client = 1; in http_accept()
683 if (s->buf_ptr >= s->buf_end) { in http_getc()
684 len = ffurl_read(s->hd, s->buffer, BUFFER_SIZE); in http_getc()
690 s->buf_ptr = s->buffer; in http_getc()
691 s->buf_end = s->buffer + len; in http_getc()
694 return *s->buf_ptr++; in http_getc()
709 if (q > line && q[-1] == '\r') in http_get_line()
710 q--; in http_get_line()
715 if ((q - line) < line_size - 1) in http_get_line()
723 HTTPContext *s = h->priv_data; in check_http_code()
727 (http_code != 401 || s->auth_state.auth_type != HTTP_AUTH_NONE) && in check_http_code()
728 (http_code != 407 || s->proxy_auth_state.auth_type != HTTP_AUTH_NONE)) { in check_http_code()
740 s->location, p); in parse_location()
744 av_free(s->location); in parse_location()
745 s->location = new_loc; in parse_location()
749 /* "bytes $from-$to/$document_size" */
752 HTTPContext *s = h->priv_data; in parse_content_range()
757 s->off = strtoull(p, NULL, 10); in parse_content_range()
759 s->filesize = strtoull(slash + 1, NULL, 10); in parse_content_range()
761 if (s->seekable == -1 && (!s->is_akamai || s->filesize != 2147483647)) in parse_content_range()
762 h->is_streamed = 0; /* we _can_ in fact seek */ in parse_content_range()
770 HTTPContext *s = h->priv_data; in parse_content_encoding()
772 s->compressed = 1; in parse_content_encoding()
773 inflateEnd(&s->inflate_stream); in parse_content_encoding()
774 if (inflateInit2(&s->inflate_stream, 32 + 15) != Z_OK) { in parse_content_encoding()
776 s->inflate_stream.msg); in parse_content_encoding()
790 // The normal, no-encoding case (although servers shouldn't include in parse_content_encoding()
798 // Concat all Icy- header lines
802 int is_first = !s->icy_metadata_headers; in parse_icy()
805 av_dict_set(&s->metadata, tag, p, 0); in parse_icy()
807 if (s->icy_metadata_headers) in parse_icy()
808 len += strlen(s->icy_metadata_headers); in parse_icy()
810 if ((ret = av_reallocp(&s->icy_metadata_headers, len)) < 0) in parse_icy()
814 *s->icy_metadata_headers = '\0'; in parse_icy()
816 av_strlcatf(s->icy_metadata_headers, len, "%s: %s\n", tag, p); in parse_icy()
824 int i, j, exp_buf_len = MAX_EXPIRY-1; in parse_set_cookie_expiry_time()
858 back = &cstr[strlen(cstr)-1]; in parse_set_cookie()
863 back--; in parse_set_cookie()
874 return -1; in parse_set_cookie()
891 return -1; in parse_cookie()
895 if (!cookie_entry || !cookie_entry->value) { in parse_cookie()
897 return -1; in parse_cookie()
901 if ((e = av_dict_get(new_params, "expires", NULL, 0)) && e->value) { in parse_cookie()
903 if (!parse_set_cookie_expiry_time(e->value, &new_tm)) { in parse_cookie()
913 e2 = av_dict_get(*cookies, cookie_entry->key, NULL, 0); in parse_cookie()
914 if (e2 && e2->value) { in parse_cookie()
918 if (e2 && e2->value) { in parse_cookie()
920 if (!parse_set_cookie_expiry_time(e->value, &old_tm)) { in parse_cookie()
924 return -1; in parse_cookie()
937 if (!(name = av_strndup(p, eql - p))) return AVERROR(ENOMEM); in parse_cookie()
952 len += strlen(e->key) + strlen(e->value) + 1; in cookie_string()
963 av_strlcatf(*cookies, len, "%s%s\n", e->key, e->value); in cookie_string()
971 HTTPContext *s = h->priv_data; in process_line()
972 const char *auto_method = h->flags & AVIO_FLAG_READ ? "POST" : "GET"; in process_line()
978 s->end_header = 1; in process_line()
984 if (s->is_connected_server) { in process_line()
991 if (s->method) { in process_line()
992 if (av_strcasecmp(s->method, method)) { in process_line()
994 s->method, method); in process_line()
1005 if (!(s->method = av_strdup(method))) in process_line()
1017 if (!(s->resource = av_strdup(resource))) in process_line()
1034 s->willclose = 1; in process_line()
1039 av_freep(&s->http_version); in process_line()
1040 s->http_version = av_strndup(p, 3); in process_line()
1045 s->http_code = strtol(p, &end, 10); in process_line()
1047 av_log(h, AV_LOG_TRACE, "http_code=%d\n", s->http_code); in process_line()
1049 if ((ret = check_http_code(h, s->http_code, end)) < 0) in process_line()
1067 } else if (!av_strcasecmp(tag, "Content-Length") && in process_line()
1068 s->filesize == UINT64_MAX) { in process_line()
1069 s->filesize = strtoull(p, NULL, 10); in process_line()
1070 } else if (!av_strcasecmp(tag, "Content-Range")) { in process_line()
1072 } else if (!av_strcasecmp(tag, "Accept-Ranges") && in process_line()
1074 s->seekable == -1) { in process_line()
1075 h->is_streamed = 0; in process_line()
1076 } else if (!av_strcasecmp(tag, "Transfer-Encoding") && in process_line()
1078 s->filesize = UINT64_MAX; in process_line()
1079 s->chunksize = 0; in process_line()
1080 } else if (!av_strcasecmp(tag, "WWW-Authenticate")) { in process_line()
1081 ff_http_auth_handle_header(&s->auth_state, tag, p); in process_line()
1082 } else if (!av_strcasecmp(tag, "Authentication-Info")) { in process_line()
1083 ff_http_auth_handle_header(&s->auth_state, tag, p); in process_line()
1084 } else if (!av_strcasecmp(tag, "Proxy-Authenticate")) { in process_line()
1085 ff_http_auth_handle_header(&s->proxy_auth_state, tag, p); in process_line()
1088 s->willclose = 1; in process_line()
1091 s->is_akamai = 1; in process_line()
1093 s->is_mediagateway = 1; in process_line()
1095 } else if (!av_strcasecmp(tag, "Content-Type")) { in process_line()
1096 av_free(s->mime_type); in process_line()
1097 s->mime_type = av_strdup(p); in process_line()
1098 } else if (!av_strcasecmp(tag, "Set-Cookie")) { in process_line()
1099 if (parse_cookie(s, p, &s->cookie_dict)) in process_line()
1101 } else if (!av_strcasecmp(tag, "Icy-MetaInt")) { in process_line()
1102 s->icy_metaint = strtoull(p, NULL, 10); in process_line()
1103 } else if (!av_strncasecmp(tag, "Icy-", 4)) { in process_line()
1106 } else if (!av_strcasecmp(tag, "Content-Encoding")) { in process_line()
1125 // cookie strings will look like Set-Cookie header field values. Multiple in get_cookies()
1126 // Set-Cookie fields will result in multiple values delimited by a newline in get_cookies()
1132 av_dict_free(&s->cookie_dict); in get_cookies()
1134 if (!s->cookies) in get_cookies()
1137 next = set_cookies = av_strdup(s->cookies); in get_cookies()
1148 if (parse_cookie(s, cookie, &s->cookie_dict)) in get_cookies()
1157 if (!cookie_entry || !cookie_entry->value) in get_cookies()
1161 if ((e = av_dict_get(cookie_params, "expires", NULL, 0)) && e->value) { in get_cookies()
1163 if (!parse_set_cookie_expiry_time(e->value, &tm_buf)) { in get_cookies()
1170 if ((e = av_dict_get(cookie_params, "domain", NULL, 0)) && e->value) { in get_cookies()
1172 int domain_offset = strlen(domain) - strlen(e->value); in get_cookies()
1177 if (av_strcasecmp(&domain[domain_offset], e->value)) in get_cookies()
1183 if (!e || av_strncasecmp(path, e->value, strlen(e->value))) in get_cookies()
1188 *cookies = av_asprintf("%s=%s", cookie_entry->key, cookie_entry->value); in get_cookies()
1191 *cookies = av_asprintf("%s; %s=%s", tmp, cookie_entry->key, cookie_entry->value); in get_cookies()
1216 HTTPContext *s = h->priv_data; in http_read_header()
1220 s->chunksize = UINT64_MAX; in http_read_header()
1228 err = process_line(h, line, s->line_count, new_location); in http_read_header()
1233 s->line_count++; in http_read_header()
1236 if (s->seekable == -1 && s->is_mediagateway && s->filesize == 2000000000) in http_read_header()
1237 h->is_streamed = 1; /* we can in fact _not_ seek */ in http_read_header()
1240 cookie_string(s->cookie_dict, &s->cookies); in http_read_header()
1241 av_dict_free(&s->cookie_dict); in http_read_header()
1249 * - escape "%" characters not followed by two hex digits
1250 * - escape all "unsafe" characters except which are also "reserved"
1251 * - pass through everything else
1262 while (*path && q - buf < sizeof(buf) - 4) { in bprint_escaped_path()
1273 av_bprint_append_data(bp, buf, q - buf); in bprint_escaped_path()
1281 HTTPContext *s = h->priv_data; in http_connect()
1285 uint64_t off = s->off; in http_connect()
1289 av_bprint_init_for_buffer(&request, s->buffer, sizeof(s->buffer)); in http_connect()
1292 post = h->flags & AVIO_FLAG_WRITE; in http_connect()
1294 if (s->post_data) { in http_connect()
1298 s->chunked_post = 0; in http_connect()
1301 if (s->method) in http_connect()
1302 method = s->method; in http_connect()
1306 authstr = ff_http_auth_create_response(&s->auth_state, auth, in http_connect()
1308 proxyauthstr = ff_http_auth_create_response(&s->proxy_auth_state, proxyauth, in http_connect()
1311 if (post && !s->post_data) { in http_connect()
1312 if (s->send_expect_100 != -1) { in http_connect()
1313 send_expect_100 = s->send_expect_100; in http_connect()
1317 * send Expect: 100-continue to get the 401 response including the in http_connect()
1318 * WWW-Authenticate header, or an 100 continue if no auth actually in http_connect()
1321 s->auth_state.auth_type == HTTP_AUTH_NONE && in http_connect()
1322 s->http_code != 401) in http_connect()
1331 if (post && s->chunked_post) in http_connect()
1332 av_bprintf(&request, "Transfer-Encoding: chunked\r\n"); in http_connect()
1334 if (!has_header(s->headers, "\r\nUser-Agent: ")) in http_connect()
1335 av_bprintf(&request, "User-Agent: %s\r\n", s->user_agent); in http_connect()
1336 if (s->referer) { in http_connect()
1338 if (!has_header(s->headers, "\r\nReferer: ")) in http_connect()
1339 av_bprintf(&request, "Referer: %s\r\n", s->referer); in http_connect()
1341 if (!has_header(s->headers, "\r\nAccept: ")) in http_connect()
1343 // Note: we send this on purpose even when s->off is 0 when we're probing, in http_connect()
1344 // since it allows us to detect more reliably if a (non-conforming) in http_connect()
1346 …if (!has_header(s->headers, "\r\nRange: ") && !post && (s->off > 0 || s->end_off || s->seekable ==… in http_connect()
1347 av_bprintf(&request, "Range: bytes=%"PRIu64"-", s->off); in http_connect()
1348 if (s->end_off) in http_connect()
1349 av_bprintf(&request, "%"PRId64, s->end_off - 1); in http_connect()
1352 if (send_expect_100 && !has_header(s->headers, "\r\nExpect: ")) in http_connect()
1353 av_bprintf(&request, "Expect: 100-continue\r\n"); in http_connect()
1355 if (!has_header(s->headers, "\r\nConnection: ")) in http_connect()
1356 av_bprintf(&request, "Connection: %s\r\n", s->multiple_requests ? "keep-alive" : "close"); in http_connect()
1358 if (!has_header(s->headers, "\r\nHost: ")) in http_connect()
1360 if (!has_header(s->headers, "\r\nContent-Length: ") && s->post_data) in http_connect()
1361 av_bprintf(&request, "Content-Length: %d\r\n", s->post_datalen); in http_connect()
1363 if (!has_header(s->headers, "\r\nContent-Type: ") && s->content_type) in http_connect()
1364 av_bprintf(&request, "Content-Type: %s\r\n", s->content_type); in http_connect()
1365 if (!has_header(s->headers, "\r\nCookie: ") && s->cookies) { in http_connect()
1372 if (!has_header(s->headers, "\r\nIcy-MetaData: ") && s->icy) in http_connect()
1373 av_bprintf(&request, "Icy-MetaData: 1\r\n"); in http_connect()
1376 if (s->headers) in http_connect()
1377 av_bprintf(&request, "%s", s->headers); in http_connect()
1382 av_bprintf(&request, "Proxy-%s", proxyauthstr); in http_connect()
1393 if ((err = ffurl_write(s->hd, request.str, request.len)) < 0) in http_connect()
1396 if (s->post_data) in http_connect()
1397 if ((err = ffurl_write(s->hd, s->post_data, s->post_datalen)) < 0) in http_connect()
1401 s->buf_ptr = s->buffer; in http_connect()
1402 s->buf_end = s->buffer; in http_connect()
1403 s->line_count = 0; in http_connect()
1404 s->off = 0; in http_connect()
1405 s->icy_data_read = 0; in http_connect()
1406 s->filesize = UINT64_MAX; in http_connect()
1407 s->willclose = 0; in http_connect()
1408 s->end_chunked_post = 0; in http_connect()
1409 s->end_header = 0; in http_connect()
1411 s->compressed = 0; in http_connect()
1413 if (post && !s->post_data && !send_expect_100) { in http_connect()
1417 s->http_code = 200; in http_connect()
1428 s->off = off; in http_connect()
1430 err = (off == s->off) ? 0 : -1; in http_connect()
1439 HTTPContext *s = h->priv_data; in http_buf_read()
1442 if (s->chunksize != UINT64_MAX) { in http_buf_read()
1443 if (s->chunkend) { in http_buf_read()
1446 if (!s->chunksize) { in http_buf_read()
1455 s->chunksize = strtoull(line, NULL, 16); in http_buf_read()
1459 s->chunksize); in http_buf_read()
1461 if (!s->chunksize && s->multiple_requests) { in http_buf_read()
1463 s->chunkend = 1; in http_buf_read()
1466 else if (!s->chunksize) { in http_buf_read()
1468 ffurl_closep(&s->hd); in http_buf_read()
1471 else if (s->chunksize == UINT64_MAX) { in http_buf_read()
1473 s->chunksize); in http_buf_read()
1477 size = FFMIN(size, s->chunksize); in http_buf_read()
1481 len = s->buf_end - s->buf_ptr; in http_buf_read()
1485 memcpy(buf, s->buf_ptr, len); in http_buf_read()
1486 s->buf_ptr += len; in http_buf_read()
1488 uint64_t target_end = s->end_off ? s->end_off : s->filesize; in http_buf_read()
1489 if ((!s->willclose || s->chunksize == UINT64_MAX) && s->off >= target_end) in http_buf_read()
1491 len = ffurl_read(s->hd, buf, size); in http_buf_read()
1493 (!s->willclose || s->chunksize == UINT64_MAX) && s->off < target_end) { in http_buf_read()
1496 s->off, target_end in http_buf_read()
1502 s->off += len; in http_buf_read()
1503 if (s->chunksize > 0 && s->chunksize != UINT64_MAX) { in http_buf_read()
1504 av_assert0(s->chunksize >= len); in http_buf_read()
1505 s->chunksize -= len; in http_buf_read()
1515 HTTPContext *s = h->priv_data; in http_buf_read_compressed()
1518 if (!s->inflate_buffer) { in http_buf_read_compressed()
1519 s->inflate_buffer = av_malloc(DECOMPRESS_BUF_SIZE); in http_buf_read_compressed()
1520 if (!s->inflate_buffer) in http_buf_read_compressed()
1524 if (s->inflate_stream.avail_in == 0) { in http_buf_read_compressed()
1525 int read = http_buf_read(h, s->inflate_buffer, DECOMPRESS_BUF_SIZE); in http_buf_read_compressed()
1528 s->inflate_stream.next_in = s->inflate_buffer; in http_buf_read_compressed()
1529 s->inflate_stream.avail_in = read; in http_buf_read_compressed()
1532 s->inflate_stream.avail_out = size; in http_buf_read_compressed()
1533 s->inflate_stream.next_out = buf; in http_buf_read_compressed()
1535 ret = inflate(&s->inflate_stream, Z_SYNC_FLUSH); in http_buf_read_compressed()
1538 ret, s->inflate_stream.msg); in http_buf_read_compressed()
1540 return size - s->inflate_stream.avail_out; in http_buf_read_compressed()
1548 HTTPContext *s = h->priv_data; in http_read_stream()
1553 if (!s->hd) in http_read_stream()
1556 if (s->end_chunked_post && !s->end_header) { in http_read_stream()
1563 if (s->compressed) in http_read_stream()
1568 uint64_t target = h->is_streamed ? 0 : s->off; in http_read_stream()
1573 if (h->is_streamed && !s->reconnect_streamed) in http_read_stream()
1576 if (!(s->reconnect && s->filesize > 0 && s->off < s->filesize) && in http_read_stream()
1577 !(s->reconnect_at_eof && read_ret == AVERROR_EOF)) in http_read_stream()
1580 if (reconnect_delay > s->reconnect_delay_max) in http_read_stream()
1583 …av_log(h, AV_LOG_WARNING, "Will reconnect at %"PRIu64" in %d second(s), error=%s.\n", s->off, reco… in http_read_stream()
1584 err = ff_network_sleep_interruptible(1000U*1000*reconnect_delay, &h->interrupt_callback); in http_read_stream()
1606 int len = http_read_stream(h, buf + pos, size - pos); in http_read_stream_all()
1620 HTTPContext *s = h->priv_data; in update_metadata()
1635 av_dict_set(&s->metadata, key, val, 0); in update_metadata()
1644 HTTPContext *s = h->priv_data; in store_icy()
1648 if (s->icy_metaint < s->icy_data_read) in store_icy()
1650 remaining = s->icy_metaint - s->icy_data_read; in store_icy()
1673 s->icy_data_read = 0; in store_icy()
1674 remaining = s->icy_metaint; in store_icy()
1682 HTTPContext *s = h->priv_data; in http_read()
1684 if (s->icy_metaint > 0) { in http_read()
1692 s->icy_data_read += size; in http_read()
1699 char temp[11] = ""; /* 32-bit hex + CRLF + nul */ in http_write()
1702 HTTPContext *s = h->priv_data; in http_write()
1704 if (!s->chunked_post) { in http_write()
1705 /* non-chunked data is sent without any special encoding */ in http_write()
1706 return ffurl_write(s->hd, buf, size); in http_write()
1709 /* silently ignore zero-size data since chunk encoding that would in http_write()
1715 if ((ret = ffurl_write(s->hd, temp, strlen(temp))) < 0 || in http_write()
1716 (ret = ffurl_write(s->hd, buf, size)) < 0 || in http_write()
1717 (ret = ffurl_write(s->hd, crlf, sizeof(crlf) - 1)) < 0) in http_write()
1727 HTTPContext *s = h->priv_data; in http_shutdown()
1730 if (((flags & AVIO_FLAG_WRITE) && s->chunked_post) || in http_shutdown()
1731 ((flags & AVIO_FLAG_READ) && s->chunked_post && s->listen)) { in http_shutdown()
1732 ret = ffurl_write(s->hd, footer, sizeof(footer) - 1); in http_shutdown()
1738 s->hd->flags |= AVIO_FLAG_NONBLOCK; in http_shutdown()
1739 read_ret = ffurl_read(s->hd, buf, sizeof(buf)); in http_shutdown()
1740 s->hd->flags &= ~AVIO_FLAG_NONBLOCK; in http_shutdown()
1746 s->end_chunked_post = 1; in http_shutdown()
1755 HTTPContext *s = h->priv_data; in http_close()
1758 inflateEnd(&s->inflate_stream); in http_close()
1759 av_freep(&s->inflate_buffer); in http_close()
1762 if (s->hd && !s->end_chunked_post) in http_close()
1764 ret = http_shutdown(h, h->flags); in http_close()
1766 if (s->hd) in http_close()
1767 ffurl_closep(&s->hd); in http_close()
1768 av_dict_free(&s->chained_options); in http_close()
1774 HTTPContext *s = h->priv_data; in http_seek_internal()
1775 URLContext *old_hd = s->hd; in http_seek_internal()
1776 uint64_t old_off = s->off; in http_seek_internal()
1782 return s->filesize; in http_seek_internal()
1785 (whence == SEEK_SET && off == s->off))) in http_seek_internal()
1786 return s->off; in http_seek_internal()
1787 else if ((s->filesize == UINT64_MAX && whence == SEEK_END)) in http_seek_internal()
1791 off += s->off; in http_seek_internal()
1793 off += s->filesize; in http_seek_internal()
1798 s->off = off; in http_seek_internal()
1800 if (s->off && h->is_streamed) in http_seek_internal()
1804 if (s->end_off || s->filesize != UINT64_MAX) { in http_seek_internal()
1805 uint64_t end_pos = s->end_off ? s->end_off : s->filesize; in http_seek_internal()
1806 if (s->off >= end_pos) in http_seek_internal()
1807 return s->off; in http_seek_internal()
1811 old_buf_size = s->buf_end - s->buf_ptr; in http_seek_internal()
1812 memcpy(old_buf, s->buf_ptr, old_buf_size); in http_seek_internal()
1813 s->hd = NULL; in http_seek_internal()
1818 memcpy(s->buffer, old_buf, old_buf_size); in http_seek_internal()
1819 s->buf_ptr = s->buffer; in http_seek_internal()
1820 s->buf_end = s->buffer + old_buf_size; in http_seek_internal()
1821 s->hd = old_hd; in http_seek_internal()
1822 s->off = old_off; in http_seek_internal()
1837 HTTPContext *s = h->priv_data; in http_get_file_handle()
1838 return ffurl_get_file_handle(s->hd); in http_get_file_handle()
1843 HTTPContext *s = h->priv_data; in http_get_short_seek()
1844 return ffurl_get_short_seek(s->hd); in http_get_short_seek()
1900 HTTPContext *s = h->priv_data; in http_proxy_close()
1901 if (s->hd) in http_proxy_close()
1902 ffurl_closep(&s->hd); in http_proxy_close()
1908 HTTPContext *s = h->priv_data; in http_proxy_open()
1917 if( s->seekable == 1 ) in http_proxy_open()
1918 h->is_streamed = 0; in http_proxy_open()
1920 h->is_streamed = 1; in http_proxy_open()
1932 ret = ffurl_open_whitelist(&s->hd, lower_url, AVIO_FLAG_READ_WRITE, in http_proxy_open()
1933 &h->interrupt_callback, NULL, in http_proxy_open()
1934 h->protocol_whitelist, h->protocol_blacklist, h); in http_proxy_open()
1938 authstr = ff_http_auth_create_response(&s->proxy_auth_state, auth, in http_proxy_open()
1940 snprintf(s->buffer, sizeof(s->buffer), in http_proxy_open()
1948 authstr ? "Proxy-" : "", authstr ? authstr : ""); in http_proxy_open()
1951 if ((ret = ffurl_write(s->hd, s->buffer, strlen(s->buffer))) < 0) in http_proxy_open()
1954 s->buf_ptr = s->buffer; in http_proxy_open()
1955 s->buf_end = s->buffer; in http_proxy_open()
1956 s->line_count = 0; in http_proxy_open()
1957 s->filesize = UINT64_MAX; in http_proxy_open()
1958 cur_auth_type = s->proxy_auth_state.auth_type; in http_proxy_open()
1965 * protocol does). This shouldn't be an issue for tls though, in http_proxy_open()
1974 if (s->http_code == 407 && in http_proxy_open()
1975 (cur_auth_type == HTTP_AUTH_NONE || s->proxy_auth_state.stale) && in http_proxy_open()
1976 s->proxy_auth_state.auth_type != HTTP_AUTH_NONE && attempts < 2) { in http_proxy_open()
1977 ffurl_closep(&s->hd); in http_proxy_open()
1981 if (s->http_code < 400) in http_proxy_open()
1983 ret = ff_http_averror(s->http_code, AVERROR(EIO)); in http_proxy_open()
1992 HTTPContext *s = h->priv_data; in http_proxy_write()
1993 return ffurl_write(s->hd, buf, size); in http_proxy_write()