summaryrefslogtreecommitdiff
path: root/libavformat/http.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2004-03-14 02:59:33 +0000
committerMichael Niedermayer <michaelni@gmx.at>2004-03-14 02:59:33 +0000
commit9eef2b77b29189606148e1fdf5d6c8d7b52b08b0 (patch)
tree8bab32620ce05bcb106c0ef9c7d56257d4911c2b /libavformat/http.c
parentc3775e542f8fda9eeda31cce1d588d70c2fcd56b (diff)
no read loop tcp/http and http CRLF fix by (Leon van Stuivenberg <l dot vanstuivenberg at chello dot nl>)
Originally committed as revision 2885 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavformat/http.c')
-rw-r--r--libavformat/http.c42
1 files changed, 16 insertions, 26 deletions
diff --git a/libavformat/http.c b/libavformat/http.c
index e992865442..6ae9d72a8e 100644
--- a/libavformat/http.c
+++ b/libavformat/http.c
@@ -183,11 +183,11 @@ static int http_connect(URLContext *h, const char *path, const char *hoststr)
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_connect(URLContext *h, const char *path, const char *hoststr)
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 */