diff options
author | Steven Liu <lq@chinaffmpeg.org> | 2018-02-01 05:56:51 +0300 |
---|---|---|
committer | Steven Liu <lq@chinaffmpeg.org> | 2018-02-01 05:56:51 +0300 |
commit | 44f343067455e09ce4da16b2169e89d9c062dbca (patch) | |
tree | 906e67a0e99f40a1ab2255ee93969e2233d57ea4 /libavformat | |
parent | 27fe8930e0b9e7881e61eb9ed0b8b526f718abfe (diff) |
avformat/http: add referer option into http
add Referer message if referer have been set.
Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
Diffstat (limited to 'libavformat')
-rw-r--r-- | libavformat/http.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/libavformat/http.c b/libavformat/http.c index aa80e314df..344fd603cb 100644 --- a/libavformat/http.c +++ b/libavformat/http.c @@ -76,6 +76,7 @@ typedef struct HTTPContext { char *mime_type; char *http_version; char *user_agent; + char *referer; #if FF_API_HTTP_USER_AGENT char *user_agent_deprecated; #endif @@ -138,6 +139,7 @@ static const AVOption options[] = { { "headers", "set custom HTTP headers, can override built in default headers", OFFSET(headers), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, D | E }, { "content_type", "set a specific content type for the POST messages", OFFSET(content_type), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, D | E }, { "user_agent", "override User-Agent header", OFFSET(user_agent), AV_OPT_TYPE_STRING, { .str = DEFAULT_USER_AGENT }, 0, 0, D }, + { "referer", "override referer header", OFFSET(referer), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, D }, #if FF_API_HTTP_USER_AGENT { "user-agent", "override User-Agent header", OFFSET(user_agent_deprecated), AV_OPT_TYPE_STRING, { .str = DEFAULT_USER_AGENT }, 0, 0, D }, #endif @@ -1198,6 +1200,12 @@ static int http_connect(URLContext *h, const char *path, const char *local_path, if (!has_header(s->headers, "\r\nUser-Agent: ")) len += av_strlcatf(headers + len, sizeof(headers) - len, "User-Agent: %s\r\n", s->user_agent); + if (s->referer) { + /* set default headers if needed */ + if (!has_header(s->headers, "\r\nReferer: ")) + len += av_strlcatf(headers + len, sizeof(headers) - len, + "Referer: %s\r\n", s->referer); + } if (!has_header(s->headers, "\r\nAccept: ")) len += av_strlcpy(headers + len, "Accept: */*\r\n", sizeof(headers) - len); |