From patchwork Thu Sep 15 16:41:41 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Steven Liu X-Patchwork-Id: 588 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.140.134 with SMTP id o128csp3284802vsd; Thu, 15 Sep 2016 09:41:54 -0700 (PDT) X-Received: by 10.194.26.69 with SMTP id j5mr1248994wjg.209.1473957714376; Thu, 15 Sep 2016 09:41:54 -0700 (PDT) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id q7si4939774wjp.170.2016.09.15.09.41.53; Thu, 15 Sep 2016 09:41:54 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 2264568A0E7; Thu, 15 Sep 2016 19:41:38 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-qk0-f177.google.com (mail-qk0-f177.google.com [209.85.220.177]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 80A86689D7A for ; Thu, 15 Sep 2016 19:41:31 +0300 (EEST) Received: by mail-qk0-f177.google.com with SMTP id w204so60528907qka.0 for ; Thu, 15 Sep 2016 09:41:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to; bh=NOVIR7M1DvTIO6wOEXgRxVFl/8stRBh3UTWzSrcdKKw=; b=I/4S5Is/epajGhXV3NcGLQuIkgAa8ToK1P+mXGQvDg1wDgZD9EU+9oo/jGC/q39PQr kzL+t/D5jbtGXOUzU3g4k2LtG6wzlOJI73iFkz9aL8VlxlKaNoZRAtOIzBbuQemWsB26 fnxde3FVgaPRQefeosTLvdy0dYja2IYXzsrRZ25j8YKBT3rL/JXKyXxWQWf4sEZIcd0I MpmQyLsTWLVnolvWrdRtfXixBxCXQcGmQ4S/bjC6wP4vvN7WEADbO7n7ylncUg+eN23j RzUFOWDr83pBfQSLxyymFJgLevy3sq0q03pVJ2jvp9Qq9phASbATuS+K0meYg1S3CnX4 bgDQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to; bh=NOVIR7M1DvTIO6wOEXgRxVFl/8stRBh3UTWzSrcdKKw=; b=Y3IVwadLcmIiZojEAfEFnSSQA1KlfGBjdKiFyeDV/Ngd6H0sW+Y0tDRn7dyKEAkMeX YY7N8AQwDko91dYT2ALEUmpdCVN+dEngmv2ETdYy9kL8MSjmUKuiqEMPI8YU1z27VuHr GVcIgoEWWMHyvqsBCCng7MixiD2vkkRjlEfBQixUgRU8eou7EOFMG8vVXvkGUgviTZYB PaX85yNRwE5+ni6zKHgKsMukNjuODmkxxBKDv+R/REPNaFtDs01/5O6R8H4sUT7aM4re gWkS819T0sKT2LOO3uFK/cNi9dxzZleg3Wfos5w8KMh2XGWPqJe8pdDmhUZCVS3vczs9 ojcw== X-Gm-Message-State: AE9vXwO0uDn6AalK/u9UHoHvVyDQXXQI8jT4GQI0+v1kUIa0BM1itfiVbYcceaZ6js5bno+coQdeIKqCB6mfDA== X-Received: by 10.55.23.193 with SMTP id 62mr11037143qkx.218.1473957703066; Thu, 15 Sep 2016 09:41:43 -0700 (PDT) MIME-Version: 1.0 Received: by 10.237.56.42 with HTTP; Thu, 15 Sep 2016 09:41:41 -0700 (PDT) In-Reply-To: References: <20160915144018.GN31483@kimiko.pkh.me> <20160915153734.GO31483@kimiko.pkh.me> <20160915153925.GA4171086@phare.normalesup.org> <20160915154218.GP31483@kimiko.pkh.me> <20160915162134.GQ31483@kimiko.pkh.me> From: Steven Liu Date: Fri, 16 Sep 2016 00:41:41 +0800 Message-ID: To: FFmpeg development discussions and patches X-Content-Filtered-By: Mailman/MimeDel 2.1.20 Subject: Re: [FFmpeg-devel] [PATCH] avformat/http: remove duplicate user-agent option X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" 2016-09-16 0:35 GMT+08:00 Steven Liu : > ignore it please, i will fix some problem > > 2016-09-16 0:30 GMT+08:00 Steven Liu : > >> >> >> 2016-09-16 0:21 GMT+08:00 Clément Bœsch : >> >>> On Fri, Sep 16, 2016 at 12:04:34AM +0800, Steven Liu wrote: >>> > 2016-09-15 23:42 GMT+08:00 Clément Bœsch : >>> > >>> > > On Thu, Sep 15, 2016 at 05:39:25PM +0200, Nicolas George wrote: >>> > > > Le decadi 30 fructidor, an CCXXIV, Clement Boesch a écrit : >>> > > > > Yes, surrounded by the #ifdefery so it will go away with the >>> option. >>> > > > > >>> > > > > Note: use av_strdup() to transfer from one field to the other >>> > > > >>> > > > Another possibility would be to implement AV_OPT_FLAG_DEPRECATED >>> and let >>> > > the >>> > > > options system itself print the warning. >>> > > > >>> > > >>> > > That's not a bad idea; you might need to add a field to redirect to >>> > > the new option though. >>> > > >>> > > -- >>> > > Clément B. >>> > > _______________________________________________ >>> > > >>> > >>> > >>> > Hi guys, >>> > >>> > are you mean like this? >>> > >>> > localhost:xxx StevenLiu$ make >>> > CC libavformat/http.o >>> > src/libavformat/http.c:1041:27: warning: 'user_agent_deprecated' is >>> > deprecated [-Wdeprecated-declarations] >>> > if (av_strncasecmp(s->user_agent_deprecated, DEFAULT_USER_AGENT, >>> > strlen(DEFAULT_USER_AGENT))) { >>> > ^ >>> > src/libavformat/http.c:74:32: note: 'user_agent_deprecated' has been >>> > explicitly marked deprecated here >>> > attribute_deprecated char *user_agent_deprecated; >>> > ^ >>> > src/libavformat/http.c:1043:38: warning: 'user_agent_deprecated' is >>> > deprecated [-Wdeprecated-declarations] >>> > s->user_agent = av_strdup(s->user_agent_deprecated); >>> > ^ >>> > src/libavformat/http.c:74:32: note: 'user_agent_deprecated' has been >>> > explicitly marked deprecated here >>> > attribute_deprecated char *user_agent_deprecated; >>> > ^ >>> > 2 warnings generated. >>> > AR libavformat/libavformat.a >>> > >>> > >>> > and the modify like this? >>> > >>> > >>> > localhost:xxx StevenLiu$ git diff >>> > diff --git a/libavformat/http.c b/libavformat/http.c >>> > index adb3d92..df9cf1a 100644 >>> > --- a/libavformat/http.c >>> > +++ b/libavformat/http.c >>> > @@ -71,6 +71,7 @@ typedef struct HTTPContext { >>> > char *headers; >>> > char *mime_type; >>> > char *user_agent; >>> > + attribute_deprecated char *user_agent_deprecated; >>> >>> not attribute_deprecated >>> >>> #if 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. */ >>> > @@ -130,7 +131,7 @@ static const AVOption options[] = { >>> > { "http_proxy", "set HTTP proxy to tunnel through", >>> > OFFSET(http_proxy), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, D | E }, >>> > { "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", >>> >>> You want to deprecate user-agent, not user_agent. >>> >>> #if FF_API_HTTP_USER_AGENT >>> { "user-agent", "override User-Agent header", ... >>> #endif >>> >>> > OFFSET(user_agent_deprecated), 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 }, >>> > { "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 }, >>> > @@ -1037,6 +1038,10 @@ static int http_connect(URLContext *h, const >>> char >>> > *path, const char *local_path, >>> > send_expect_100 = 1; >>> > } >>> > >>> > + if (av_strncasecmp(s->user_agent_deprecated, DEFAULT_USER_AGENT, >>> > strlen(DEFAULT_USER_AGENT))) { >>> >>> - you need to check s->user_agent, not s->user_agent_deprecated >>> - strcmp() is enough >>> >>> > + av_log(s, AV_LOG_WARNING, "the user_agent option is >>> deprecated, >>> > please use user-agent option\n"); >>> >>> the other way around >>> >>> > + s->user_agent = av_strdup(s->user_agent_deprecated); >>> > + } >>> >>> -- >>> Clément B. >>> _______________________________________________ >>> >> >> >> >> >> >> patch update >> >> >> >> >> add a FF_OPT_FLAG_DEPRECATED define for compile. >> add a new variable for user_agent to give a deprecated warning message >> --- >> doc/protocols.texi | 4 +++- >> libavformat/http.c | 14 ++++++++++++-- >> libavformat/version.h | 3 +++ >> 3 files changed, 18 insertions(+), 3 deletions(-) >> >> diff --git a/doc/protocols.texi b/doc/protocols.texi >> index 470c99c..3acdc78 100644 >> --- a/doc/protocols.texi >> +++ b/doc/protocols.texi >> @@ -292,10 +292,12 @@ Use persistent connections if set to 1, default is >> 0. >> 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/") >> >> +@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 >> diff --git a/libavformat/http.c b/libavformat/http.c >> index adb3d92..7dbe614 100644 >> --- a/libavformat/http.c >> +++ b/libavformat/http.c >> @@ -71,6 +71,9 @@ typedef struct HTTPContext { >> char *headers; >> char *mime_type; >> char *user_agent; >> +#ifdef FF_OPT_FLAG_DEPRECATED >> + attribute_deprecated 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. */ >> @@ -130,7 +133,9 @@ static const AVOption options[] = { >> { "http_proxy", "set HTTP proxy to tunnel through", >> OFFSET(http_proxy), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, D | E }, >> { "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 }, >> +#ifdef FF_OPT_FLAG_DEPRECATED >> + { "user_agent", "override User-Agent header", >> OFFSET(user_agent_deprecated), AV_OPT_TYPE_STRING, { .str = >> DEFAULT_USER_AGENT }, 0, 0, D }, >> +#endif >> { "user-agent", "override User-Agent header", 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_BOOL, { .i64 = 0 }, 0, 1, D | E }, >> { "post_data", "set custom HTTP post data", OFFSET(post_data), >> AV_OPT_TYPE_BINARY, .flags = D | E }, >> @@ -1036,7 +1041,12 @@ static int http_connect(URLContext *h, const char >> *path, const char *local_path, >> s->http_code != 401) >> send_expect_100 = 1; >> } >> - >> +#ifdef FF_OPT_FLAG_DEPRECATED >> + if (av_strncmp(s->user_agent_deprecated, DEFAULT_USER_AGEN)) { >> + 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, >> diff --git a/libavformat/version.h b/libavformat/version.h >> index 34226ca..518aac7 100644 >> --- a/libavformat/version.h >> +++ b/libavformat/version.h >> @@ -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_OPT_FLAG_DEPRECATED >> +#define FF_OPT_FLAG_DEPRECATED (LIBAVFORMAT_VERSION_MAJOR < 58) >> +#endif >> >> #ifndef FF_API_R_FRAME_RATE >> #define FF_API_R_FRAME_RATE 1 >> -- >> 2.7.4 (Apple Git-66) >> > > update: add a FF_OPT_FLAG_DEPRECATED define for compile. add a new variable for user_agent to give a deprecated warning message --- doc/protocols.texi | 4 +++- libavformat/http.c | 14 ++++++++++++-- libavformat/version.h | 3 +++ 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/doc/protocols.texi b/doc/protocols.texi index 470c99c..3acdc78 100644 --- a/doc/protocols.texi +++ b/doc/protocols.texi @@ -292,10 +292,12 @@ Use persistent connections if set to 1, default is 0. 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/") +@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 diff --git a/libavformat/http.c b/libavformat/http.c index adb3d92..0b8a86c 100644 --- a/libavformat/http.c +++ b/libavformat/http.c @@ -71,6 +71,9 @@ typedef struct HTTPContext { char *headers; char *mime_type; char *user_agent; +#ifdef FF_OPT_FLAG_DEPRECATED + attribute_deprecated 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. */ @@ -130,7 +133,9 @@ static const AVOption options[] = { { "http_proxy", "set HTTP proxy to tunnel through", OFFSET(http_proxy), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, D | E }, { "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 }, +#ifdef FF_OPT_FLAG_DEPRECATED + { "user_agent", "override User-Agent header", OFFSET(user_agent_deprecated), AV_OPT_TYPE_STRING, { .str = DEFAULT_USER_AGENT }, 0, 0, D }, +#endif { "user-agent", "override User-Agent header", 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_BOOL, { .i64 = 0 }, 0, 1, D | E }, { "post_data", "set custom HTTP post data", OFFSET(post_data), AV_OPT_TYPE_BINARY, .flags = D | E }, @@ -1036,7 +1041,12 @@ static int http_connect(URLContext *h, const char *path, const char *local_path, s->http_code != 401) send_expect_100 = 1; } - +#ifdef FF_OPT_FLAG_DEPRECATED + 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, diff --git a/libavformat/version.h b/libavformat/version.h index 34226ca..518aac7 100644 --- a/libavformat/version.h +++ b/libavformat/version.h @@ -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_OPT_FLAG_DEPRECATED +#define FF_OPT_FLAG_DEPRECATED (LIBAVFORMAT_VERSION_MAJOR < 58) +#endif #ifndef FF_API_R_FRAME_RATE #define FF_API_R_FRAME_RATE 1