handle IPv6 sources
[record-dvb] / http.c
diff --git a/http.c b/http.c
index eee73454e763b0b5d5770954cfeeb7a146e8cad3..c7e553cc7511bd7769356fb77c68c00bf52b6791 100644 (file)
--- a/http.c
+++ b/http.c
@@ -27,17 +27,15 @@ int open_http(char *url)
 {
        int fd;
        struct sockaddr_in server;
-       static struct dvb_host *dvbhost = NULL;
+       struct dvb_host *dvbhost = NULL;
        char c, buffer[BUFFSIZE], *pos;
        int lines = 0;
 
        if(!is_http(url))
                return -1;
 
-       if (!dvbhost) {
-               dvbhost = parse(&(url[7]), "80");
-               dvbhost->socktype = SOCK_STREAM;
-       }
+       dvbhost = parse(&(url[7]), "80");
+       dvbhost->socktype = SOCK_STREAM;
 
        if (resolve(dvbhost, &server) < 0) {
                return -1;
@@ -91,8 +89,7 @@ int open_http(char *url)
 
                                pos = buffer;
                                while (*pos != 0) {
-                                       if (*pos == ' ') {
-                                               pos++;
+                                       if (*(pos++) == ' ') {
                                                if(strncmp("200", pos, 3)) {
                                                        fprintf(stderr, "Wrong result-code: %s\n", buffer);
                                                        return -1;
@@ -100,7 +97,11 @@ int open_http(char *url)
                                                        break;
                                                }
                                        }
-                                       pos++;
+
+                                       if (*(++pos) == 0) {
+                                               fprintf(stderr, "Wrong answer from server: %s\n", buffer);
+                                               return -1;
+                                       }
                                }
                        }
 
Impressum, Datenschutz