You've already forked FFmpeg
mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-08-15 14:13:16 +02:00
http: add -content_type user option.
This commit is contained in:
committed by
Clément Bœsch
parent
6ddb03caf0
commit
c01d1d4ddf
@@ -46,6 +46,7 @@ typedef struct {
|
|||||||
int line_count;
|
int line_count;
|
||||||
int http_code;
|
int http_code;
|
||||||
int64_t chunksize; /**< Used if "Transfer-Encoding: chunked" otherwise -1. */
|
int64_t chunksize; /**< Used if "Transfer-Encoding: chunked" otherwise -1. */
|
||||||
|
char *content_type;
|
||||||
char *user_agent;
|
char *user_agent;
|
||||||
int64_t off, filesize;
|
int64_t off, filesize;
|
||||||
char location[MAX_URL_SIZE];
|
char location[MAX_URL_SIZE];
|
||||||
@@ -72,6 +73,7 @@ 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", "custom HTTP headers, can override built in default headers", OFFSET(headers), AV_OPT_TYPE_STRING, { 0 }, 0, 0, D|E },
|
{"headers", "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 },
|
||||||
{"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 = NULL}, 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", "custom HTTP post data", OFFSET(post_data), AV_OPT_TYPE_BINARY, .flags = D|E },
|
{"post_data", "custom HTTP post data", OFFSET(post_data), AV_OPT_TYPE_BINARY, .flags = D|E },
|
||||||
@@ -451,6 +453,9 @@ static int http_connect(URLContext *h, const char *path, const char *local_path,
|
|||||||
if (!has_header(s->headers, "\r\nContent-Length: ") && s->post_data)
|
if (!has_header(s->headers, "\r\nContent-Length: ") && s->post_data)
|
||||||
len += av_strlcatf(headers + len, sizeof(headers) - len,
|
len += av_strlcatf(headers + len, sizeof(headers) - len,
|
||||||
"Content-Length: %d\r\n", s->post_datalen);
|
"Content-Length: %d\r\n", s->post_datalen);
|
||||||
|
if (!has_header(s->headers, "\r\nContent-Type: ") && s->content_type)
|
||||||
|
len += av_strlcatf(headers + len, sizeof(headers) - len,
|
||||||
|
"Content-Type: %s\r\n", s->content_type);
|
||||||
|
|
||||||
/* now add in custom headers */
|
/* now add in custom headers */
|
||||||
if (s->headers)
|
if (s->headers)
|
||||||
|
Reference in New Issue
Block a user