mirror of
https://github.com/xenia-project/FFmpeg.git
synced 2024-11-25 04:30:02 +00:00
lavf/http: use a more compatible default user agent.
Fixes Ticket 2265.
This commit is contained in:
parent
28943c4d31
commit
1fabd95035
@ -71,12 +71,13 @@ typedef struct {
|
|||||||
#define D AV_OPT_FLAG_DECODING_PARAM
|
#define D AV_OPT_FLAG_DECODING_PARAM
|
||||||
#define E AV_OPT_FLAG_ENCODING_PARAM
|
#define E AV_OPT_FLAG_ENCODING_PARAM
|
||||||
#define DEC AV_OPT_FLAG_DECODING_PARAM
|
#define DEC AV_OPT_FLAG_DECODING_PARAM
|
||||||
|
#define DEFAULT_USER_AGENT "Mozilla/5.0 Lavf/" AV_STRINGIFY(LIBAVFORMAT_VERSION)
|
||||||
static const AVOption options[] = {
|
static const AVOption options[] = {
|
||||||
{"seekable", "control seekability of connection", OFFSET(seekable), AV_OPT_TYPE_INT, {.i64 = -1}, -1, 1, D },
|
{"seekable", "control seekability of connection", OFFSET(seekable), AV_OPT_TYPE_INT, {.i64 = -1}, -1, 1, D },
|
||||||
{"chunked_post", "use chunked transfer-encoding for posts", OFFSET(chunked_post), AV_OPT_TYPE_INT, {.i64 = 1}, 0, 1, E },
|
{"chunked_post", "use chunked transfer-encoding for posts", OFFSET(chunked_post), AV_OPT_TYPE_INT, {.i64 = 1}, 0, 1, E },
|
||||||
{"headers", "set custom HTTP headers, can override built in default headers", OFFSET(headers), AV_OPT_TYPE_STRING, { 0 }, 0, 0, D|E },
|
{"headers", "set custom HTTP headers, can override built in default headers", OFFSET(headers), AV_OPT_TYPE_STRING, { 0 }, 0, 0, D|E },
|
||||||
{"content_type", "force a content type", OFFSET(content_type), AV_OPT_TYPE_STRING, { 0 }, 0, 0, D|E },
|
{"content_type", "force a content type", OFFSET(content_type), AV_OPT_TYPE_STRING, { 0 }, 0, 0, D|E },
|
||||||
{"user-agent", "override User-Agent header", OFFSET(user_agent), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, DEC},
|
{"user-agent", "override User-Agent header", OFFSET(user_agent), AV_OPT_TYPE_STRING, {.str = DEFAULT_USER_AGENT}, 0, 0, DEC},
|
||||||
{"multiple_requests", "use persistent connections", OFFSET(multiple_requests), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 1, D|E },
|
{"multiple_requests", "use persistent connections", OFFSET(multiple_requests), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 1, D|E },
|
||||||
{"post_data", "set custom HTTP post data", OFFSET(post_data), AV_OPT_TYPE_BINARY, .flags = D|E },
|
{"post_data", "set custom HTTP post data", OFFSET(post_data), AV_OPT_TYPE_BINARY, .flags = D|E },
|
||||||
{"timeout", "set timeout of socket I/O operations", OFFSET(rw_timeout), AV_OPT_TYPE_INT, {.i64 = -1}, -1, INT_MAX, D|E },
|
{"timeout", "set timeout of socket I/O operations", OFFSET(rw_timeout), AV_OPT_TYPE_INT, {.i64 = -1}, -1, INT_MAX, D|E },
|
||||||
@ -540,8 +541,7 @@ static int http_connect(URLContext *h, const char *path, const char *local_path,
|
|||||||
/* set default headers if needed */
|
/* set default headers if needed */
|
||||||
if (!has_header(s->headers, "\r\nUser-Agent: "))
|
if (!has_header(s->headers, "\r\nUser-Agent: "))
|
||||||
len += av_strlcatf(headers + len, sizeof(headers) - len,
|
len += av_strlcatf(headers + len, sizeof(headers) - len,
|
||||||
"User-Agent: %s\r\n",
|
"User-Agent: %s\r\n", s->user_agent);
|
||||||
s->user_agent ? s->user_agent : LIBAVFORMAT_IDENT);
|
|
||||||
if (!has_header(s->headers, "\r\nAccept: "))
|
if (!has_header(s->headers, "\r\nAccept: "))
|
||||||
len += av_strlcpy(headers + len, "Accept: */*\r\n",
|
len += av_strlcpy(headers + len, "Accept: */*\r\n",
|
||||||
sizeof(headers) - len);
|
sizeof(headers) - len);
|
||||||
|
Loading…
Reference in New Issue
Block a user