]> git.sesse.net Git - ffmpeg/commitdiff
lavf/http: deprecate user-agent option
authorSteven Liu <lingjiujianke@gmail.com>
Fri, 16 Sep 2016 02:42:34 +0000 (10:42 +0800)
committerClément Bœsch <u@pkh.me>
Sat, 17 Sep 2016 11:48:34 +0000 (13:48 +0200)
doc/protocols.texi
libavformat/http.c
libavformat/version.h

index 470c99ceb421d818bbb0e869e5275da0902499cb..3abc5f38d4d0ea5b97af84934e493827f6d866f5 100644 (file)
@@ -291,11 +291,13 @@ Use persistent connections if set to 1, default is 0.
 @item post_data
 Set custom HTTP post data.
 
-@item user-agent
 @item user_agent
 Override the User-Agent header. If not specified the protocol will use a
 string describing the libavformat build. ("Lavf/<version>")
 
+@item user-agent
+This is a deprecated option, you can use user_agent instead it.
+
 @item timeout
 Set timeout in microseconds of socket I/O operations used by the underlying low level
 operation. By default it is set to -1, which means that the timeout is
index adb3d92e2125d278cd7cee90d5797a4bab9f487f..5f6b9dea4270b5d197915ec8c6e4eb6492bb5d25 100644 (file)
@@ -71,6 +71,9 @@ typedef struct HTTPContext {
     char *headers;
     char *mime_type;
     char *user_agent;
+#ifdef FF_API_HTTP_USER_AGENT
+    char *user_agent_deprecated;
+#endif
     char *content_type;
     /* Set if the server correctly handles Connection: close and will close
      * the connection after feeding us the content. */
@@ -131,7 +134,9 @@ 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 },
-    { "user-agent", "override User-Agent header", OFFSET(user_agent), AV_OPT_TYPE_STRING, { .str = DEFAULT_USER_AGENT }, 0, 0, D },
+#ifdef 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
     { "multiple_requests", "use persistent connections", OFFSET(multiple_requests), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, D | E },
     { "post_data", "set custom HTTP post data", OFFSET(post_data), AV_OPT_TYPE_BINARY, .flags = D | E },
     { "mime_type", "export the MIME type", OFFSET(mime_type), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, AV_OPT_FLAG_EXPORT | AV_OPT_FLAG_READONLY },
@@ -1037,6 +1042,12 @@ static int http_connect(URLContext *h, const char *path, const char *local_path,
             send_expect_100 = 1;
     }
 
+#ifdef FF_API_HTTP_USER_AGENT
+    if (strcmp(s->user_agent_deprecated, DEFAULT_USER_AGENT)) {
+        av_log(s, AV_LOG_WARNING, "the user-agent option is deprecated, please use user_agent option\n");
+        s->user_agent = av_strdup(s->user_agent_deprecated);
+    }
+#endif
     /* set default headers if needed */
     if (!has_header(s->headers, "\r\nUser-Agent: "))
         len += av_strlcatf(headers + len, sizeof(headers) - len,
index 34226cae2061c52e6c21fd6f627ee52470073a4a..a9a4d590e30833c935ae5a09a63c2c4066ffc358 100644 (file)
@@ -82,6 +82,9 @@
 #ifndef FF_API_NOCONST_GET_SIDE_DATA
 #define FF_API_NOCONST_GET_SIDE_DATA    (LIBAVFORMAT_VERSION_MAJOR < 58)
 #endif
+#ifndef FF_API_HTTP_USER_AGENT
+#define FF_API_HTTP_USER_AGENT          (LIBAVFORMAT_VERSION_MAJOR < 58)
+#endif
 
 #ifndef FF_API_R_FRAME_RATE
 #define FF_API_R_FRAME_RATE            1