summaryrefslogtreecommitdiff
path: root/libavformat/http.c
diff options
context:
space:
mode:
authorStephan Holljes <klaxa1337@googlemail.com>2015-06-05 00:27:07 +0200
committerNicolas George <george@nsup.org>2015-06-06 09:24:50 +0200
commit44d19212008ee48255f96d82df899e3413a982c2 (patch)
tree1ffce24c42789c9745a0a7fef90a5ad119da47b8 /libavformat/http.c
parent290b23755673eaa8a6f32025734e8f9916e75f6f (diff)
lavf/http: Add simple autodetection for client HTTP method, based on AVIO_FLAG_READ.
Signed-off-by: Stephan Holljes <klaxa1337@googlemail.com>
Diffstat (limited to 'libavformat/http.c')
-rw-r--r--libavformat/http.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/libavformat/http.c b/libavformat/http.c
index 1bf9166c27..2db2dea51e 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