[PATCH 2/5] http_connect changed to use http_get_line

Peter Holik peter
Mon Jun 1 19:11:28 CEST 2009


Signed-off-by: Peter Holik <peter at holik.at>
---
 libavformat/http.c |   18 +++---------------
 1 files changed, 3 insertions(+), 15 deletions(-)

diff --git a/libavformat/http.c b/libavformat/http.c
index ffc34e1..f8c44ce 100644
--- a/libavformat/http.c
+++ b/libavformat/http.c
@@ -233,8 +233,8 @@ static int http_connect(URLContext *h, const char *path, const char *hoststr,
                         const char *auth, int *new_location)
 {
     HTTPContext *s = h->priv_data;
-    int post, err, ch;
-    char line[1024], *q;
+    int post, err;
+    char line[1024];
     char *auth_b64;
     int auth_b64_len = (strlen(auth) + 2) / 3 * 4 + 1;
     int64_t off = s->off;
@@ -275,16 +275,9 @@ static int http_connect(URLContext *h, const char *path, const char *hoststr,
     }
 
     /* wait for header */
-    q = line;
     for(;;) {
-        ch = http_getc(s);
-        if (ch < 0)
+        if (http_get_line(s, line, sizeof(line)) < 0)
             return AVERROR(EIO);
-        if (ch == '\n') {
-            /* process line */
-            if (q > line && q[-1] == '\r')
-                q--;
-            *q = '\0';
 #ifdef DEBUG
             printf("header='%s'\n", line);
 #endif
@@ -294,11 +287,6 @@ static int http_connect(URLContext *h, const char *path, const char *hoststr,
             if (err == 0)
                 break;
             s->line_count++;
-            q = line;
-        } else {
-            if ((q - line) < sizeof(line) - 1)
-                *q++ = ch;
-        }
     }
 
     return (off == s->off) ? 0 : -1;
-- 
1.6.3.1

------=_20090601194625_76390
Content-Type: text/x-patch; name="0003-cosmetics-for-http_connect.patch"
Content-Transfer-Encoding: 8bit
Content-Disposition: attachment;
      filename="0003-cosmetics-for-http_connect.patch"




More information about the ffmpeg-devel mailing list