[FFmpeg-devel] [PATCH][GSoC] lavf/http: Add simple autodetection for client HTTP method, based on AVIO_FLAG_READ.

Stephan Holljes klaxa1337 at googlemail.com
Fri Jun 5 00:27:07 CEST 2015


Signed-off-by: Stephan Holljes <klaxa1337 at googlemail.com>
---
 libavformat/http.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/libavformat/http.c b/libavformat/http.c
index 90e88ad..32fc1ce 100644
--- a/libavformat/http.c
+++ b/libavformat/http.c
@@ -563,6 +563,7 @@ 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;
 
@@ -587,6 +588,14 @@ static int process_line(URLContext *h, char *line, int line_count,
                            s->method, method);
                     return ff_http_averror(400, AVERROR(EIO));
                 }
+            } 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);
+                    return ff_http_averror(400, AVERROR(EIO));
+                }
             }
 
             // HTTP resource
-- 
2.1.0



More information about the ffmpeg-devel mailing list