Signed-off-by: Nicolas George <geo...@nsup.org> --- libavformat/http.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-)
diff --git a/libavformat/http.c b/libavformat/http.c index c9415578aa..135b533203 100644 --- a/libavformat/http.c +++ b/libavformat/http.c @@ -903,11 +903,19 @@ static int cookie_string(AVDictionary *dict, char **cookies) return 0; } +static int method_allowed(URLContext *h, const char *method) +{ + if (!av_strcasecmp(method, "GET") && (h->flags & AVIO_FLAG_WRITE)) + return 1; + if (!av_strcasecmp(method, "POST") && (h->flags & AVIO_FLAG_READ)) + return 1; + return 0; +} + static int process_line(URLContext *h, char *line, int line_count, int *new_location) { HTTPContext *s = h->priv_data; - const char *auto_method = h->flags & AVIO_FLAG_READ ? "POST" : "GET"; char *tag, *p, *end, *method, *resource, *version; int ret; @@ -934,10 +942,11 @@ static int process_line(URLContext *h, char *line, int line_count, } } else { // use autodetected HTTP method to expect - av_log(h, AV_LOG_TRACE, "Autodetected %s HTTP method\n", auto_method); - if (av_strcasecmp(auto_method, method)) { - av_log(h, AV_LOG_ERROR, "Received and autodetected HTTP method did not match " - "(%s autodetected %s received)\n", auto_method, method); + if (!method_allowed(h, method)) { + const char *mode[2][2] = { { "null", "read", }, { "write", "rw" } }; + av_log(h, AV_LOG_ERROR, "HTTP method %s not allowed in %s mode\n", + method, + mode[!!(h->flags & AVIO_FLAG_WRITE)][!!(h->flags & AVIO_FLAG_READ)]); return ff_http_averror(400, AVERROR(EIO)); } if (!(s->method = av_strdup(method))) -- 2.25.0 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".