diff http.c @ 385:2f56d366a787 libavformat

no read loop tcp/http and http CRLF fix by (Leon van Stuivenberg <l dot vanstuivenberg at chello dot nl>)
author michael
date Sun, 14 Mar 2004 02:59:33 +0000
parents 741c56c608bb
children 0fdc96c2f2fe
line wrap: on
line diff
--- a/http.c	Sat Mar 13 23:04:37 2004 +0000
+++ b/http.c	Sun Mar 14 02:59:33 2004 +0000
@@ -183,11 +183,11 @@
     post = h->flags & URL_WRONLY;
 
     snprintf(s->buffer, sizeof(s->buffer),
-             "%s %s HTTP/1.0\n"
-             "User-Agent: %s\n"
-             "Accept: */*\n"
-             "Host: %s\n"
-             "\n",
+             "%s %s HTTP/1.0\r\n"
+             "User-Agent: %s\r\n"
+             "Accept: */*\r\n"
+             "Host: %s\r\n"
+             "\r\n",
              post ? "POST" : "GET",
              path,
              LIBAVFORMAT_IDENT,
@@ -238,29 +238,19 @@
 static int http_read(URLContext *h, uint8_t *buf, int size)
 {
     HTTPContext *s = h->priv_data;
-    int size1, len;
+    int len;
 
-    size1 = size;
-    while (size > 0) {
-        /* read bytes from input buffer first */
-        len = s->buf_end - s->buf_ptr;
-        if (len > 0) {
-            if (len > size)
-                len = size;
-            memcpy(buf, s->buf_ptr, len);
-            s->buf_ptr += len;
-        } else {
-            len = url_read (s->hd, buf, size);
-            if (len < 0) {
-                return len;
-            } else if (len == 0) {
-                break;
-            }
-        }
-        size -= len;
-        buf += len;
+    /* read bytes from input buffer first */
+    len = s->buf_end - s->buf_ptr;
+    if (len > 0) {
+        if (len > size)
+            len = size;
+        memcpy(buf, s->buf_ptr, len);
+        s->buf_ptr += len;
+    } else {
+        len = url_read(s->hd, buf, size);
     }
-    return size1 - size;
+    return len;
 }
 
 /* used only when posting data */