From patchwork Fri Feb 15 16:34:43 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vittorio Giovara X-Patchwork-Id: 12083 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 AF946448C52 for ; Fri, 15 Feb 2019 18:41:30 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 95A1168A7DF; Fri, 15 Feb 2019 18:41:30 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-vs1-f66.google.com (mail-vs1-f66.google.com [209.85.217.66]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id B0E0268A57B for ; Fri, 15 Feb 2019 18:41:23 +0200 (EET) Received: by mail-vs1-f66.google.com with SMTP id z18so6161869vso.7 for ; Fri, 15 Feb 2019 08:41:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=e1qGiFDW/S70mD4v1cG0DqdjC/UdV/ISDCXvIhLm46c=; b=b22YcoC+szCwrsbCcg4sSY1NJIhA7Pl+4srodrCpBkHpREuWPs6dwl/xRcMNcdWhFq 8aMbGcvBf0ccqX1Rc96S2BJsqX7d1RKDt7kMJJbl4anoSoTDIAHCdqGvL4SEvGWm6OD3 cDVByxdasuYv2zdNETSHejvJoN6G/B3MnUG4FOnsxXf6SUJXrtFL+pjBCg9IF4K0CkqJ teePZvH82qCV5hXlB0hRVrKmeuwY0BM/i+tmJhN6lp4GszhbQS8v5AuX7AhF4Jd5xnxI Xsiujmimx8Yqs5RK1dZp+njN6YmutnrqIOwY+R+e7iQjYmnjMydbT0g1iP2NTHj05J2G 7ZrA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=e1qGiFDW/S70mD4v1cG0DqdjC/UdV/ISDCXvIhLm46c=; b=eg7SiJnkzToayoHrJWY340Y4ZQyrI7ztqE2PHfzImgteF+KVyfmfv9CbdB1e11B7FX ydvGmcXiILlZF687Y9brx153GIrjigEDy3Q1+uP6bd5A+Hhx6tkX5PCJ1uIVz9A5Sgnf Vgx/z19vsIaGG7p2nqPhs9RC/xGlFhrGNVb/vPSrcFNGrvWhQmQB5Q3YdupWIiO2YEHa tc+BPhEgZLrh63U6AMxqHA2OazzbPlTvmQLEaCtGPi4ncEg0jqUY88sp1QlJBb2kEmGP HlJ3buJLgWJz73YfOBXLL0sbvsYjX2MqSJin8oK+/sYXrmVVjLQraQw267i6zilw/2BN S4aA== X-Gm-Message-State: AHQUAualCjIUsCi92+h/tNqNDW8CfRIex542VdmEt06GMIyjQPYoSjS5 prTlPS3UNWbjkFKJU0BhQCHliQ03XV89kVuOdLVG7JRRyNc= X-Google-Smtp-Source: AHgI3IZm1tuAikkGtuAJsNylp9TwPREd2tdXKiVoWRp3xObQSR4y5OKf0T/jD48ka+7N2XvTi26o6utiQ6202VzLe5w= X-Received: by 2002:a67:8597:: with SMTP id h145mr4364523vsd.74.1550248495071; Fri, 15 Feb 2019 08:34:55 -0800 (PST) MIME-Version: 1.0 From: Vittorio Giovara Date: Fri, 15 Feb 2019 11:34:43 -0500 Message-ID: To: FFmpeg development discussions and patches X-Content-Filtered-By: Mailman/MimeDel 2.1.20 Subject: [FFmpeg-devel] [PATCH] avformat/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(+) old_buf_size = s->buf_end - s->buf_ptr; memcpy(old_buf, s->buf_ptr, old_buf_size); 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 */