changeset 6263:89adb1f9ff50 libavformat

http: Log a warning when receiving an error code
author mstorsjo
date Fri, 16 Jul 2010 14:15:37 +0000
parents 7b8b71ff9a76
children f4f55ad4a603
files http.c
diffstat 1 files changed, 7 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/http.c	Fri Jul 16 14:12:52 2010 +0000
+++ b/http.c	Fri Jul 16 14:15:37 2010 +0000
@@ -210,7 +210,7 @@
                         int *new_location)
 {
     HTTPContext *s = h->priv_data;
-    char *tag, *p;
+    char *tag, *p, *end;
 
     /* end of header */
     if (line[0] == '\0')
@@ -222,14 +222,18 @@
             p++;
         while (isspace(*p))
             p++;
-        s->http_code = strtol(p, NULL, 10);
+        s->http_code = strtol(p, &end, 10);
 
         dprintf(NULL, "http_code=%d\n", s->http_code);
 
         /* error codes are 4xx and 5xx, but regard 401 as a success, so we
          * don't abort until all headers have been parsed. */
-        if (s->http_code >= 400 && s->http_code < 600 && s->http_code != 401)
+        if (s->http_code >= 400 && s->http_code < 600 && s->http_code != 401) {
+            end += strspn(end, SPACE_CHARS);
+            av_log(NULL, AV_LOG_WARNING, "HTTP error %d %s\n",
+                   s->http_code, end);
             return -1;
+        }
     } else {
         while (*p != '\0' && *p != ':')
             p++;