Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
* [FFmpeg-devel] [PATCH 1/2] libavformat/http: Use http_read_header in http_shutdown to react to response errors
@ 2022-12-11  1:09 Basel Sayeh
  2022-12-11  1:11 ` [FFmpeg-devel] [PATCH 2/2] libavformat/hlsenc: Return in hls_write_packet if error after retrying with a new http session Basel Sayeh
  0 siblings, 1 reply; 2+ messages in thread
From: Basel Sayeh @ 2022-12-11  1:09 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Basel Sayeh

Use http_read_header to parse and print/react to errors in http_shutdown if
 the http server responds with an error (404/500/...)

Signed-off-by: Basel Sayeh <basel.sayeh@hotmail.com>
---
 libavformat/http.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/libavformat/http.c b/libavformat/http.c
index 7bce821535..123a7c77f2 100644
--- a/libavformat/http.c
+++ b/libavformat/http.c
@@ -1853,15 +1853,13 @@ static int http_shutdown(URLContext *h, int flags)
         ((flags & AVIO_FLAG_READ) && s->chunked_post && s->listen)) {
         ret = ffurl_write(s->hd, footer, sizeof(footer) - 1);
         ret = ret > 0 ? 0 : ret;
-        /* flush the receive buffer when it is write only mode */
+
+        /* Read and parse http headers when it is write only mode to react to response errors */
         if (!(flags & AVIO_FLAG_READ)) {
-            char buf[1024];
             int read_ret;
-            s->hd->flags |= AVIO_FLAG_NONBLOCK;
-            read_ret = ffurl_read(s->hd, buf, sizeof(buf));
-            s->hd->flags &= ~AVIO_FLAG_NONBLOCK;
+            read_ret = http_read_header(h);
             if (read_ret < 0 && read_ret != AVERROR(EAGAIN)) {
-                av_log(h, AV_LOG_ERROR, "URL read error: %s\n", av_err2str(read_ret));
+                av_log(h, AV_LOG_ERROR, "HTTP error: %s\n", av_err2str(read_ret));
                 ret = read_ret;
             }
         }
-- 
2.30.2

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-12-11  1:11 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-11  1:09 [FFmpeg-devel] [PATCH 1/2] libavformat/http: Use http_read_header in http_shutdown to react to response errors Basel Sayeh
2022-12-11  1:11 ` [FFmpeg-devel] [PATCH 2/2] libavformat/hlsenc: Return in hls_write_packet if error after retrying with a new http session Basel Sayeh

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git