From patchwork Wed Feb 20 14:54:06 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vittorio Giovara X-Patchwork-Id: 12117 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 04882448B27 for ; Wed, 20 Feb 2019 17:00:00 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id D96AC68AC39; Wed, 20 Feb 2019 16:59:59 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-qt1-f196.google.com (mail-qt1-f196.google.com [209.85.160.196]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 0C88C68AA54 for ; Wed, 20 Feb 2019 16:59:53 +0200 (EET) Received: by mail-qt1-f196.google.com with SMTP id j36so27464149qta.7 for ; Wed, 20 Feb 2019 06:59:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=DDQAyOqsJsAyh6Gg4/xjfEHBHY5bY9ioCBdMC/q90Vg=; b=meMI78ZikY7yw5UvWc+j3CT26brSVl921OQm3LCWNIUbeo7Hj5LLtFpOoyVelo6/el pWFWRtd879zTZfpSzGIk+9SxhGSYbP/SZiblAotd6kyiYCOaBRKX+9jFg+J8CwgMZXM4 A2P8wcGvSQcYpZ0bFuChOQuvjgZjeSTtWCSyy8QxNGfsw07ejM32cDC2b93FB55aQ6dX 7eFoSfVJiWjstZSpa1VQiCcGp5bhwm7ikAoi5bNoD+VG05aF3Rad86ZL8ZORRc4oicHP uI5vQnIIOottMSU7fXZagRU4+HDCGiFRlPghTLS74O2E45zctEGZMCvd+DfBMnpGnXiI cXwA== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=DDQAyOqsJsAyh6Gg4/xjfEHBHY5bY9ioCBdMC/q90Vg=; b=SJOMRMSe7pKos0w2ATgryyK9+ihKMJvbGTeFQ4OBVe407LpzIBAryuOjPIOBcRLZNo Ee8uSOqEOM/YMylEButZRwnFGHGHfrya5MVXyPaQH+yDQtl+oXb/djyJRaVlTzlKT96j GWGpJ5F7PB5MdWjuiV4gJ4vaxceocXLlXul733zwlZ9ANGnIMS4DaO6hW6vXIYGsxwin QTRlNTGyCRsLT/QM0RoXvbS2ogQh7Xe4223z878KNH5XivcHoO78wdrT4nlqTwMPg+Oe +6zHfF4yfoDkD0IfYJP0gnRj25pYymZ9pQUgoTRAVcLspfkV2g+dHRb/uiutnrA63oTq ztiw== X-Gm-Message-State: AHQUAubzHFXa0nh/GZ0+1R3dKIESVO8BMr1BoYM601uxE4zxtYK8tqdM R2WHpvHMEpDNHlACEUqsFTq5MBIO X-Google-Smtp-Source: AHgI3IZai4Ybk0TaessF2TO5DQri/Z7PFW6ZbWQsodw3tlXE1tJQex72ZvuTOX6nX23P5YgyhEJ3dw== X-Received: by 2002:ac8:67d3:: with SMTP id r19mr26749769qtp.196.1550674448080; Wed, 20 Feb 2019 06:54:08 -0800 (PST) Received: from vimacnew.iac.corp ([8.40.92.161]) by smtp.gmail.com with ESMTPSA id z43sm1236090qtj.66.2019.02.20.06.54.06 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 20 Feb 2019 06:54:07 -0800 (PST) From: Vittorio Giovara To: ffmpeg-devel@ffmpeg.org Date: Wed, 20 Feb 2019 09:54:06 -0500 Message-Id: <20190220145406.55022-1-vittorio.giovara@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: References: MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH] http: Do not try to make a new request when seeking past the end of the file 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" From: Justin Ruggles This avoids making invalid HTTP Range requests for a byte range past the known end of the file during a seek. Those requests generally return a HTTP response of 416 Range Not Satisfiable, which causes an error response. Reference: https://tools.ietf.org/html/rfc7233 Signed-off-by: Vittorio Giovara --- libavformat/http.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/libavformat/http.c b/libavformat/http.c index a0a0636cf2..1e40268599 100644 --- a/libavformat/http.c +++ b/libavformat/http.c @@ -1691,6 +1691,13 @@ static int64_t http_seek_internal(URLContext *h, int64_t off, int whence, int fo if (s->off && h->is_streamed) return AVERROR(ENOSYS); + /* do not try to make a new connection if seeking past the end of the file */ + if (s->end_off || s->filesize != UINT64_MAX) { + uint64_t end_pos = s->end_off ? s->end_off : s->filesize; + if (s->off >= end_pos) + return s->off; + } + /* we save the old context in case the seek fails */ old_buf_size = s->buf_end - s->buf_ptr; memcpy(old_buf, s->buf_ptr, old_buf_size);