aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorClément Bœsch <u@pkh.me>2014-03-06 18:40:03 +0100
committerLuca Barbato <lu_zero@gentoo.org>2014-03-11 22:08:57 +0100
commit2572d07c1f0abd9e2bf3ed20dbe35c58f1dd6ac4 (patch)
treee7fd5bf27cec827dc8ba69767a2671bb5b420bf7
parentfe568b3d27ca2c5cca3878b2a7a3a968e605aec4 (diff)
downloadffmpeg-2572d07c1f0abd9e2bf3ed20dbe35c58f1dd6ac4.tar.gz
http: Allow setting a Content-Type for POST requests
Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
-rw-r--r--doc/protocols.texi3
-rw-r--r--libavformat/http.c6
2 files changed, 9 insertions, 0 deletions
diff --git a/doc/protocols.texi b/doc/protocols.texi
index 597693af29..1501dab60c 100644
--- a/doc/protocols.texi
+++ b/doc/protocols.texi
@@ -95,6 +95,9 @@ This protocol accepts the following options:
@item chunked_post
If set to 1 use chunked Transfer-Encoding for posts, default is 1.
+@item content_type
+Set a specific content type for the POST messages.
+
@item headers
Set custom HTTP headers, can override built in default headers. The
value must be a string encoding the headers.
diff --git a/libavformat/http.c b/libavformat/http.c
index 05151eb3d0..f7d5c8925b 100644
--- a/libavformat/http.c
+++ b/libavformat/http.c
@@ -58,6 +58,7 @@ typedef struct {
char *headers;
char *mime_type;
char *user_agent;
+ char *content_type;
/* Set if the server correctly handles Connection: close and will close
* the connection after feeding us the content. */
int willclose;
@@ -93,6 +94,7 @@ typedef struct {
static const AVOption options[] = {
{"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 },
+{"content_type", "set a specific content type for the POST messages", 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 = DEFAULT_USER_AGENT}, 0, 0, D },
{"user-agent", "override User-Agent header, for compatibility with ffmpeg", OFFSET(user_agent), AV_OPT_TYPE_STRING, {.str = DEFAULT_USER_AGENT}, 0, 0, D },
{"multiple_requests", "use persistent connections", OFFSET(multiple_requests), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 1, D|E },
@@ -605,6 +607,10 @@ static int http_connect(URLContext *h, const char *path, const char *local_path,
if (!has_header(s->headers, "\r\nContent-Length: ") && s->post_data)
len += av_strlcatf(headers + len, sizeof(headers) - len,
"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);
if (!has_header(s->headers, "\r\nIcy-MetaData: ") && s->icy) {
len += av_strlcatf(headers + len, sizeof(headers) - len,
"Icy-MetaData: %d\r\n", 1);