@@ -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;
}
}
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(-)