From patchwork Fri Mar 22 23:12:22 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jun Li X-Patchwork-Id: 12395 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 93112447E05 for ; Sat, 23 Mar 2019 01:12:38 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 6EF0568A754; Sat, 23 Mar 2019 01:12:38 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pg1-f195.google.com (mail-pg1-f195.google.com [209.85.215.195]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id CA88A68A723 for ; Sat, 23 Mar 2019 01:12:30 +0200 (EET) Received: by mail-pg1-f195.google.com with SMTP id r124so2494414pgr.3 for ; Fri, 22 Mar 2019 16:12:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id; bh=wYhZYohg/mOv6V0ZpFubJ76raW9SeC9SnR91bv36KvY=; b=Q6L54CnNtu67Aq+HFEpdjNDhzeNT7kGqO+MOUUR8Y1QxqA04CaiDY0thRCp8eoBiyJ e8DDlYVxRIvOBU+q0hvviyFMNM1sGp27LVUpBlCBhX0NF0N5TGH8+I7UkX0F0NNv3f1q Y3fJiniHlhFBCyhrZSFlOZ5BSL6L6Tk8gtUvbkrupKvka4/Fe/mCihBgwPnzftsSe6Y4 tKsptUUH3QC1Q2AGqgGd9H8NzDDxgEsTItwnEanP/3qd5PWf3Nq91SmD9UgGnY3tw0zA CPPjJIPysoUd2Ts7OgH8OSuKO+pv+ChkEYBWCwRIb+d39efyCuXBdqvet2OU42dHTREb 4ENw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id; bh=wYhZYohg/mOv6V0ZpFubJ76raW9SeC9SnR91bv36KvY=; b=X47bh8YxCD6X7O/n/+fydR8IslSw37xHWSbjv9FKb50udNRWPaoNuE6efTF2Jr++eC JTou2S9O7a7iGHR5Bh0eB4/VsuPxVLAi+S3ks1mV6sOyg7NMzctDMO7sHoTAt/FpPXVH iEOCTYpzvRugltGebu5C0URgLsOHOUMn+imBT+vKe8c1vTdqbVSdNNEuINjJXKVm4JDa Pyn4yt7Jpfb0rHzyFWU6Z2f6gh0QtgVfKd8ayu5CGuSOlVehwiMPkTf9By29YQHWtCvi WMEV4ctCXge9ZrqaoQbvkA+W1WqWOqbv366wxWZiE4ca6dAowwGuUzRb5hloGskz3xl9 bbDA== X-Gm-Message-State: APjAAAURRF/xeSskchi2yv6KvQwR0w4V67uVDBJFT8HMWCtU7kuPebK3 c0KKLu8MlmnSn4IbPjAy4UhSYJE1 X-Google-Smtp-Source: APXvYqwEUWDIHM9Z/2QMn6NOLKwlqg3z8JN840kRSz6uE7swpcGsO4s2GfKPg0Fk6fTy9PECWYjgSw== X-Received: by 2002:a63:1410:: with SMTP id u16mr10137096pgl.420.1553296348595; Fri, 22 Mar 2019 16:12:28 -0700 (PDT) Received: from jun-ubuntu.corp.microsoft.com ([2001:4898:80e8:9:24a4:3dda:2b5:c2f5]) by smtp.googlemail.com with ESMTPSA id d12sm14701456pfh.168.2019.03.22.16.12.27 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 22 Mar 2019 16:12:27 -0700 (PDT) From: Jun Li To: ffmpeg-devel@ffmpeg.org Date: Fri, 22 Mar 2019 16:12:22 -0700 Message-Id: <20190322231222.21546-1-junli1026@gmail.com> X-Mailer: git-send-email 2.17.1 Subject: [FFmpeg-devel] [PATCH v4] avformat/http, icecast, rtsp: Add option to disable send-100-continue 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 MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" The current setting for send-100-continue option is either enabled if applicable or forced enabled, no option to force disable the header. This change is to expand the option setting to provide more flexibility, which is useful for rstp case. --- libavformat/http.c | 28 +++++++++++++++++----------- libavformat/icecast.c | 2 +- libavformat/rtsp.c | 1 + 3 files changed, 19 insertions(+), 12 deletions(-) diff --git a/libavformat/http.c b/libavformat/http.c index 74d743850d..5a937994cf 100644 --- a/libavformat/http.c +++ b/libavformat/http.c @@ -113,6 +113,7 @@ typedef struct HTTPContext { uint8_t *inflate_buffer; #endif /* CONFIG_ZLIB */ AVDictionary *chained_options; + /* -1 = try to send if applicable, 0 = always disabled, 1 = always enabled */ int send_expect_100; char *method; int reconnect; @@ -155,7 +156,7 @@ static const AVOption options[] = { { "auth_type", "HTTP authentication type", OFFSET(auth_state.auth_type), AV_OPT_TYPE_INT, { .i64 = HTTP_AUTH_NONE }, HTTP_AUTH_NONE, HTTP_AUTH_BASIC, D | E, "auth_type"}, { "none", "No auth method set, autodetect", 0, AV_OPT_TYPE_CONST, { .i64 = HTTP_AUTH_NONE }, 0, 0, D | E, "auth_type"}, { "basic", "HTTP basic authentication", 0, AV_OPT_TYPE_CONST, { .i64 = HTTP_AUTH_BASIC }, 0, 0, D | E, "auth_type"}, - { "send_expect_100", "Force sending an Expect: 100-continue header for POST", OFFSET(send_expect_100), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, E }, + { "send_expect_100", "Force sending an Expect: 100-continue header for POST", OFFSET(send_expect_100), AV_OPT_TYPE_BOOL, { .i64 = -1 }, -1, 1, E }, { "location", "The actual location of the data received", OFFSET(location), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, D | E }, { "offset", "initial byte offset", OFFSET(off), AV_OPT_TYPE_INT64, { .i64 = 0 }, 0, INT64_MAX, D }, { "end_offset", "try to limit the request to bytes preceding this offset", OFFSET(end_off), AV_OPT_TYPE_INT64, { .i64 = 0 }, 0, INT64_MAX, D }, @@ -1179,16 +1180,21 @@ static int http_connect(URLContext *h, const char *path, const char *local_path, local_path, method); proxyauthstr = ff_http_auth_create_response(&s->proxy_auth_state, proxyauth, local_path, method); - if (post && !s->post_data) { - send_expect_100 = s->send_expect_100; - /* The user has supplied authentication but we don't know the auth type, - * send Expect: 100-continue to get the 401 response including the - * WWW-Authenticate header, or an 100 continue if no auth actually - * is needed. */ - if (auth && *auth && - s->auth_state.auth_type == HTTP_AUTH_NONE && - s->http_code != 401) - send_expect_100 = 1; + + if (post && !s->post_data) { + if (s->send_expect_100 != -1) { + send_expect_100 = s->send_expect_100; + } else { + send_expect_100 = 0; + /* The user has supplied authentication but we don't know the auth type, + * send Expect: 100-continue to get the 401 response including the + * WWW-Authenticate header, or an 100 continue if no auth actually + * is needed. */ + if (auth && *auth && + s->auth_state.auth_type == HTTP_AUTH_NONE && + s->http_code != 401) + send_expect_100 = 1; + } } #if FF_API_HTTP_USER_AGENT diff --git a/libavformat/icecast.c b/libavformat/icecast.c index c93b06b553..d2198b78ec 100644 --- a/libavformat/icecast.c +++ b/libavformat/icecast.c @@ -115,7 +115,7 @@ static int icecast_open(URLContext *h, const char *uri, int flags) av_dict_set(&opt_dict, "auth_type", "basic", 0); av_dict_set(&opt_dict, "headers", headers, 0); av_dict_set(&opt_dict, "chunked_post", "0", 0); - av_dict_set(&opt_dict, "send_expect_100", s->legacy_icecast ? "0" : "1", 0); + av_dict_set(&opt_dict, "send_expect_100", s->legacy_icecast ? "-1" : "1", 0); if (NOT_EMPTY(s->content_type)) av_dict_set(&opt_dict, "content_type", s->content_type, 0); else diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c index ae8811234a..6e67e411b9 100644 --- a/libavformat/rtsp.c +++ b/libavformat/rtsp.c @@ -1793,6 +1793,7 @@ redirect: sessioncookie); av_opt_set(rt->rtsp_hd_out->priv_data, "headers", headers, 0); av_opt_set(rt->rtsp_hd_out->priv_data, "chunked_post", "0", 0); + av_opt_set(rt->rtsp_hd_out->priv_data, "send_expect_100", "0", 0); /* Initialize the authentication state for the POST session. The HTTP * protocol implementation doesn't properly handle multi-pass