http: Support relative URL redirection
authorZhang Rui <bbcallen@gmail.com>
Thu, 4 Jul 2013 09:18:52 +0000 (17:18 +0800)
committerMartin Storsjö <martin@martin.st>
Fri, 22 Nov 2013 12:27:04 +0000 (14:27 +0200)
In RFC 2616, this was explicitly said to be an absolute URL,
while in an upcoming draft [1] it is allowed to be relative as well.

[1] http://tools.ietf.org/html/draft-ietf-httpbis-p2-semantics-25#section-7.1.2

Signed-off-by: Martin Storsjö <martin@martin.st>
libavformat/http.c

index a26ec2a..eb08dfe 100644 (file)
@@ -335,7 +335,10 @@ static int process_line(URLContext *h, char *line, int line_count,
         while (av_isspace(*p))
             p++;
         if (!av_strcasecmp(tag, "Location")) {
         while (av_isspace(*p))
             p++;
         if (!av_strcasecmp(tag, "Location")) {
-            av_strlcpy(s->location, p, sizeof(s->location));
+            char redirected_location[MAX_URL_SIZE];
+            ff_make_absolute_url(redirected_location, sizeof(redirected_location),
+                                 s->location, p);
+            av_strlcpy(s->location, redirected_location, sizeof(s->location));
             *new_location = 1;
         } else if (!av_strcasecmp (tag, "Content-Length") && s->filesize == -1) {
             s->filesize = strtoll(p, NULL, 10);
             *new_location = 1;
         } else if (!av_strcasecmp (tag, "Content-Length") && s->filesize == -1) {
             s->filesize = strtoll(p, NULL, 10);