aboutsummaryrefslogtreecommitdiffstats
path: root/src/inputStream_http.c
diff options
context:
space:
mode:
authorWarren Dukes <warren.dukes@gmail.com>2004-05-18 13:13:55 +0000
committerWarren Dukes <warren.dukes@gmail.com>2004-05-18 13:13:55 +0000
commitc51ad71efaa975c64f6ad31dce5578307a5cba7b (patch)
tree348881ea4c5b04bd17e04e881905dbacef296869 /src/inputStream_http.c
parent6c24180516f823985f564ba013607b47f70afa81 (diff)
downloadmpd-c51ad71efaa975c64f6ad31dce5578307a5cba7b.tar.gz
mpd-c51ad71efaa975c64f6ad31dce5578307a5cba7b.tar.xz
mpd-c51ad71efaa975c64f6ad31dce5578307a5cba7b.zip
rework stuff so that we can use mime-type of streams to detect type of file
git-svn-id: https://svn.musicpd.org/mpd/trunk@1062 09075e82-0dd4-0310-85a5-a0d7c8717e4f
Diffstat (limited to '')
-rw-r--r--src/inputStream_http.c41
1 files changed, 20 insertions, 21 deletions
diff --git a/src/inputStream_http.c b/src/inputStream_http.c
index c2c1b0904..9d0909ba2 100644
--- a/src/inputStream_http.c
+++ b/src/inputStream_http.c
@@ -381,11 +381,13 @@ static int getHTTPHello(InputStream * inStream) {
*temp = '\r';
}
else if(0 == strncmp(cur, "\r\nContent-Type:", 15)) {
- char * temp = strstr(cur+15,"\r\n");
+ char * temp2 = cur+15;
+ char * temp = strstr(temp2,"\r\n");
if(!temp) break;
+ while(*temp2 && *temp2==' ') temp2++;
*temp = '\0';
if(inStream->mime) free(inStream->mime);
- inStream->mime = strdup(cur+15);
+ inStream->mime = strdup(temp2);
*temp = '\r';
}
@@ -455,13 +457,15 @@ size_t inputStream_httpRead(InputStream * inStream, void * ptr, size_t size,
return 0;
}
- readed = inlen > data->buflen ? data->buflen : inlen;
+ if(data->buflen > 0) {
+ readed = inlen > data->buflen ? data->buflen : inlen;
- memcpy(ptr, data->buffer, readed);
- data->buflen -= readed;
- memmove(data->buffer, data->buffer+readed, data->buflen);
+ memcpy(ptr, data->buffer, readed);
+ data->buflen -= readed;
+ memmove(data->buffer, data->buffer+readed, data->buflen);
- inStream->offset+= readed;
+ inStream->offset+= readed;
+ }
return readed;
}
@@ -536,22 +540,17 @@ int inputStream_httpBuffer(InputStream * inStream) {
return 0;
}
- if(ret == 1) {
- readed = recv(data->sock,
- data->buffer+data->buflen,
- HTTP_BUFFER_SIZE-1-data->buflen, 0);
+ if(ret == 0) return 0;
- if(readed < 0 && (errno == EAGAIN ||
- errno == EINTR))
- {
- readed = 0;
- }
- else if(readed <= 0) {
- close(data->sock);
- data->connState = HTTP_CONN_STATE_CLOSED;
- }
- else data->buflen += readed;
+ readed = recv(data->sock, data->buffer+data->buflen,
+ HTTP_BUFFER_SIZE-1-data->buflen, 0);
+
+ if(readed < 0 && (errno == EAGAIN || errno == EINTR));
+ else if(readed <= 0) {
+ close(data->sock);
+ data->connState = HTTP_CONN_STATE_CLOSED;
}
+ else data->buflen += readed;
}
return 0;